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 b350013
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 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

0 comments on commit b350013

Please sign in to comment.