Hi All My CI process is failing health checks whe...
# ask-community
b
Hi All My CI process is failing health checks when building my flow with
prefect build -p
with the following error. Anyone experience this issue?
Copy code
Beginning health checks...
System Version check: OK
Traceback (most recent call last):
  File "/opt/prefect/healthcheck.py", line 150, in <module>
    flows = import_flow_from_script_check(flow_file_paths)
  File "/opt/prefect/healthcheck.py", line 63, in import_flow_from_script_check
    flows.append(extract_flow_from_file(file_path=flow_file_path))
  File "/usr/local/lib/python3.8/site-packages/prefect/utilities/storage.py", line 86, in extract_flow_from_file
    exec(contents, exec_vals)
  File "<string>", line 129, in <module>
NameError: name '__file__' is not defined
z
Hey @Belal Aboabdo -- are you referencing
__file__
in your flow script?
b
Yes I am
z
It looks like we're not providing a value for that during load from storage because the flow no longer has a real "file" location -- what are you using it for? (your use-case may justify adding a fake value here)
b
Makes sense we're using it to manage our flow configuration here's a snippet:
Copy code
if __name__ == "__main__":

    flow_params = dict(file_path=os.path.abspath(__file__))

    FlowManager(flow, flow_params).do(entry_point())
z
Hm. What are you using for flow storage here?
(ie
flow.storage
)
b
We're using Docker storage with aws ecr.
z
I'm trying to reproduce this but the
__name__
should not be
__main__
when that flow is loaded
Do you use
__file__
else where in your flow code?
b
No not within the flow itself.
z
Would it be feasible to DM me your flow script in entirety?
Copy code
from prefect import Flow
from prefect.storage import Docker as DockerStorage 


with Flow("test") as flow:
   pass


flow.storage = DockerStorage(base_image="prefecthq/prefect:0.14.7")

if __name__ == "__main__":

     print(__file__)
works fine with
prefect build -p
b
Sorry I can't share the script but I can try replicating the issue with the snippet you just sent.
z
That'd be great! A minimal example would be really helpful
b
Sorry for the confusion I believe I found the flow that's causing the issue here:
Copy code
with Flow(
    flow_name,
    **get_configs(
        file_path=os.path.abspath(__file__), flow_name=flow_name, schedule=sched
    ),
) as flow:
j
I had a similar issue here. Not the exact same (wrong
__file__
value rather than
NameError
), but maybe this also has to do with how/if the flows are pickled?
z
Yeah I'm not sure this is an unexpected issue. Using
__file__
in your flow declaration like that is a brittle case for us to handle. I'll open an issue to look into it further nonetheless.
@Marvin open "Docker storage healthcheck fails when using
__file__
in flow"
b
Thanks for all the help everyone!