Skip to content

Commit

Permalink
fix(import): Fix relative import path error (flyteorg#2397)
Browse files Browse the repository at this point in the history
Signed-off-by: Chi-Sheng Liu <chishengliu@chishengliu.com>
Signed-off-by: Kevin Su <pingsutw@apache.org>
Co-authored-by: Kevin Su <pingsutw@apache.org>
  • Loading branch information
2 people authored and austin362667 committed May 10, 2024
1 parent b8a5aa7 commit 9384413
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions flytekit/clis/sdk_in_container/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,12 +330,11 @@ def get_entities_in_file(filename: pathlib.Path, should_delete: bool) -> Entitie
Returns a list of flyte workflow names and list of Flyte tasks in a file.
"""
flyte_ctx = context_manager.FlyteContextManager.current_context().new_builder()
if filename.is_relative_to("."):
module_name = str(filename.relative_to(".").with_suffix("")).replace(os.path.sep, ".")
if filename.is_relative_to(pathlib.Path.cwd()):
additional_path = str(pathlib.Path.cwd())
else:
module_name = str(filename.stem)
additional_path = str(filename.parent)
additional_path = _find_project_root(filename)
module_name = str(filename.relative_to(additional_path).with_suffix("")).replace(os.path.sep, ".")
with context_manager.FlyteContextManager.with_context(flyte_ctx):
with module_loader.add_sys_path(additional_path):
importlib.import_module(module_name)
Expand Down

0 comments on commit 9384413

Please sign in to comment.