Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: BYO Deadline now looks specifically for resource env vars. #128

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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