Skip to content

Commit bf2e6bf

Browse files
committed
fix test
1 parent 2692816 commit bf2e6bf

4 files changed

Lines changed: 16 additions & 6 deletions

File tree

amorphouspy_api/src/amorphouspy_api/pipeline.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,11 @@ def _run_elastic(submission: JobSubmission, config: ElasticAnalysis, result: dic
221221
# Analyses that build their own sub-DAG instead of going through _run_analysis.
222222
_SUBMITTERS: dict[str, Callable[..., Future]] = {"viscosity": _submit_viscosity}
223223

224-
__all__ = ["ANALYSES", "BASE_STEPS", "STEPS", "submit_pipeline"]
224+
# All known analysis names (simple + DAG-based), used for result lookups and
225+
# progress tracking.
226+
ANALYSIS_NAMES: frozenset[str] = frozenset(ANALYSES) | frozenset(_SUBMITTERS)
227+
228+
__all__ = ["ANALYSES", "ANALYSIS_NAMES", "BASE_STEPS", "STEPS", "submit_pipeline"]
225229

226230

227231
# ---------------------------------------------------------------------------

amorphouspy_api/src/amorphouspy_api/routers/jobs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
_job_urls,
5252
validate_atoms,
5353
)
54-
from amorphouspy_api.pipeline import ANALYSES
54+
from amorphouspy_api.pipeline import ANALYSIS_NAMES
5555
from amorphouspy_api.routers.jobs_helpers import (
5656
_analyses_list,
5757
_initial_progress,
@@ -450,7 +450,7 @@ def get_job_results(job_id: str) -> JobResultsResponse:
450450
raise HTTPException(status_code=404, detail="No results available yet")
451451

452452
# Collect results for all analysis types
453-
analyses = {key: result[key] for key in ANALYSES if key in result}
453+
analyses = {key: result[key] for key in ANALYSIS_NAMES if key in result}
454454

455455
return JobResultsResponse(
456456
job_id=job.job_id,

amorphouspy_api/src/amorphouspy_api/routers/jobs_helpers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
JobSubmission,
2222
StepStatus,
2323
)
24-
from amorphouspy_api.pipeline import ANALYSES, BASE_STEPS, submit_pipeline
24+
from amorphouspy_api.pipeline import ANALYSIS_NAMES, BASE_STEPS, submit_pipeline
2525

2626
if TYPE_CHECKING:
2727
from amorphouspy_api.database import Job
@@ -267,7 +267,7 @@ def _update_from_resolved(job_id: str, resolved: dict, submission: JobSubmission
267267
# Build the expected step list
268268
all_steps = list(BASE_STEPS)
269269
if submission:
270-
all_steps.extend(a.type for a in submission.analyses if a.type in ANALYSES)
270+
all_steps.extend(a.type for a in submission.analyses if a.type in ANALYSIS_NAMES)
271271

272272
if status == "completed":
273273
result = resolved["result"]
@@ -399,7 +399,7 @@ def refresh_job_from_cache(job: Job) -> None:
399399
submission = _parse_submission(job)
400400
all_steps = list(BASE_STEPS)
401401
if submission:
402-
all_steps.extend(a.type for a in submission.analyses if a.type in ANALYSES)
402+
all_steps.extend(a.type for a in submission.analyses if a.type in ANALYSIS_NAMES)
403403

404404
progress, partial_results, has_failure, errors = _probe_step_caches(job, all_steps)
405405

amorphouspy_api/src/tests/test_pipeline.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from amorphouspy_api.pipeline import (
66
_SUBMITTERS,
77
ANALYSES,
8+
ANALYSIS_NAMES,
89
BASE_STEPS,
910
STEPS,
1011
_accumulate_step,
@@ -131,6 +132,11 @@ def test_submitters_contain_viscosity(self) -> None:
131132
assert "viscosity" in _SUBMITTERS
132133
assert callable(_SUBMITTERS["viscosity"])
133134

135+
def test_analysis_names_includes_all(self) -> None:
136+
"""ANALYSIS_NAMES is the union of ANALYSES and _SUBMITTERS."""
137+
assert frozenset(ANALYSES) | frozenset(_SUBMITTERS) == ANALYSIS_NAMES
138+
assert "viscosity" in ANALYSIS_NAMES
139+
134140
def test_all_steps_are_callable(self) -> None:
135141
"""Every registered step function is callable."""
136142
for fn in STEPS.values():

0 commit comments

Comments
 (0)