diff --git a/cluster_agent/jobbergate/schemas.py b/cluster_agent/jobbergate/schemas.py index d505e12..10d339d 100644 --- a/cluster_agent/jobbergate/schemas.py +++ b/cluster_agent/jobbergate/schemas.py @@ -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): diff --git a/cluster_agent/jobbergate/submit.py b/cluster_agent/jobbergate/submit.py index 3283257..e824976 100644 --- a/cluster_agent/jobbergate/submit.py +++ b/cluster_agent/jobbergate/submit.py @@ -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) diff --git a/tests/jobbergate/conftest.py b/tests/jobbergate/conftest.py index 9766127..a028037 100644 --- a/tests/jobbergate/conftest.py +++ b/tests/jobbergate/conftest.py @@ -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