mirror of
https://github.com/clearml/clearml-agent
synced 2025-03-03 18:52:22 +00:00
Fix docker container backwards compatibility for API <2.13
Fix default docker match rules resolver (used incorrect field "container" instead of "image") Remove "container" (image) match rule option from default docker image resolver
This commit is contained in:
parent
a535f93cd6
commit
3ed63e2154
@ -388,13 +388,6 @@
|
|||||||
# }
|
# }
|
||||||
# },
|
# },
|
||||||
# {
|
# {
|
||||||
# "image": "better_container:tag",
|
|
||||||
# "arguments": "",
|
|
||||||
# "match": {
|
|
||||||
# "container": "replace_me_please"
|
|
||||||
# }
|
|
||||||
# },
|
|
||||||
# {
|
|
||||||
# "image": "another_container:tag",
|
# "image": "another_container:tag",
|
||||||
# "arguments": "",
|
# "arguments": "",
|
||||||
# "match": {
|
# "match": {
|
||||||
|
@ -109,15 +109,15 @@ def resolve_default_container(session, task_id, container_config):
|
|||||||
match.get('script.binary', None), entry))
|
match.get('script.binary', None), entry))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if match.get('container', None):
|
# if match.get('image', None):
|
||||||
# noinspection PyBroadException
|
# # noinspection PyBroadException
|
||||||
try:
|
# try:
|
||||||
if not re.search(match.get('container', None), requested_container.get('image', '')):
|
# if not re.search(match.get('image', None), requested_container.get('image', '')):
|
||||||
continue
|
# continue
|
||||||
except Exception:
|
# except Exception:
|
||||||
print('Failed parsing regular expression \"{}\" in rule: {}'.format(
|
# print('Failed parsing regular expression \"{}\" in rule: {}'.format(
|
||||||
match.get('container', None), entry))
|
# match.get('image', None), entry))
|
||||||
continue
|
# continue
|
||||||
|
|
||||||
matched = True
|
matched = True
|
||||||
for req_section in ['script.requirements.pip', 'script.requirements.conda']:
|
for req_section in ['script.requirements.pip', 'script.requirements.conda']:
|
||||||
@ -156,8 +156,8 @@ def resolve_default_container(session, task_id, container_config):
|
|||||||
break
|
break
|
||||||
|
|
||||||
if matched:
|
if matched:
|
||||||
if not container_config.get('container'):
|
if not container_config.get('image'):
|
||||||
container_config['container'] = entry.get('image', None)
|
container_config['image'] = entry.get('image', None)
|
||||||
if not container_config.get('arguments'):
|
if not container_config.get('arguments'):
|
||||||
container_config['arguments'] = entry.get('arguments', None)
|
container_config['arguments'] = entry.get('arguments', None)
|
||||||
container_config['arguments'] = shlex.split(str(container_config.get('arguments') or '').strip())
|
container_config['arguments'] = shlex.split(str(container_config.get('arguments') or '').strip())
|
||||||
|
@ -372,16 +372,19 @@ def get_task_container(session, task_id):
|
|||||||
container = {}
|
container = {}
|
||||||
else:
|
else:
|
||||||
response = get_task(session, task_id, only_fields=["execution.docker_cmd"])
|
response = get_task(session, task_id, only_fields=["execution.docker_cmd"])
|
||||||
|
container = {}
|
||||||
|
if response.execution:
|
||||||
task_docker_cmd_parts = shlex.split(str(response.execution.docker_cmd or '').strip())
|
task_docker_cmd_parts = shlex.split(str(response.execution.docker_cmd or '').strip())
|
||||||
|
if task_docker_cmd_parts:
|
||||||
try:
|
try:
|
||||||
container = dict(
|
container = dict(
|
||||||
container=task_docker_cmd_parts[0],
|
image=task_docker_cmd_parts[0],
|
||||||
arguments=task_docker_cmd_parts[1:] if len(task_docker_cmd_parts[0]) > 1 else ''
|
arguments=task_docker_cmd_parts[1:] if len(task_docker_cmd_parts[0]) > 1 else ''
|
||||||
)
|
)
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
container = {}
|
pass
|
||||||
|
|
||||||
if (not container or not container.get('container')) and session.check_min_api_version("2.13"):
|
if (not container or not container.get('image')) and session.check_min_api_version("2.13"):
|
||||||
container = resolve_default_container(session=session, task_id=task_id, container_config=container)
|
container = resolve_default_container(session=session, task_id=task_id, container_config=container)
|
||||||
|
|
||||||
return container
|
return container
|
||||||
|
@ -242,8 +242,6 @@ agent {
|
|||||||
# # no repository matching required
|
# # no repository matching required
|
||||||
# repository: ""
|
# repository: ""
|
||||||
# }
|
# }
|
||||||
# # no container image matching required (allow to replace one requested container with another)
|
|
||||||
# container: ""
|
|
||||||
# # no repository matching required
|
# # no repository matching required
|
||||||
# project: ""
|
# project: ""
|
||||||
# }
|
# }
|
||||||
|
Loading…
Reference in New Issue
Block a user