mirror of
https://github.com/clearml/clearml
synced 2025-03-03 10:42:00 +00:00
Fix support for auto package detection for standalone scripts
This commit is contained in:
parent
d19fde7041
commit
15683b5b43
@ -76,7 +76,6 @@ class ScriptRequirements(object):
|
||||
modules = ImportedModules()
|
||||
try_imports = set()
|
||||
local_mods = list()
|
||||
cur_dir = project_path # os.getcwd()
|
||||
ignore_paths = collections.defaultdict(set)
|
||||
if not ignores:
|
||||
ignore_paths[project_path].add('.git')
|
||||
@ -85,6 +84,14 @@ class ScriptRequirements(object):
|
||||
parent_dir = os.path.dirname(path)
|
||||
ignore_paths[parent_dir].add(os.path.basename(path))
|
||||
|
||||
if os.path.isfile(project_path):
|
||||
fake_path = Path(project_path).name
|
||||
with open(project_path, 'rb') as f:
|
||||
fmodules, try_ipts = file_import_modules(fake_path, f.read())
|
||||
modules |= fmodules
|
||||
try_imports |= try_ipts
|
||||
else:
|
||||
cur_dir = project_path # os.getcwd()
|
||||
for dirpath, dirnames, files in os.walk(project_path, followlinks=True):
|
||||
if dirpath in ignore_paths:
|
||||
dirnames[:] = [d for d in dirnames
|
||||
@ -457,7 +464,8 @@ class ScriptInfo(object):
|
||||
# create requirements if backend supports requirements
|
||||
# if jupyter is present, requirements will be created in the background, when saving a snapshot
|
||||
if not jupyter_filepath and Session.check_min_api_version('2.2'):
|
||||
script_requirements = ScriptRequirements(Path(repo_root).as_posix())
|
||||
script_requirements = ScriptRequirements(
|
||||
Path(repo_root).as_posix() if repo_info.url else script_path.as_posix())
|
||||
if create_requirements:
|
||||
requirements = script_requirements.get_requirements()
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user