Skip to content

Commit

Permalink
safe removal
Browse files Browse the repository at this point in the history
  • Loading branch information
madhur-ob committed Dec 17, 2024
1 parent 0676c05 commit ec43bc6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions metaflow/runner/click_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,14 @@ def extract_flow_class_from_file(flow_file: str) -> FlowSpec:

return flow_cls
finally:
# Remove the flow directory from sys.path
sys.path.remove(flow_dir)
# Safely remove the flow directory from sys.path if it exists
try:
# Remove the flow directory from sys.path
sys.path.remove(flow_dir)
except ValueError:
# The path might have been modified during module loading,
# so we silently ignore if flow_dir is no longer in sys.path
pass


class MetaflowAPI(object):
Expand Down

0 comments on commit ec43bc6

Please sign in to comment.