Skip to content

Commit

Permalink
Support --submiter-name for non-GUI submitter
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Crowe <[email protected]>
  • Loading branch information
crowecawcaw committed Jul 26, 2024
1 parent 9bc3072 commit 5862cc9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/deadline/client/api/_submit_job_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def create_job_from_job_bundle(
upload_progress_callback: Optional[Callable[[ProgressReportMetadata], bool]] = None,
create_job_result_callback: Optional[Callable[[], bool]] = None,
require_paths_exist: bool = False,
submitter_name: str = "CLI",
) -> Union[str, None]:
"""
Creates a job in the AWS Deadline Cloud farm/queue configured as default for the
Expand Down Expand Up @@ -310,7 +311,7 @@ def create_job_from_job_bundle(

api.get_deadline_cloud_library_telemetry_client().record_event(
event_type="com.amazon.rum.deadline.submission",
event_details={},
event_details={"submitter_name": submitter_name},
)

create_job_response = deadline.create_job(**create_job_args)
Expand Down
7 changes: 7 additions & 0 deletions src/deadline/client/cli/_groups/bundle_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ def validate_parameters(ctx, param, value):
is_flag=True,
help="Require all input paths to exist",
)
@click.option(
"--submitter-name",
type=click.STRING,
help="Name of the application submitting the bundle.",
)
@click.argument("job_bundle_dir")
@_handle_error
def bundle_submit(
Expand All @@ -119,6 +124,7 @@ def bundle_submit(
max_failed_tasks_count,
max_retries_per_task,
require_paths_exist,
submitter_name,
**args,
):
"""
Expand Down Expand Up @@ -199,6 +205,7 @@ def _decide_cancel_submission(upload_group: AssetUploadGroup) -> bool:
print_function_callback=click.echo,
decide_cancel_submission_callback=_decide_cancel_submission,
require_paths_exist=require_paths_exist,
submitter_name=submitter_name,
)

# Check Whether the CLI options are modifying any of the default settings that affect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def __init__(
self.setMinimumSize(400, 400)

self.job_settings_type = type(initial_job_settings)
self.submitter_name = submitter_name or self.job_settings_type.submitter_name
self.submitter_name = submitter_name or self.job_settings_type().submitter_name
self.on_create_job_bundle_callback = on_create_job_bundle_callback
self.create_job_response: Optional[Dict[str, Any]] = None
self.job_history_bundle_dir: Optional[str] = None
Expand Down
13 changes: 12 additions & 1 deletion test/unit/deadline_client/cli/test_cli_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,11 @@ def test_cli_bundle_job_parameter_from_cli(fresh_deadline_config):
Verify that job parameters specified at the CLI are passed to the CreateJob call
"""
# Use a temporary directory for the job bundle
with tempfile.TemporaryDirectory() as tmpdir, patch.object(boto3, "Session") as session_mock:
with tempfile.TemporaryDirectory() as tmpdir, patch.object(
boto3, "Session"
) as session_mock, patch.object(
bundle_group.api, "get_deadline_cloud_library_telemetry_client"
) as telemetry_mock:
session_mock().client("deadline").create_job.return_value = MOCK_CREATE_JOB_RESPONSE
session_mock().client("deadline").get_job.return_value = MOCK_GET_JOB_RESPONSE
session_mock.reset_mock()
Expand All @@ -426,6 +430,8 @@ def test_cli_bundle_job_parameter_from_cli(fresh_deadline_config):
"priority=90",
"--priority",
"45",
"--submitter-name",
"MyDCC",
],
)

Expand All @@ -441,6 +447,11 @@ def test_cli_bundle_job_parameter_from_cli(fresh_deadline_config):
priority=45,
)

telemetry_mock.return_value.record_event.assert_any_call(
event_type="com.amazon.rum.deadline.submission",
event_details={"submitter_name": "MyDCC"},
)

assert result.exit_code == 0


Expand Down

0 comments on commit 5862cc9

Please sign in to comment.