Hi I am getting this erro on CI when I try to regi...
# ask-community
j
Hi I am getting this erro on CI when I try to register my flow (which uses the
RunNamespacedJob
task); How can I force it to defer trying to access the cluster until its actually running?
Copy code
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/runpy.py", line 185, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/local/lib/python3.8/runpy.py", line 111, in _get_module_details
    __import__(pkg_name)
  File "/home/circleci/project/prefect_pipelines/__init__.py", line 8, in <module>
    from prefect_pipelines.pod_tasks.flow import flow as pod_tasks
  File "/home/circleci/project/prefect_pipelines/pod_tasks/flow.py", line 12, in <module>
    make_coal_input.run()
  File "/home/circleci/.cache/pypoetry/virtualenvs/prefect-pipelines-3aSsmiER-py3.8/lib/python3.8/site-packages/prefect/utilities/tasks.py", line 454, in method
    return run_method(self, *args, **kwargs)
  File "/home/circleci/.cache/pypoetry/virtualenvs/prefect-pipelines-3aSsmiER-py3.8/lib/python3.8/site-packages/prefect/tasks/kubernetes/job.py", line 713, in run
    client.BatchV1Api, get_kubernetes_client("job", kubernetes_api_key_secret)
  File "/home/circleci/.cache/pypoetry/virtualenvs/prefect-pipelines-3aSsmiER-py3.8/lib/python3.8/site-packages/prefect/utilities/kubernetes.py", line 54, in get_kubernetes_client
    kubernetes_api_key = Secret(kubernetes_api_key_secret).get()
  File "/home/circleci/.cache/pypoetry/virtualenvs/prefect-pipelines-3aSsmiER-py3.8/lib/python3.8/site-packages/prefect/client/secrets.py", line 131, in get
    raise ValueError(
ValueError: Secrets should only be retrieved during a Flow run, not while building a Flow.
My hope is that since I am running on k8s it should just work ™️ and no auth will be required - but obvs CI is wanting to know how to authenticate when I register...
Anybody get any ideas here?? Really don't understand why it needs to be able to connect to the cluster when it registers the flows!?
n
Hi @Josh Greenhalgh - can you share a min reproducible example of your code?
j
It looks like your task is running (the error occurs in in the
run
method) which should never be called during registration. Perhaps you're calling run somewhere in your flow script?
upvote 1
j
Yeah defo - so I instantiate in one file
my_job = RunNamespacedJob(body=the_job_sepc)
Then
import my_job
in the flow and then call
my_job.run()
So I should just call
my_job()
?
j
When defining a flow you should never call
run
(as that runs immediately).
my_job()
would be correct, yes.
j
Ahhh - ok! Thanks!