mirror of
https://github.com/clearml/clearml
synced 2025-06-23 01:55:38 +00:00
Add CLEARML_VCS_ENTRY_POINT env var controlling experiment's entry point
Fix CLEARML_VCS_WORK_DIR and CLEARML_VCS_DIFF support for standalone mode
This commit is contained in:
parent
7016138c84
commit
ceb20f1eec
@ -13,7 +13,7 @@ from threading import Thread
|
|||||||
|
|
||||||
from .util import get_command_output, remove_user_pass_from_url
|
from .util import get_command_output, remove_user_pass_from_url
|
||||||
from ....backend_api import Session
|
from ....backend_api import Session
|
||||||
from ....config import deferred_config, VCS_WORK_DIR
|
from ....config import deferred_config, VCS_WORK_DIR, VCS_ENTRY_POINT, VCS_DIFF
|
||||||
from ....debugging import get_logger
|
from ....debugging import get_logger
|
||||||
from .detectors import GitEnvDetector, GitDetector, HgEnvDetector, HgDetector, Result as DetectionResult
|
from .detectors import GitEnvDetector, GitDetector, HgEnvDetector, HgDetector, Result as DetectionResult
|
||||||
from ....utilities.process.mp import SafeEvent
|
from ....utilities.process.mp import SafeEvent
|
||||||
@ -790,6 +790,9 @@ class ScriptInfo(object):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _get_entry_point(cls, repo_root, script_path):
|
def _get_entry_point(cls, repo_root, script_path):
|
||||||
|
if VCS_ENTRY_POINT.get():
|
||||||
|
return VCS_ENTRY_POINT.get()
|
||||||
|
|
||||||
repo_root = Path(repo_root).absolute()
|
repo_root = Path(repo_root).absolute()
|
||||||
script_path = Path(script_path)
|
script_path = Path(script_path)
|
||||||
|
|
||||||
@ -820,6 +823,9 @@ class ScriptInfo(object):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _get_working_dir(cls, repo_root, return_abs=False):
|
def _get_working_dir(cls, repo_root, return_abs=False):
|
||||||
|
if VCS_WORK_DIR.get():
|
||||||
|
return VCS_WORK_DIR.get()
|
||||||
|
|
||||||
# get the repository working directory (might be different from actual cwd)
|
# get the repository working directory (might be different from actual cwd)
|
||||||
repo_root = Path(repo_root).absolute()
|
repo_root = Path(repo_root).absolute()
|
||||||
cwd = cls._cwd()
|
cwd = cls._cwd()
|
||||||
@ -843,6 +849,15 @@ class ScriptInfo(object):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _get_script_code(cls, script_path):
|
def _get_script_code(cls, script_path):
|
||||||
|
# allow to override with env variable
|
||||||
|
# noinspection PyBroadException
|
||||||
|
try:
|
||||||
|
diff = VCS_DIFF.get()
|
||||||
|
if diff:
|
||||||
|
return diff
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
# noinspection PyBroadException
|
# noinspection PyBroadException
|
||||||
try:
|
try:
|
||||||
with open(script_path, 'r') as f:
|
with open(script_path, 'r') as f:
|
||||||
@ -915,13 +930,13 @@ class ScriptInfo(object):
|
|||||||
|
|
||||||
repo_root = repo_info.root or script_dir
|
repo_root = repo_info.root or script_dir
|
||||||
if not plugin:
|
if not plugin:
|
||||||
working_dir = '.'
|
working_dir = VCS_WORK_DIR.get() or '.'
|
||||||
entry_point = str(script_path.name)
|
entry_point = VCS_ENTRY_POINT.get() or str(script_path.name)
|
||||||
else:
|
else:
|
||||||
# allow to override the VCS working directory (notice relative to the git repo)
|
# allow to override the VCS working directory (notice relative to the git repo)
|
||||||
# because we can have a sync folder on remote pycharm sessions
|
# because we can have a sync folder on remote pycharm sessions
|
||||||
# not syncing from the Git repo, but from a subfolder, so the pycharm plugin need to pass the override
|
# not syncing from the Git repo, but from a subfolder, so the pycharm plugin need to pass the override
|
||||||
working_dir = VCS_WORK_DIR.get() if VCS_WORK_DIR.get() else cls._get_working_dir(repo_root)
|
working_dir = cls._get_working_dir(repo_root)
|
||||||
entry_point = cls._get_entry_point(repo_root, script_path)
|
entry_point = cls._get_entry_point(repo_root, script_path)
|
||||||
|
|
||||||
if check_uncommitted:
|
if check_uncommitted:
|
||||||
|
@ -33,5 +33,6 @@ VCS_COMMIT_ID = EnvEntry("CLEARML_VCS_COMMIT_ID", "TRAINS_VCS_COMMIT_ID")
|
|||||||
VCS_BRANCH = EnvEntry("CLEARML_VCS_BRANCH", "TRAINS_VCS_BRANCH")
|
VCS_BRANCH = EnvEntry("CLEARML_VCS_BRANCH", "TRAINS_VCS_BRANCH")
|
||||||
VCS_ROOT = EnvEntry("CLEARML_VCS_ROOT", "TRAINS_VCS_ROOT")
|
VCS_ROOT = EnvEntry("CLEARML_VCS_ROOT", "TRAINS_VCS_ROOT")
|
||||||
VCS_WORK_DIR = EnvEntry("CLEARML_VCS_WORK_DIR")
|
VCS_WORK_DIR = EnvEntry("CLEARML_VCS_WORK_DIR")
|
||||||
|
VCS_ENTRY_POINT = EnvEntry("CLEARML_VCS_ENTRY_POINT")
|
||||||
VCS_STATUS = EnvEntry("CLEARML_VCS_STATUS", "TRAINS_VCS_STATUS", converter=base64_to_text)
|
VCS_STATUS = EnvEntry("CLEARML_VCS_STATUS", "TRAINS_VCS_STATUS", converter=base64_to_text)
|
||||||
VCS_DIFF = EnvEntry("CLEARML_VCS_DIFF", "TRAINS_VCS_DIFF", converter=base64_to_text)
|
VCS_DIFF = EnvEntry("CLEARML_VCS_DIFF", "TRAINS_VCS_DIFF", converter=base64_to_text)
|
||||||
|
Loading…
Reference in New Issue
Block a user