MCPcopy Create free account
hub / github.com/It4innovations/hyperqueue / parse_exec_line

Function parse_exec_line

tests/autoalloc/test_autoalloc.py:428–454  ·  view source on GitHub ↗

`script_path` should be a path to qsub or sbatch submit script.

(script_path: str)

Source from the content-addressed store, hash-verified

426
427
428def parse_exec_line(script_path: str) -> WorkerExecLine:
429 """
430 `script_path` should be a path to qsub or sbatch submit script.
431 """
432 line = get_exec_line(script_path)
433
434 def get_env(item: str) -> Optional[Tuple[str, str]]:
435 if "=" in item:
436 key, value = item.split("=", maxsplit=1)
437 if key.isupper():
438 return (key, value)
439 return None
440
441 env = {}
442 cmd = None
443 items = line.split(" ")
444 for index, item in enumerate(items):
445 env_item = get_env(item)
446 if env_item is not None:
447 assert env_item[0] not in env
448 env[env_item[0]] = env_item[1]
449 else:
450 cmd = " ".join(items[index:])
451 break
452
453 assert cmd is not None
454 return WorkerExecLine(cmd=cmd, env=env)
455
456
457@all_flavors

Calls 4

get_exec_lineFunction · 0.85
get_envFunction · 0.85
WorkerExecLineClass · 0.85
splitMethod · 0.45

Tested by

no test coverage detected