Skip to content

Commit

Permalink
Merge branch 'aws-deadline:mainline' into telemetry2
Browse files Browse the repository at this point in the history
  • Loading branch information
leongdl authored Jul 9, 2024
2 parents 762bf84 + 51fc0f1 commit 0d341ff
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
19 changes: 15 additions & 4 deletions src/deadline_worker_agent/boto/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,34 @@
from botocore.config import Config

from .._version import __version__ as worker_agent_version
from deadline.client import version as deadline_client_lib_version
from openjd.sessions import version as openjd_sessions_version


def construct_user_agent() -> str:
"""
Compute the user agent string to send over boto requests.
- Contains the versions of Deadline Worker Agent, Deadline Client Library, OpenJD Sessions.
"""
return f"deadline_worker_agent/{worker_agent_version} deadline_cloud/{deadline_client_lib_version} openjd_sessions/{openjd_sessions_version}"


DEADLINE_BOTOCORE_CONFIG = Config(
retries={
"max_attempts": 1,
},
user_agent_extra=f"deadline_worker_agent/{worker_agent_version}",
user_agent_extra=construct_user_agent(),
)

"""
Botocore client configuration for AWS Deadline Cloud. This overrides to:
- botocore retries - the worker agent has its own retry logic for AWS Deadline Cloud
API requests. See the `aws/deadline` sub-package for that retry logic.
- add deadline-worker-agent version to user User-Agent request header
- add deadline, deadline worker agent and openjd package versions to user User-Agent request header
"""

OTHER_BOTOCORE_CONFIG = Config(user_agent_extra=f"deadline_worker_agent/{worker_agent_version}")
OTHER_BOTOCORE_CONFIG = Config(user_agent_extra=construct_user_agent())
"""
Botocore client configuration for other AWS services. This overrides to:
- add deadline-worker-agent version to user User-Agent request header
- add deadline, deadline worker agent and openjd package versions to user User-Agent request header
"""
12 changes: 10 additions & 2 deletions test/unit/boto/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from botocore.config import Config

from deadline_worker_agent._version import __version__
from deadline.client import version as deadline_client_lib_version
from openjd.sessions import version as openjd_sessions_version
import deadline_worker_agent.boto.config as boto_config_mod


Expand All @@ -20,7 +22,10 @@ def test_sets_user_agent(self) -> None:

# THEN
assert isinstance(DEADLINE_BOTOCORE_CONFIG, Config)
assert DEADLINE_BOTOCORE_CONFIG.user_agent_extra == f"deadline_worker_agent/{__version__}"
libraries: list[str] = DEADLINE_BOTOCORE_CONFIG.user_agent_extra.split(" ")
assert libraries[0] == f"deadline_worker_agent/{__version__}"
assert libraries[1] == f"deadline_cloud/{deadline_client_lib_version}"
assert libraries[2] == f"openjd_sessions/{openjd_sessions_version}"

def test_does_not_retry(self) -> None:
"""Asserts that DEADLINE_BOTOCORE_CONFIG sets retries.max_attempts to 1.
Expand Down Expand Up @@ -60,4 +65,7 @@ def test_sets_user_agent(self) -> None:

# THEN
assert isinstance(OTHER_BOTOCORE_CONFIG, Config)
assert OTHER_BOTOCORE_CONFIG.user_agent_extra == f"deadline_worker_agent/{__version__}"
libraries: list[str] = OTHER_BOTOCORE_CONFIG.user_agent_extra.split(" ")
assert libraries[0] == f"deadline_worker_agent/{__version__}"
assert libraries[1] == f"deadline_cloud/{deadline_client_lib_version}"
assert libraries[2] == f"openjd_sessions/{openjd_sessions_version}"

0 comments on commit 0d341ff

Please sign in to comment.