Lew Dawson
09/26/2021, 7:37 PMDockerRun
run_config with Github
storage. Have the following project structure in the Github repo:
etl/
├── util/
│ ├── __init__.py
│ ├── util_vault.py
├── __init__.py
├── runner.py
The util_vault.py
looks like:
from prefect.client import Secret
class UtilVault:
@staticmethod
def get_secret_simple(name):
return Secret(name).get()
The runner.py
looks like:
from prefect import Flow, task, context
from prefect.run_configs import DockerRun
from prefect.storage import GitHub
from util.util_vault import UtilVault
logger = context.get("logger")
@task
def hello_secrets():
secret = UtilVault.get_secret_simple('GITHUB_ACCESS_TOKEN')
<http://logger.info|logger.info>('secret = %s', secret)
with Flow(name='hello_world') as flow:
hello_secrets()
flow.storage = GitHub(
repo='<username>/<repo>',
path='etl/runner.py',
access_token_secret='GITHUB_ACCESS_TOKEN',
)
flow.run_config = run_config=DockerRun(
image='<registry-name>/prefect-runner-base-image:1.0.0',
)
When I run this task, I get ModuleNotFoundError: No module named 'util'
. Any help would be much appreciated.Lew Dawson
09/26/2021, 7:45 PMetl/
isn't part of the sys.path/pythonpath, so Python doesn't know where to search for the util
module.Lew Dawson
09/26/2021, 7:47 PMKevin Kho
pip install path_to_module
). This requires the setup.py
file.Lew Dawson
09/26/2021, 8:35 PMKevin Kho
Lew Dawson
09/26/2021, 8:42 PMLew Dawson
09/26/2021, 8:43 PMLew Dawson
09/26/2021, 8:44 PMKevin Kho
Kevin Kho
create_container
call is hereLew Dawson
09/26/2021, 9:06 PMWORKDIR
of container. It must get mounted somewhere else on the image...Kevin Kho
Lew Dawson
09/26/2021, 9:35 PMAnna Geller