Zach Schumacher
04/27/2021, 1:19 AMKubernetesRun
?Zach Schumacher
04/27/2021, 1:22 AMFailed to load and execute Flow's environment: ImportError('Unable to import Github, please ensure you have installed the github extra')
Zach Schumacher
04/27/2021, 1:22 AMFROM python:3.7.4-slim
# libpq-dev is required to install psycopg2-binary
RUN apt-get update && \
apt-get install libpq-dev curl -y && \
apt-get clean
WORKDIR /app
RUN useradd -m python && \
chown python:python -R /app
USER python
ENV POETRY_VERSION=1.1.4
ENV PATH=/home/python/.poetry/bin:/opt/bin:/home/python/.local/bin:$PATH
ENV PYTHONUNBUFFERED=1
RUN curl -sSL <https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py> | python
ADD pyproject.toml .
ADD poetry.lock .
RUN poetry config virtualenvs.create false && \
poetry run pip install --user -U pip && \
if [ "$install_dev" = "true" ] ; \
then poetry install ; \
else poetry install --no-dev ; \
fi
CMD poetry run python
Kevin Kho
pip install prefect[github]
Kevin Kho
Zach Schumacher
04/27/2021, 1:40 AMKevin Kho
Zach Schumacher
04/27/2021, 3:51 AMFROM prefecthq/prefect:0.14.16-python3.7
RUN apt-get update && \
apt-get install libpq-dev gcc libunwind-dev curl -y && \
apt-get clean
ENV POETRY_VERSION=1.1.4
ENV PATH=/root/.poetry/bin:$PATH
RUN curl -sSL <https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py> | python
ADD pyproject.toml .
ADD poetry.lock .
RUN pip install pygithub
RUN poetry config virtualenvs.create false && \
poetry run pip install -U pip && \
poetry install
Zach Schumacher
04/27/2021, 3:51 AM26 April 2021,11:50:20 agent INFO Submitted for execution: Job prefect-job-4b671fee
26 April 2021,11:50:23 execute flow-run ERROR Failed to load and execute Flow's environment: ImportError('Unable to import Github, please ensure you have installed the github extra')
26 April 2021,11:50:25 execute flow-run ERROR Failed to load and execute Flow's environment: ImportError('Unable to import Github, please ensure you have installed the github extra')
26 April 2021,11:50:27 k8s-infra ERROR Pod prefect-job-4b671fee-4m2cb failed.
Container 'flow' state: terminated
Exit Code:: 1
Reason: Error
26 April 2021,11:50:27 k8s-infra ERROR Pod prefect-job-4b671fee-cp9kj failed.
Container 'flow' state: terminated
Exit Code:: 1
Reason: Error
Kevin Kho
Zach Schumacher
04/27/2021, 4:53 AMZach Schumacher
04/27/2021, 1:59 PM@task()
def print_hello(name: str):
<http://logger.info|logger.info>(f"hello {name}!")
storage = GitHub(
repo="Simplebet/sbprefect", path="sbprefect/flows/example.py", access_token_secret="GITHUB_ACCESS_TOKEN"
)
environment = os.environ.get("ENVIRONMENT", "dev")
with Flow("Example", storage=storage) as flow:
example_task = print_hello("world")
flow.run_config = KubernetesRun(labels=[f"k8s-{environment}"], image=f"simplebet/sbprefect:{environment}")
Kevin Kho
with
block?Kevin Kho
with
Zach Schumacher
04/27/2021, 2:30 PMKevin Kho
with Flow("Example", storage=storage) as flow:
example_task = print_hello("world")
flow.run_config = KubernetesRun(labels=[f"k8s-{environment}"], image=f"simplebet/sbprefect:{environment}")
Zach Schumacher
04/27/2021, 2:34 PMKevin Kho
DockerRun
and seeing if you get the same error. If we get the same error, then at least we know it’s the container. If it works, then we know it’s on the k8s side.Kevin Kho
Kevin Kho
Kevin Kho
IfNotPresent
and you can change this to Always
to always pull the newest image. Some users find that their Docker container doesn’t update because Kubernetes already sees a version of the image.Zach Schumacher
04/27/2021, 2:43 PMZach Schumacher
04/27/2021, 2:43 PMKevin Kho
Zach Schumacher
04/27/2021, 3:09 PM:latest
• use a job template like the below
apiVersion: batch/v1
kind: Job
spec:
template:
spec:
containers:
- name: flow
imagePullPolicy: Always
Kevin Kho
Zach Schumacher
04/27/2021, 3:35 PMZach Schumacher
04/27/2021, 3:35 PMKevin Kho
Zach Schumacher
04/27/2021, 5:13 PMKevin Kho