Skip to content

Commit

Permalink
PENG-1556 replace file container from dict to list
Browse files Browse the repository at this point in the history
  • Loading branch information
fschuch committed Aug 9, 2023
1 parent b1a7281 commit 90992c7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
9 changes: 6 additions & 3 deletions cluster_agent/jobbergate/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,20 @@
class JobScriptFile(pydantic.BaseModel, extra=pydantic.Extra.ignore):
"""Model for the job_script_files field of the JobScript resource."""

id: int
parent_id: int
filename: str
file_type: FileType
parent_id: int

path: str
@property
def path(self) -> str:
return f"jobbergate/job-scripts/{self.parent_id}/upload/{self.filename}"


class JobScript(pydantic.BaseModel, extra=pydantic.Extra.ignore):
"""Model to match database for the JobScript resource."""

files: Dict[str, JobScriptFile]
files: List[JobScriptFile]


class PendingJobSubmission(pydantic.BaseModel, extra=pydantic.Extra.ignore):
Expand Down
4 changes: 2 additions & 2 deletions cluster_agent/jobbergate/submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ async def submit_job_script(

job_script = None

for filename, metadata in pending_job_submission.job_script.files.items():
local_script_path = submit_dir / filename
for metadata in pending_job_submission.job_script.files:
local_script_path = submit_dir / metadata.filename
local_script_path.parent.mkdir(parents=True, exist_ok=True)

response = await backend_client.get(metadata.path)
Expand Down
9 changes: 4 additions & 5 deletions tests/jobbergate/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,13 @@ def dummy_template_source():

@pytest.fixture
def dummy_job_script_files():
return {
"application.sh": {
"id": 1,
return [
{
"parent_id": 1,
"filename": "application.sh",
"file_type": "ENTRYPOINT",
"path": "jobbergate/job-scripts/1/upload/application.sh",
},
}
]


@pytest.fixture
Expand Down
2 changes: 1 addition & 1 deletion tests/jobbergate/test_submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ async def test_submit_job_script__raises_exception_if_no_executable_script_was_f
and that the job submission status is updated to rejected.
"""
pending_job_submission = PendingJobSubmission(**dummy_pending_job_submission_data)
pending_job_submission.job_script.files = {}
pending_job_submission.job_script.files = []

async with respx.mock:
respx.post(f"https://{SETTINGS.OIDC_DOMAIN}/oauth/token").mock(
Expand Down

0 comments on commit 90992c7

Please sign in to comment.