Skip to content

Fixes for podman support #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 29 additions & 22 deletions automation/script/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,28 +507,7 @@ def _run(self, i):
if os.environ.get(key, '') != '' and env.get(key, '') == '':
env[key] = os.environ[key]

# Check path/input/output in input and pass to env
for key in self.input_flags_converted_to_tmp_env:
value = i.get(key, '').strip()
if value != '':
env['CM_TMP_' + key.upper()] = value

for key in self.input_flags_converted_to_env:
value = i.get(
key,
'').strip() if isinstance(
i.get(
key,
''),
str) else i.get(
key,
'')
if value:
env[f"CM_{key.upper()}"] = value

r = update_env_with_values(env)
if r['return'] > 0:
return r
r = self._update_env_from_input(env, i)

#######################################################################
# Check if we want to skip cache (either by skip_cache or by fake_run)
Expand Down Expand Up @@ -2294,6 +2273,34 @@ def _run(self, i):

return rr

##########################################################################

def _update_env_from_input(self, env, i):
# Check path/input/output in input and pass to env
for key in self.input_flags_converted_to_tmp_env:
value = i.get(key, '').strip()
if value != '':
env['CM_TMP_' + key.upper()] = value

for key in self.input_flags_converted_to_env:
value = i.get(
key,
'').strip() if isinstance(
i.get(
key,
''),
str) else i.get(
key,
'')
if value:
env[f"CM_{key.upper()}"] = value

r = update_env_with_values(env)
if r['return'] > 0:
return r

return {'return': 0}

##########################################################################
def _fix_cache_paths(self, env):
cm_repos_path = os.environ.get(
Expand Down
11 changes: 10 additions & 1 deletion automation/script/module_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2071,6 +2071,14 @@ def docker(i):
continue
'''

r = script_automation._update_env_from_input(env, i)
if r['return'] > 0:
return r

# mount outdirname path
if env.get('CM_OUTDIRNAME', '') != '':
mounts.append(f"""{env['CM_OUTDIRNAME']}:{env['CM_OUTDIRNAME']}""")

# Check if need to update/map/mount inputs and env
r = process_inputs({'run_cmd_arc': i_run_cmd_arc,
'docker_settings': docker_settings,
Expand Down Expand Up @@ -2409,7 +2417,8 @@ def docker(i):
print(final_run_cmd)
print('')

docker_recreate_image = 'yes' if not norecreate_docker_image else 'no'
docker_recreate_image = 'yes' if str(norecreate_docker_image).lower() not in [
"yes", "true", "1"] else 'no'

if i.get('docker_push_image', '') in ['True', True, 'yes']:
env['CM_DOCKER_PUSH_IMAGE'] = 'yes'
Expand Down
4 changes: 2 additions & 2 deletions script/get-ml-model-rgat/_cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ automation_alias: script
automation_uid: 5b4e0237da074764
cache: true
category: AI/ML models
docker:
fake_run_deps: True
env:
CM_ML_MODEL: RGAT
CM_ML_MODEL_DATASET: ICBH
input_mapping:
checkpoint: RGAT_CHECKPOINT_PATH
download_path: CM_DOWNLOAD_PATH
to: CM_DOWNLOAD_PATH
new_env_keys:
- CM_ML_MODEL_*
- CM_ML_MODEL_RGAT_CHECKPOINT_PATH
Expand Down
16 changes: 13 additions & 3 deletions script/get-ml-model-rgat/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@ def preprocess(i):
os_info = i['os_info']
env = i['env']

download_dir = env.get('CM_OUTDIRNAME', '')

path = env.get('RGAT_CHECKPOINT_PATH', '').strip()

if path == '' or not os.path.exists(path):
env['CM_TMP_REQUIRE_DOWNLOAD'] = 'yes'
if download_dir != '' and os.path.exists(
os.path.join(download_dir, "RGAT", "RGAT.pt")):
env['RGAT_CHECKPOINT_PATH'] = os.path.join(
download_dir, "RGAT", "RGAT.pt")
else:
env['CM_TMP_REQUIRE_DOWNLOAD'] = 'yes'

return {'return': 0}

Expand All @@ -19,9 +26,12 @@ def postprocess(i):

env = i['env']

if env.get('RGAT_CHECKPOINT_PATH', '') == '':
env['RGAT_CHECKPOINT_PATH'] = os.path.join(
env['RGAT_DIR_PATH'], "RGAT.pt")

if env.get('CM_ML_MODEL_RGAT_CHECKPOINT_PATH', '') == '':
env['CM_ML_MODEL_RGAT_CHECKPOINT_PATH'] = env.get(
'RGAT_CHECKPOINT_PATH', os.path.join(env['RGAT_DIR_PATH'], "RGAT.pt"))
env['CM_ML_MODEL_RGAT_CHECKPOINT_PATH'] = env['RGAT_CHECKPOINT_PATH']

if env.get('CM_ML_MODEL_PATH', '') == '':
env['CM_ML_MODEL_PATH'] = env['CM_ML_MODEL_RGAT_CHECKPOINT_PATH']
Expand Down
1 change: 1 addition & 0 deletions script/run-docker-container/_cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,4 @@ prehook_deps:
CM_DOCKER_CONTAINER_ID:
- on
tags: build,docker,image
- tags: get,docker
4 changes: 4 additions & 0 deletions script/run-docker-container/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ def postprocess(i):
if env.get('CM_DOCKER_EXTRA_RUN_ARGS', '') != '':
run_opts += env['CM_DOCKER_EXTRA_RUN_ARGS']

if env.get('CM_CONTAINER_TOOL', '') == 'podman' and env.get(
'CM_PODMAN_MAP_USER_ID', '').lower() not in ["no", "0", "false"]:
run_opts += " --userns=keep-id"

if env.get('CM_DOCKER_PORT_MAPS', []):
for ports in env['CM_DOCKER_PORT_MAPS']:
port_map_cmds.append(ports)
Expand Down
Loading