56 lines
2.3 KiB
Python
56 lines
2.3 KiB
Python
"""The import pipeline's step vocabulary, and the gate-to-step mapping.
|
|
|
|
`ImportStep` is the join between three things: the machine-readable step written into the import
|
|
record's JSON detail, the key of the error catalog (one code and one sentence per step) and the
|
|
value the frontend switches on. It lives in the bundle package rather than in the activities module
|
|
because the reader raises with it — `laborious/activities/model_import.py` imports it from here so
|
|
there is exactly one definition.
|
|
|
|
It holds **pipeline** steps only. The two failures that are not steps of the pipeline — failing to
|
|
claim the record and failing to write it — are reported by the failure channel under their own
|
|
markers (`not_claimable`, `status_write`), deliberately outside this enum so the
|
|
catalog-completeness test keeps meaning "every pipeline step has a sentence".
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from enum import StrEnum
|
|
from typing import Final
|
|
|
|
|
|
class ImportStep(StrEnum):
|
|
"""Where an import stopped. Values are what gets written to the record."""
|
|
|
|
RECEIVED = 'received'
|
|
DOWNLOAD = 'download'
|
|
DECRYPTION = 'decryption'
|
|
ARCHIVE_INSPECTION = 'archive_inspection'
|
|
EXTRACTION = 'extraction'
|
|
STRUCTURE_VALIDATION = 'structure_validation'
|
|
CONTENT_POLICY = 'content_policy'
|
|
EXPERIMENT_CREATION = 'experiment_creation'
|
|
ARTIFACT_UPLOAD = 'artifact_upload'
|
|
REGISTRATION = 'registration'
|
|
MODEL_DOCUMENT = 'model_document'
|
|
CLEANUP = 'cleanup'
|
|
|
|
|
|
# The seven gates map onto the first seven steps, with gates 1 and 2 sharing one: both say "these
|
|
# are not the bytes that were sent" — an object over the size ceiling, a key with the wrong shape, a
|
|
# digest that disagrees with what the uploader computed, a wrong magic, an unsupported version, a
|
|
# chunk stream that does not match the header's digest. The catalog's `download` sentence ("The
|
|
# uploaded file could not be read, or it is not the file that was sent. Upload it again.") is true
|
|
# for all of them, and none of them may borrow the `decryption` sentence, which implicates the
|
|
# password.
|
|
GATE_TO_STEP: Final[dict[int, ImportStep]] = {
|
|
1: ImportStep.DOWNLOAD,
|
|
2: ImportStep.DOWNLOAD,
|
|
3: ImportStep.DECRYPTION,
|
|
4: ImportStep.ARCHIVE_INSPECTION,
|
|
5: ImportStep.EXTRACTION,
|
|
6: ImportStep.STRUCTURE_VALIDATION,
|
|
7: ImportStep.CONTENT_POLICY,
|
|
}
|
|
|
|
GATE_COUNT: Final[int] = 7
|