Skip to content

Commit

Permalink
fix: BYO Deadline now looks specifically for resource env vars.
Browse files Browse the repository at this point in the history
Signed-off-by: Eric Osiowy <134728121+erico-aws@users.noreply.github.com>
  • Loading branch information
erico-aws committed Jul 8, 2024
1 parent 56b2f41 commit c7cce1c
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/deadline_test_fixtures/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,21 +281,16 @@ def deadline_resources(
"""
if os.getenv("BYO_DEADLINE", "false").lower() == "true":
kwargs: dict[str, Any] = {}
resource_env_vars: list[str] = [
'FARM_ID',
'FLEET_ID',
'QUEUE_ID',
]

all_fields = fields(DeadlineResources)
for f in all_fields:
env_var = f.name.upper()
for env_var in resource_env_vars:
if env_var in os.environ:
kwargs[f.name] = os.environ[env_var]
kwargs[env_var.lower()] = os.environ[env_var]

required_fields = [f for f in all_fields if (MISSING == f.default == f.default_factory)]
assert all([rf.name in kwargs for rf in required_fields]), (
"Not all Deadline resources have been fulfilled via environment variables. Expected "
+ f"values for {[f.name.upper() for f in required_fields]}, but got {kwargs}"
)
LOG.info(
f"All Deadline resources have been fulfilled via environment variables. Using {kwargs}"
)
yield DeadlineResources(**kwargs)
else:
LOG.info("Deploying Deadline resources")
Expand Down

0 comments on commit c7cce1c

Please sign in to comment.