def test_passing_params_to_no_io_overrides_polyaxonfiles_raises(self): with self.assertRaises(PolyaxonfileError): check_polyaxonfile( polyaxonfile=os.path.abspath("tests/fixtures/plain/simple_job.yml"), params={"flag": True, "loss": "some-loss"}, is_cli=False, )
def test_passing_wrong_params_raises(self): with self.assertRaises(PolyaxonfileError): check_polyaxonfile( polyaxonfile=os.path.abspath("tests/fixtures/plain/simple_job.yml"), params="foo", is_cli=False, )
def test_missing_kind_raises(self): with self.assertRaises(PolyaxonfileError): check_polyaxonfile( polyaxonfile=os.path.abspath( "tests/fixtures/plain/missing_kind.yml"), is_cli=False, )
def test_non_existing_raises(self): with self.assertRaises(PolyaxonfileError): check_polyaxonfile( polyaxonfile=os.path.abspath( "tests/fixtures/plain/non_existing_file.yml"), is_cli=False, )
def test_using_untyped_params_raises(self): with self.assertRaises(PolyaxonfileError): check_polyaxonfile( polyaxonfile=os.path.abspath( "tests/fixtures/typing/untyped_params.yml"), is_cli=False, )
def test_matrix_file_with_required_inputs_and_wrong_matrix_type_fails(self): with self.assertRaises(PolyaxonfileError): check_polyaxonfile( polyaxonfile=os.path.abspath( "tests/fixtures/typing/matrix_job_required_inputs_file_wrong_matrix_type.yml" ), is_cli=False, )
def test_from_hub(self): operation = check_polyaxonfile(hub="component:12", is_cli=False, to_op=True) assert operation.version == pkg.SCHEMA_VERSION assert operation.kind == "operation" assert operation.hub_ref == "component:12"
def test_matrix_early_stopping_file_passes(self): plx_file = check_polyaxonfile( polyaxonfile=os.path.abspath( "tests/fixtures/plain/matrix_job_file_early_stopping.yml"), is_cli=False, to_op=False, ) # Get compiled_operation data run_config = OperationSpecification.compile_operation(plx_file) run_config = CompiledOperationSpecification.apply_context(run_config) assert run_config.version == 1.05 assert isinstance(run_config.parallel, V1RandomSearch) assert isinstance(run_config.parallel.params["lr"], V1HpLinSpace) assert isinstance(run_config.parallel.params["loss"], V1HpChoice) assert run_config.parallel.params["lr"].to_dict() == { "kind": "linspace", "value": { "start": 0.01, "stop": 0.1, "num": 5 }, } assert run_config.parallel.params["loss"].to_dict() == { "kind": "choice", "value": ["MeanSquaredError", "AbsoluteDifference"], } assert run_config.parallel.concurrency == 2 assert run_config.parallel.num_runs == 300 assert isinstance(run_config.parallel, V1RandomSearch) assert run_config.parallel.kind == V1RandomSearch.IDENTIFIER assert len(run_config.parallel.early_stopping) == 1 assert isinstance(run_config.parallel.early_stopping[0], V1MetricEarlyStopping)
def create_from_url( self, url: str, name: str = None, description: str = None, tags: Union[str, Sequence[str]] = None, params: Dict = None, presets: List[str] = None, queue: str = None, nocache: bool = None, cache: bool = None, ) -> V1Run: """Creates a new run from a url containing a Polyaxonfile specification. N.B. Create methods are only useful if you want to create a run programmatically, if you run a component/operation from the CLI/UI an instance will be created automatically. [Run API](/docs/api/#operation/CreateRun) Args: url: str, url containing a YAML/Json specification. The url's polyaxonfile should contain a [V1Component](/docs/core/specification/component/) or an [V1Operation](/docs/core/specification/operation/). name: str, optional, it will override the name in the operation if provided. description: str, optional, it will override the description in the operation if provided. tags: str or List[str], optional, list of tags, it will override the tags in the operation if provided. params: dict, optional, a dictionary of parameters that will be used to resolve the component's inputs/outputs. presets: List[str], optional, the name of the [presets](/docs/core/introduction/concepts/#preset). queue: str, optional, the name of the [queue](/docs/core/scheduling-strategies/queue-routing/) to assign the run to. nocache: bool, optional, simple flag to disable [cache check](/docs/automation/helpers/cache/). If passed and the Polyaxonfile has cache section, it will be patched with `disabled: true`. cache: bool, optional, simple flag to enable [cache check](/docs/automation/helpers/cache/). If passed and the Polyaxonfile has cache section, it will be patched with `disabled: false`. Returns: V1Run, run instance from the response. """ op_spec = check_polyaxonfile( url=url, params=params, presets=presets, queue=queue, nocache=nocache, cache=cache, verbose=False, ) return self.create(name=name, description=description, tags=tags, content=op_spec)
def test_mapping_early_stopping_file_passes(self): plx_file = check_polyaxonfile( polyaxonfile=os.path.abspath( "tests/fixtures/plain/mapping_job_file_early_stopping.yml"), is_cli=False, to_op=False, ) # Get compiled_operation data config_run = OperationSpecification.compile_operation(plx_file) config_run = CompiledOperationSpecification.apply_context(config_run) assert config_run.version == 1.05 assert isinstance(config_run.parallel, V1Mapping) assert config_run.parallel.values == [ { "lr": 0.001, "loss": "MeanSquaredError" }, { "lr": 0.1, "loss": "AbsoluteDifference" }, ] assert config_run.parallel.concurrency == 2 assert isinstance(config_run.parallel, V1Mapping) assert config_run.parallel.kind == V1Mapping.IDENTIFIER assert len(config_run.parallel.early_stopping) == 1 assert isinstance(config_run.parallel.early_stopping[0], V1MetricEarlyStopping)
def test_matrix_file_passes_int_float_types(self): plx_file = check_polyaxonfile( polyaxonfile=os.path.abspath( "tests/fixtures/plain/matrix_job_file_with_int_float_types.yml" ), is_cli=False, ) # Get compiled_operation data run_config = OperationSpecification.compile_operation(plx_file) run_config = CompiledOperationSpecification.apply_context(run_config) assert run_config.version == 1.05 assert isinstance(run_config.parallel, V1GridSearch) assert isinstance(run_config.parallel.params["param1"], V1HpChoice) assert isinstance(run_config.parallel.params["param2"], V1HpChoice) assert run_config.parallel.params["param1"].to_dict() == { "kind": "choice", "value": [1, 2], } assert run_config.parallel.params["param2"].to_dict() == { "kind": "choice", "value": [3.3, 4.4], } assert run_config.parallel.concurrency == 2 assert isinstance(run_config.parallel, V1GridSearch) assert run_config.parallel.kind == V1GridSearch.IDENTIFIER assert run_config.parallel.early_stopping is None
def test_matrix_file_with_required_inputs_passes(self): plx_file = check_polyaxonfile( polyaxonfile=os.path.abspath( "tests/fixtures/typing/matrix_job_required_inputs_file.yml"), is_cli=False, ) run_config = OperationSpecification.compile_operation(plx_file) run_config = CompiledOperationSpecification.apply_context(run_config) assert run_config.version == 1.1 assert isinstance(run_config.matrix, V1Hyperband) assert isinstance(run_config.matrix.params["lr"], V1HpLinSpace) assert isinstance(run_config.matrix.params["loss"], V1HpChoice) assert run_config.matrix.params["lr"].to_dict() == { "kind": "linspace", "value": { "start": 0.01, "stop": 0.1, "num": 5 }, } assert run_config.matrix.params["loss"].to_dict() == { "kind": "choice", "value": ["MeanSquaredError", "AbsoluteDifference"], } assert run_config.matrix.concurrency == 2 assert isinstance(run_config.matrix, V1Hyperband) assert run_config.matrix.kind == V1Hyperband.IDENTIFIER assert run_config.matrix.early_stopping is None
def create_from_hub( self, component: str, name: str = None, description: str = None, tags: Union[str, Sequence[str]] = None, params: Dict = None, profile: str = None, queue: str = None, nocache: bool = True, ): """Creates a new run from the hub based on the component name. N.B. Create methods are only useful if you want to create a run programmatically, if you run a component/operation from the CLI/UI an instance will be created automatically. By default the hub hosts components. If the component has required inputs, you should pass the params. [Run API](/docs/api/#operation/CreateRun) Args: component: str, name of the hub component. name: str, optional, it will override the name in the component if provided. description: str, optional, it will override the description in the component if provided. tags: str or List[str], optional, list of tags, it will override the tags in the component if provided. params: dict, optional, a dictionary of parameters that will be used to resolve the component's inputs/outputs. profile: str, optional, the name of the [run profile](/docs/core/introduction/concepts/#run-profile). queue: str, optional, the name of the [queue](/docs/core/scheduling-strategies/queue-routing/) to assign the run to. nocache: bool, optional, to disable [cache check](/docs/automation/helpers/cache/). If passed and the Polyaxonfile has cache section, it will be patched with `disabled: true`. Returns: V1Run, run instance from the response. """ op_spec = check_polyaxonfile( hub=component, params=params, profile=profile, queue=queue, nocache=nocache, log=False, ) return self.create(name=name, description=description, tags=tags, content=op_spec)
def test_from_hub(self): with patch("polyaxon_sdk.ComponentHubV1Api.get_component_version" ) as request_mock: request_mock.return_value = MagicMock(content=os.path.abspath( "tests/fixtures/plain/simple_job.yml"), ) operation = check_polyaxonfile(hub="org/component:12", is_cli=False, to_op=True) assert operation.version == pkg.SCHEMA_VERSION assert operation.kind == "operation" assert operation.hub_ref == "org/component:12"
def test_from_git_hub(self): os.environ[POLYAXON_KEYS_USE_GIT_REGISTRY] = "true" with patch("polyaxon.config_reader.spec._read_from_public_hub") as request_mock: request_mock.return_value = os.path.abspath( "tests/fixtures/plain/simple_job.yml" ) operation = check_polyaxonfile(hub="component:12", is_cli=False, to_op=True) assert request_mock.call_count == 1 assert operation.kind == "operation" assert operation.hub_ref == "component:12" del os.environ[POLYAXON_KEYS_USE_GIT_REGISTRY]
def test_matrix_file_passes(self): plx_file = check_polyaxonfile( polyaxonfile=os.path.abspath( "tests/fixtures/plain/matrix_job_file.yml"), is_cli=False, ) run_config = OperationSpecification.compile_operation(plx_file) run_config = CompiledOperationSpecification.apply_operation_contexts( run_config) assert run_config.version == 1.1 assert isinstance(run_config.matrix, V1Hyperband) assert isinstance(run_config.matrix.params["lr"], V1HpLinSpace) assert isinstance(run_config.matrix.params["loss"], V1HpChoice) assert run_config.matrix.params["lr"].to_dict() == { "kind": "linspace", "value": { "start": 0.01, "stop": 0.1, "num": 5 }, } assert run_config.matrix.params["loss"].to_dict() == { "kind": "choice", "value": ["MeanSquaredError", "AbsoluteDifference"], } assert run_config.matrix.params["normal_rate"].to_dict() == { "kind": "normal", "value": { "loc": 0, "scale": 0.9 }, } assert run_config.matrix.params["dropout"].to_dict() == { "kind": "qloguniform", "value": { "high": 0.8, "low": 0, "q": 0.1 }, } assert run_config.matrix.params["activation"].to_dict() == { "kind": "pchoice", "value": [["relu", 0.1], ["sigmoid", 0.8]], } assert run_config.matrix.params["model"].to_dict() == { "kind": "choice", "value": ["CDNA", "DNA", "STP"], } assert run_config.matrix.concurrency == 2 assert isinstance(run_config.matrix, V1Hyperband) assert run_config.matrix.kind == V1Hyperband.IDENTIFIER assert run_config.matrix.early_stopping is None
def create_from_url( self, url: str, name: str = None, description: str = None, tags: Union[str, Sequence[str]] = None, params: Dict = None, profile: str = None, queue: str = None, nocache: bool = True, ): """Creates a new run from url containing a Polyaxonfile specification. [Run API](/docs/api/#operation/CreateRun) Args: url: str, url containing a YAML/Json specification. The url's polyaxonfile should contain a [V1Component](/docs/core/specification/component/) or an [V1Operation](/docs/core/specification/operation/). name: str, optional, name note it will override the name in the operation if available. description: str, optional, description note it will override the description in the operation if available. tags: str or List[str], optional, list of tags, note it will override the tags in the operation if available. params: dict, optional, a dictionary of parameters that will be used to resolve the component's inputs/outputs. profile: str, optional, the name of the [run profile](/docs/core/introduction/concepts/#run-profile). queue: str, optional, the name of the [queue](/docs/core/scheduling-strategies/queue-routing/) to assign the run to. nocache: bool, optional, to disable [cache check](/docs/automation/helpers/cache/). If passed and the Polyaxonfile has cache section, it will be patched with `disabled: true`. Returns: V1Run, run instance from the response. """ op_spec = check_polyaxonfile( url=url, params=params, profile=profile, queue=queue, nocache=nocache, log=False, ) return self.create(name=name, description=description, tags=tags, content=op_spec)
def test_cron_pipeline(self): plx_file = check_polyaxonfile( polyaxonfile=os.path.abspath( "tests/fixtures/pipelines/simple_cron_pipeline.yml" ), is_cli=False, to_op=False, ) # Get compiled_operation data run_config = OperationSpecification.compile_operation(plx_file) run_config = CompiledOperationSpecification.apply_context(run_config) assert run_config.run is not None assert len(run_config.run.operations) == 1 assert run_config.run.operations[0].name == "cron-task" assert run_config.schedule is not None assert run_config.schedule.kind == "cron" assert run_config.schedule.cron == "0 0 * * *"
def test_interval_pipeline(self): plx_file = check_polyaxonfile( polyaxonfile=os.path.abspath( "tests/fixtures/pipelines/simple_recurrent_pipeline.yml" ), is_cli=False, to_op=False, ) # Get compiled_operation data run_config = OperationSpecification.compile_operation(plx_file) run_config = CompiledOperationSpecification.apply_context(run_config) assert run_config.run is not None assert len(run_config.run.operations) == 1 assert run_config.run.operations[0].name == "recurrent-task" assert run_config.schedule is not None assert run_config.schedule.kind == "interval" assert run_config.schedule.start_at.year == 2019 assert run_config.schedule.frequency.seconds == 120 assert run_config.schedule.depends_on_past is True assert run_config.schedule is not None
def create_polyaxonfile(): if os.path.isfile(constants.INIT_FILE_PATH): try: _ = check_polyaxonfile(constants.INIT_FILE_PATH) # noqa Printer.print_success("A valid polyaxonfile.yaml was found in the project.") except Exception as e: handle_cli_error(e, message="A Polyaxonfile was found but it is not valid.") sys.exit(1) else: create_init_file(constants.INIT_FILE) # if we are here the file was not created if not os.path.isfile(constants.INIT_FILE_PATH): Printer.print_error( "Something went wrong, init command did not create a file.\n" "Possible reasons: you don't have enough rights to create the file." ) sys.exit(1) Printer.print_success( "{} was created successfully.".format(constants.INIT_FILE_PATH) )
def create_from_hub( self, component: str, name: str = None, description: str = None, tags: Union[str, Sequence[str]] = None, params: Dict = None, profile: str = None, queue: str = None, nocache: bool = True, ): op_spec = check_polyaxonfile( hub=component, params=params, profile=profile, queue=queue, nocache=nocache, log=False, ) return self.create(name=name, description=description, tags=tags, content=op_spec)
def run( ctx, project, polyaxonfile, python_module, url, hub, name, tags, description, upload, log, watch, local, conda_env, params, profile, queue, nocache, ): """Run polyaxonfile specification. Examples: \b $ polyaxon run -f file -f file_override ... Upload before running \b $ polyaxon run -f file -u Run and set description and tags for this run \b $ polyaxon run -f file -u --description="Description of the current run" --tags="foo, bar, moo" Run and set a unique name for this run \b polyaxon run --name=foo Run for a specific project \b $ polyaxon run -p project1 -f file.yaml Run with updated params \b $ polyaxon run -p project1 -f file.yaml -P param1=234.2 -P param2=relu If a python file contains a component main, you can run that component \b polyaxon run -pm path/to/my-component.py If a python file contains more than one component, you can specify the component to run \b polyaxon run -pm path/to/my-component.py:componentA """ op_spec = check_polyaxonfile( polyaxonfile=polyaxonfile, python_module=python_module, url=url, hub=hub, params=params, profile=profile, queue=queue, nocache=nocache, log=False, ) owner, project_name = get_project_or_local(project, is_cli=True) tags = validate_tags(tags) if local: try: compiled_operation = OperationSpecification.compile_operation(op_spec) compiled_operation = CompiledOperationSpecification.apply_context( compiled_operation ) except (PolyaxonSchemaError, ValidationError): Printer.print_error( "Could not run this polyaxonfile locally, " "a context is required to resolve it dependencies." ) sys.exit(1) docker_run( ctx=ctx, name=name, owner=owner, project_name=project_name, description=description, tags=tags, compiled_operation=compiled_operation, log=log, ) elif settings.CLIENT_CONFIG.no_api: k8s_run( ctx=ctx, name=name, owner=owner, project_name=project_name, description=description, tags=tags, op_spec=op_spec, upload=upload, log=log, can_upload=all([upload, project]), ) else: platform_run( ctx=ctx, name=name, owner=owner, project_name=project_name, description=description, tags=tags, op_spec=op_spec, upload=upload, log=log, watch=watch, can_upload=all([upload, project]), )
def test_wong_hub_call(self): with self.assertRaises(PolyaxonfileError): check_polyaxonfile(hub="component:12", is_cli=False, to_op=False)
def test_multi_option_call(self): with self.assertRaises(PolyaxonfileError): check_polyaxonfile(hub="component:12", url="http://foo.bar", is_cli=False, to_op=False)
def run( ctx, project, polyaxonfile, python_module, url, hub, name, tags, description, log, upload, upload_from, upload_to, watch, local, params, presets, queue, nocache, cache, eager, git_preset, git_revision, ignore_template, ): """Run polyaxonfile specification. Examples: \b $ polyaxon run -f file -f file_override ... Run and set description and tags for this run \b $ polyaxon run -f file --description="Description of the current run" --tags="foo, bar, moo" Run and set a unique name for this run \b polyaxon run --name=foo Run for a specific project \b $ polyaxon run -p project1 -f file.yaml Run with updated params \b $ polyaxon run -p project1 -f file.yaml -P param1=234.2 -P param2=relu If a python file contains a component main, you can run that component \b $ polyaxon run -pm path/to/my-component.py If a python file contains more than one component, you can specify the component to run \b $ polyaxon run -pm path/to/my-component.py:componentA Uploading from everything in the current folder to the default uploads path \b $ polyaxon run ... -u Uploading from everything in the current folder to a custom path, e.g. code \b $ polyaxon run ... -u-to code Uploading from everything from a sub-folder, e.g. ./code to the a custom path, e.g. new-code \b $ polyaxon run ... -u-from ./code -u-to new-code """ if cache and nocache: Printer.print_error( "You can't use `--cache` and `--nocache` at the same.", sys_exit=True ) if (upload_to or upload_from) and not upload: upload = True if upload and eager: Printer.print_error( "You can't use `--upload` and `--eager` at the same.", sys_exit=True ) git_init = None if git_preset or git_revision: # Check that the current path was initialized if not GitConfigManager.is_initialized(): Printer.print_error( "You can't use `--git-preset [--git-revision]`, " "the current path is not initialized with a valid git connection or a git url, " "please run `polyaxon init [--git-connection] [--git-url]` " "to set a valid git configuration.", sys_exit=True, ) git_init = GitConfigManager.get_config() if git_init.git is None: GitConfigManager.purge(visibility=GitConfigManager.VISIBILITY_LOCAL) Printer.print_error( "Polyaxon could not start a new run with the `[--git-preset] or [--git-revision]`. " "The current path is initialized with " "an invalid git connection or an invalid git url.\n" "please run `polyaxon init [--git-connection] [--git-url]` " "to properly initialize the current path.", sys_exit=True, ) if git_revision: git_init.git.revision = git_revision elif code_reference.is_git_initialized(path="."): if code_reference.is_dirty(path="."): Printer.print_warning( "Polyaxon detected uncommitted changes in the current git repo!" ) commit_hash = code_reference.get_commit() git_init.git.revision = commit_hash else: Printer.print_warning( "Polyaxon could not find a valid git repo, " "and will not add the current commit to the git initializer." ) presets = validate_tags(presets) op_spec = check_polyaxonfile( polyaxonfile=polyaxonfile, python_module=python_module, url=url, hub=hub, params=params, presets=presets, queue=queue, cache=cache, nocache=nocache, verbose=False, eager=eager, git_init=git_init, ignore_template=ignore_template, ) if ignore_template: op_spec.disable_template() if op_spec.is_template(): click.echo("Please customize the specification or disable the template.") sys.exit(1) owner, project_name = get_project_or_local(project, is_cli=True) tags = validate_tags(tags) if local: try: compiled_operation = OperationSpecification.compile_operation(op_spec) compiled_operation = ( CompiledOperationSpecification.apply_operation_contexts( compiled_operation ) ) except (PolyaxonSchemaError, ValidationError): Printer.print_error( "Could not run this polyaxonfile locally, " "a context is required to resolve it dependencies." ) sys.exit(1) docker_run( ctx=ctx, name=name, owner=owner, project_name=project_name, description=description, tags=tags, compiled_operation=compiled_operation, log=log, ) elif settings.CLIENT_CONFIG.no_api: k8s_run( ctx=ctx, name=name, owner=owner, project_name=project_name, description=description, tags=tags, op_spec=op_spec, log=log, ) else: platform_run( ctx=ctx, name=name, owner=owner, project_name=project_name, description=description, tags=tags, op_spec=op_spec, log=log, upload=upload, upload_to=upload_to, upload_from=upload_from, watch=watch, eager=eager, )
def test_required_inputs_with_params(self): run_config = V1CompiledOperation.read([ os.path.abspath("tests/fixtures/typing/required_inputs.yml"), { "kind": "compiled_operation" }, ]) with self.assertRaises(ValidationError): CompiledOperationSpecification.apply_context(run_config) assert run_config.inputs[0].value is None assert run_config.inputs[1].value is None run_config.apply_params(params={ "loss": { "value": "bar" }, "flag": { "value": False } }) assert run_config.inputs[0].value == "bar" assert run_config.inputs[1].value is False run_config = CompiledOperationSpecification.apply_context(run_config) run_config = CompiledOperationSpecification.apply_run_contexts( run_config) assert run_config.version == 1.1 assert run_config.tags == ["foo", "bar"] assert run_config.run.container.image == "my_image" assert run_config.run.container.command == ["/bin/sh", "-c"] assert run_config.run.container.args == "video_prediction_train --loss=bar " run_config = V1CompiledOperation.read([ os.path.abspath("tests/fixtures/typing/required_inputs.yml"), { "kind": "compiled_operation" }, ]) assert run_config.inputs[0].value is None assert run_config.inputs[1].value is None run_config.apply_params(params={ "loss": { "value": "bar" }, "flag": { "value": True } }) assert run_config.inputs[0].value == "bar" assert run_config.inputs[1].value is True run_config = CompiledOperationSpecification.apply_context(run_config) run_config = CompiledOperationSpecification.apply_run_contexts( run_config) assert run_config.version == 1.1 assert run_config.tags == ["foo", "bar"] assert run_config.run.container.image == "my_image" assert run_config.run.container.command == ["/bin/sh", "-c"] assert (run_config.run.container.args == "video_prediction_train --loss=bar --flag") # Adding extra value raises with self.assertRaises(ValidationError): run_config.validate_params( params={ "loss": { "value": "bar" }, "flag": { "value": True }, "value": { "value": 1.1 }, }) with self.assertRaises(PolyaxonfileError): check_polyaxonfile( polyaxonfile=os.path.abspath( "tests/fixtures/typing/required_inputs.yml"), params={ "loss": { "value": "bar" }, "value": { "value": 1.1 } }, is_cli=False, ) # Adding non valid params raises with self.assertRaises(ValidationError): run_config.validate_params(params={"value": {"value": 1.1}})
def run( ctx, project, polyaxonfile, python_module, url, hub, name, tags, description, log, watch, local, params, presets, queue, nocache, eager, git_preset, git_revision, ignore_template, ): """Run polyaxonfile specification. Examples: \b $ polyaxon run -f file -f file_override ... Run and set description and tags for this run \b $ polyaxon run -f file --description="Description of the current run" --tags="foo, bar, moo" Run and set a unique name for this run \b polyaxon run --name=foo Run for a specific project \b $ polyaxon run -p project1 -f file.yaml Run with updated params \b $ polyaxon run -p project1 -f file.yaml -P param1=234.2 -P param2=relu If a python file contains a component main, you can run that component \b polyaxon run -pm path/to/my-component.py If a python file contains more than one component, you can specify the component to run \b polyaxon run -pm path/to/my-component.py:componentA """ git_init = None if git_preset: # Check that the current path was initialized if not GitConfigManager.is_initialized(): Printer.print_error( "You can't use --git-init, " "the current path is not initialized with a valid git connection or a git url, " "please run `polyaxon init [--git-connection] [--git-url]` " "to set a valid git configuration.") sys.exit(1) git_init = GitConfigManager.get_config() if git_revision: git_init.git.revision = git_revision elif code_reference.is_git_initialized(path="."): if code_reference.is_dirty(path="."): Printer.print_warning( "Polyaxon detected uncommitted changes in the current git repo!" ) commit_hash = code_reference.get_commit() git_init.git.revision = commit_hash else: Printer.print_warning( "Polyaxon could not find a valid git repo, " "and will not add the current commit to the git initializer.") presets = validate_tags(presets) op_spec = check_polyaxonfile( polyaxonfile=polyaxonfile, python_module=python_module, url=url, hub=hub, params=params, presets=presets, queue=queue, nocache=nocache, verbose=False, eager=eager, git_init=git_init, ignore_template=ignore_template, ) if ignore_template: op_spec.disable_template() if op_spec.is_template(): click.echo( "Please customize the specification or disable the template.") sys.exit(1) owner, project_name = get_project_or_local(project, is_cli=True) tags = validate_tags(tags) if local: try: compiled_operation = OperationSpecification.compile_operation( op_spec) compiled_operation = CompiledOperationSpecification.apply_operation_contexts( compiled_operation) except (PolyaxonSchemaError, ValidationError): Printer.print_error( "Could not run this polyaxonfile locally, " "a context is required to resolve it dependencies.") sys.exit(1) docker_run( ctx=ctx, name=name, owner=owner, project_name=project_name, description=description, tags=tags, compiled_operation=compiled_operation, log=log, ) elif settings.CLIENT_CONFIG.no_api: k8s_run( ctx=ctx, name=name, owner=owner, project_name=project_name, description=description, tags=tags, op_spec=op_spec, log=log, ) else: platform_run( ctx=ctx, name=name, owner=owner, project_name=project_name, description=description, tags=tags, op_spec=op_spec, log=log, watch=watch, eager=eager, )