Skip to content

Commit f3a5459

Browse files
committed
Fixes for podman support (#79)
* Fix coco2014 sample ids path * Fixes for podman, #33 * [Automated Commit] Format Codebase * Fixed rgat checkpoint path * Fixed rgat checkpoint path * [Automated Commit] Format Codebase
1 parent cade457 commit f3a5459

File tree

6 files changed

+59
-28
lines changed

6 files changed

+59
-28
lines changed

automation/script/module.py

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -507,28 +507,7 @@ def _run(self, i):
507507
if os.environ.get(key, '') != '' and env.get(key, '') == '':
508508
env[key] = os.environ[key]
509509

510-
# Check path/input/output in input and pass to env
511-
for key in self.input_flags_converted_to_tmp_env:
512-
value = i.get(key, '').strip()
513-
if value != '':
514-
env['CM_TMP_' + key.upper()] = value
515-
516-
for key in self.input_flags_converted_to_env:
517-
value = i.get(
518-
key,
519-
'').strip() if isinstance(
520-
i.get(
521-
key,
522-
''),
523-
str) else i.get(
524-
key,
525-
'')
526-
if value:
527-
env[f"CM_{key.upper()}"] = value
528-
529-
r = update_env_with_values(env)
530-
if r['return'] > 0:
531-
return r
510+
r = self._update_env_from_input(env, i)
532511

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

22952274
return rr
22962275

2276+
##########################################################################
2277+
2278+
def _update_env_from_input(self, env, i):
2279+
# Check path/input/output in input and pass to env
2280+
for key in self.input_flags_converted_to_tmp_env:
2281+
value = i.get(key, '').strip()
2282+
if value != '':
2283+
env['CM_TMP_' + key.upper()] = value
2284+
2285+
for key in self.input_flags_converted_to_env:
2286+
value = i.get(
2287+
key,
2288+
'').strip() if isinstance(
2289+
i.get(
2290+
key,
2291+
''),
2292+
str) else i.get(
2293+
key,
2294+
'')
2295+
if value:
2296+
env[f"CM_{key.upper()}"] = value
2297+
2298+
r = update_env_with_values(env)
2299+
if r['return'] > 0:
2300+
return r
2301+
2302+
return {'return': 0}
2303+
22972304
##########################################################################
22982305
def _fix_cache_paths(self, env):
22992306
cm_repos_path = os.environ.get(

automation/script/module_misc.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2071,6 +2071,14 @@ def docker(i):
20712071
continue
20722072
'''
20732073

2074+
r = script_automation._update_env_from_input(env, i)
2075+
if r['return'] > 0:
2076+
return r
2077+
2078+
# mount outdirname path
2079+
if env.get('CM_OUTDIRNAME', '') != '':
2080+
mounts.append(f"""{env['CM_OUTDIRNAME']}:{env['CM_OUTDIRNAME']}""")
2081+
20742082
# Check if need to update/map/mount inputs and env
20752083
r = process_inputs({'run_cmd_arc': i_run_cmd_arc,
20762084
'docker_settings': docker_settings,
@@ -2409,7 +2417,8 @@ def docker(i):
24092417
print(final_run_cmd)
24102418
print('')
24112419

2412-
docker_recreate_image = 'yes' if not norecreate_docker_image else 'no'
2420+
docker_recreate_image = 'yes' if str(norecreate_docker_image).lower() not in [
2421+
"yes", "true", "1"] else 'no'
24132422

24142423
if i.get('docker_push_image', '') in ['True', True, 'yes']:
24152424
env['CM_DOCKER_PUSH_IMAGE'] = 'yes'

script/get-ml-model-rgat/_cm.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ automation_alias: script
33
automation_uid: 5b4e0237da074764
44
cache: true
55
category: AI/ML models
6+
docker:
7+
fake_run_deps: True
68
env:
79
CM_ML_MODEL: RGAT
810
CM_ML_MODEL_DATASET: ICBH
911
input_mapping:
1012
checkpoint: RGAT_CHECKPOINT_PATH
11-
download_path: CM_DOWNLOAD_PATH
12-
to: CM_DOWNLOAD_PATH
1313
new_env_keys:
1414
- CM_ML_MODEL_*
1515
- CM_ML_MODEL_RGAT_CHECKPOINT_PATH

script/get-ml-model-rgat/customize.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,17 @@ def preprocess(i):
77
os_info = i['os_info']
88
env = i['env']
99

10+
download_dir = env.get('CM_OUTDIRNAME', '')
11+
1012
path = env.get('RGAT_CHECKPOINT_PATH', '').strip()
1113

1214
if path == '' or not os.path.exists(path):
13-
env['CM_TMP_REQUIRE_DOWNLOAD'] = 'yes'
15+
if download_dir != '' and os.path.exists(
16+
os.path.join(download_dir, "RGAT", "RGAT.pt")):
17+
env['RGAT_CHECKPOINT_PATH'] = os.path.join(
18+
download_dir, "RGAT", "RGAT.pt")
19+
else:
20+
env['CM_TMP_REQUIRE_DOWNLOAD'] = 'yes'
1421

1522
return {'return': 0}
1623

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

2027
env = i['env']
2128

29+
if env.get('RGAT_CHECKPOINT_PATH', '') == '':
30+
env['RGAT_CHECKPOINT_PATH'] = os.path.join(
31+
env['RGAT_DIR_PATH'], "RGAT.pt")
32+
2233
if env.get('CM_ML_MODEL_RGAT_CHECKPOINT_PATH', '') == '':
23-
env['CM_ML_MODEL_RGAT_CHECKPOINT_PATH'] = env.get(
24-
'RGAT_CHECKPOINT_PATH', os.path.join(env['RGAT_DIR_PATH'], "RGAT.pt"))
34+
env['CM_ML_MODEL_RGAT_CHECKPOINT_PATH'] = env['RGAT_CHECKPOINT_PATH']
2535

2636
if env.get('CM_ML_MODEL_PATH', '') == '':
2737
env['CM_ML_MODEL_PATH'] = env['CM_ML_MODEL_RGAT_CHECKPOINT_PATH']

script/run-docker-container/_cm.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,4 @@ prehook_deps:
6868
CM_DOCKER_CONTAINER_ID:
6969
- on
7070
tags: build,docker,image
71+
- tags: get,docker

script/run-docker-container/customize.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ def postprocess(i):
167167
if env.get('CM_DOCKER_EXTRA_RUN_ARGS', '') != '':
168168
run_opts += env['CM_DOCKER_EXTRA_RUN_ARGS']
169169

170+
if env.get('CM_CONTAINER_TOOL', '') == 'podman' and env.get(
171+
'CM_PODMAN_MAP_USER_ID', '').lower() not in ["no", "0", "false"]:
172+
run_opts += " --userns=keep-id"
173+
170174
if env.get('CM_DOCKER_PORT_MAPS', []):
171175
for ports in env['CM_DOCKER_PORT_MAPS']:
172176
port_map_cmds.append(ports)

0 commit comments

Comments
 (0)