mirror of
https://github.com/clearml/clearml
synced 2025-06-26 18:16:07 +00:00
Clean up code
This commit is contained in:
parent
28deda0f3d
commit
3616265bc5
@ -1659,7 +1659,6 @@ class PipelineController(object):
|
|||||||
pipeline_controller.set_user_properties(version=version or cls._default_pipeline_version)
|
pipeline_controller.set_user_properties(version=version or cls._default_pipeline_version)
|
||||||
if add_run_number:
|
if add_run_number:
|
||||||
cls._add_pipeline_name_run_number(pipeline_controller)
|
cls._add_pipeline_name_run_number(pipeline_controller)
|
||||||
print(pipeline_controller.get_output_log_web_page())
|
|
||||||
return cls._create_pipeline_controller_from_task(pipeline_controller)
|
return cls._create_pipeline_controller_from_task(pipeline_controller)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -699,7 +699,7 @@ if __name__ == '__main__':
|
|||||||
kwargs = {function_kwargs}
|
kwargs = {function_kwargs}
|
||||||
task.connect(kwargs, name='{kwargs_section}')
|
task.connect(kwargs, name='{kwargs_section}')
|
||||||
function_input_artifacts = {function_input_artifacts}
|
function_input_artifacts = {function_input_artifacts}
|
||||||
params = task.get_parameters() or dict()
|
params = task.get_parameters(cast=True) or dict()
|
||||||
argspec = inspect.getfullargspec({function_name})
|
argspec = inspect.getfullargspec({function_name})
|
||||||
if argspec.varkw is not None or argspec.varargs is not None:
|
if argspec.varkw is not None or argspec.varargs is not None:
|
||||||
for k, v in params.items():
|
for k, v in params.items():
|
||||||
|
@ -1958,7 +1958,7 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
|
|||||||
"""
|
"""
|
||||||
Set the current Task's tags. Please note this will overwrite anything that is there already.
|
Set the current Task's tags. Please note this will overwrite anything that is there already.
|
||||||
|
|
||||||
:param Sequence(str) tags: object sequence of tags to set.
|
:param Sequence(str) tags: Any sequence of tags to set.
|
||||||
"""
|
"""
|
||||||
assert isinstance(tags, (list, tuple))
|
assert isinstance(tags, (list, tuple))
|
||||||
if not Session.check_min_api_version("2.3"):
|
if not Session.check_min_api_version("2.3"):
|
||||||
|
@ -234,6 +234,12 @@ def cli() -> None:
|
|||||||
if args.script and args.script.endswith(".sh") and not args.binary:
|
if args.script and args.script.endswith(".sh") and not args.binary:
|
||||||
print("Detected shell script. Binary will be set to '/bin/bash'")
|
print("Detected shell script. Binary will be set to '/bin/bash'")
|
||||||
if args.pipeline:
|
if args.pipeline:
|
||||||
|
argparse_args = []
|
||||||
|
for arg in args.args:
|
||||||
|
arg_split = arg.split("=")
|
||||||
|
if len(arg_split) != 2:
|
||||||
|
raise ValueError("Invalid argument: {}. Format should be key=value".format(arg))
|
||||||
|
argparse_args.append(arg_split)
|
||||||
pipeline = PipelineController.create(
|
pipeline = PipelineController.create(
|
||||||
project_name=args.project,
|
project_name=args.project,
|
||||||
task_name=args.name,
|
task_name=args.name,
|
||||||
@ -250,11 +256,12 @@ def cli() -> None:
|
|||||||
docker_bash_setup_script=bash_setup_script,
|
docker_bash_setup_script=bash_setup_script,
|
||||||
version=args.pipeline_version,
|
version=args.pipeline_version,
|
||||||
add_run_number=False if args.pipeline_dont_add_run_number else True,
|
add_run_number=False if args.pipeline_dont_add_run_number else True,
|
||||||
binary=args.binary
|
binary=args.binary,
|
||||||
|
argparse_args=argparse_args
|
||||||
)
|
)
|
||||||
created_task = pipeline._task
|
created_task = pipeline._task
|
||||||
else:
|
else:
|
||||||
created_task = CreateAndPopulate(
|
create_and_populate = CreateAndPopulate(
|
||||||
project_name=args.project,
|
project_name=args.project,
|
||||||
task_name=args.name,
|
task_name=args.name,
|
||||||
task_type=args.task_type,
|
task_type=args.task_type,
|
||||||
@ -277,30 +284,31 @@ def cli() -> None:
|
|||||||
binary=args.binary
|
binary=args.binary
|
||||||
)
|
)
|
||||||
# verify args before creating the Task
|
# verify args before creating the Task
|
||||||
created_task.update_task_args(args.args)
|
create_and_populate.update_task_args(args.args)
|
||||||
print("Creating new task")
|
print("Creating new task")
|
||||||
created_task.create_task()
|
create_and_populate.create_task()
|
||||||
# update Task args
|
# update Task args
|
||||||
created_task.update_task_args(args.args)
|
create_and_populate.update_task_args(args.args)
|
||||||
|
created_task = create_and_populate.task
|
||||||
# set tags
|
# set tags
|
||||||
if args.tags:
|
if args.tags:
|
||||||
created_task.task.add_tags(args.tags)
|
created_task.add_tags(args.tags)
|
||||||
|
|
||||||
# noinspection PyProtectedMember
|
# noinspection PyProtectedMember
|
||||||
created_task.task._set_runtime_properties({"_CLEARML_TASK": True})
|
created_task._set_runtime_properties({"_CLEARML_TASK": True})
|
||||||
|
|
||||||
print("New {} created id={}".format("pipeline" if args.pipeline else "task", created_task.get_id()))
|
print("New {} created id={}".format("pipeline" if args.pipeline else "task", created_task.id))
|
||||||
if not args.queue:
|
if not args.queue:
|
||||||
print("Warning: No queue was provided, leaving {} in draft-mode.", "pipeline" if args.pipeline else "task")
|
print("Warning: No queue was provided, leaving {} in draft-mode.", "pipeline" if args.pipeline else "task")
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
Task.enqueue(created_task.task, queue_name=args.queue)
|
Task.enqueue(created_task, queue_name=args.queue)
|
||||||
print(
|
print(
|
||||||
"{} id={} sent for execution on queue {}".format(
|
"{} id={} sent for execution on queue {}".format(
|
||||||
"Pipeline" if args.pipeline else "task", created_task.get_id(), args.queue
|
"Pipeline" if args.pipeline else "task", created_task.id, args.queue
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
print("Execution log at: {}".format(created_task.task.get_output_log_web_page()))
|
print("Execution log at: {}".format(created_task.get_output_log_web_page()))
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
|
@ -1480,7 +1480,7 @@ class Task(_Task):
|
|||||||
- ``user`` - List[str] Filter based on Task's user owner, provide list of valid user IDs.
|
- ``user`` - List[str] Filter based on Task's user owner, provide list of valid user IDs.
|
||||||
- ``order_by`` - List[str] List of field names to order by. When ``search_text`` is used. Use '-' prefix to specify descending order. Optional, recommended when using page. Example: ``order_by=['-last_update']``
|
- ``order_by`` - List[str] List of field names to order by. When ``search_text`` is used. Use '-' prefix to specify descending order. Optional, recommended when using page. Example: ``order_by=['-last_update']``
|
||||||
- ``_all_`` - dict(fields=[], pattern='') Match string `pattern` (regular expression) appearing in All `fields`. Example: dict(fields=['script.repository'], pattern='github.com/user')
|
- ``_all_`` - dict(fields=[], pattern='') Match string `pattern` (regular expression) appearing in All `fields`. Example: dict(fields=['script.repository'], pattern='github.com/user')
|
||||||
- ``_any_`` - dict(fields=[], pattern='') Match string `pattern` (regular expression) appearing in object of the `fields`. Example: dict(fields=['comment', 'name'], pattern='my comment')
|
- ``_any_`` - dict(fields=[], pattern='') Match string `pattern` (regular expression) appearing in any of the `fields`. Example: dict(fields=['comment', 'name'], pattern='my comment')
|
||||||
- Examples - ``{'status': ['stopped'], 'order_by': ["-last_update"]}`` , ``{'order_by'=['-last_update'], '_all_'=dict(fields=['script.repository'], pattern='github.com/user'))``
|
- Examples - ``{'status': ['stopped'], 'order_by': ["-last_update"]}`` , ``{'order_by'=['-last_update'], '_all_'=dict(fields=['script.repository'], pattern='github.com/user'))``
|
||||||
|
|
||||||
:return: The Tasks specified by the parameter combinations (see the parameters).
|
:return: The Tasks specified by the parameter combinations (see the parameters).
|
||||||
|
Loading…
Reference in New Issue
Block a user