From 7993b5519b182f0eab62f342b232c2645cc7c54e Mon Sep 17 00:00:00 2001 From: Michael Walsh Date: Mon, 25 Nov 2024 11:00:38 -0500 Subject: [PATCH] changes found during manual testing of workflows --- .../request/CreateCalibrationRecordRequest.py | 3 +- .../dao/request/CreateIndexEntryRequest.py | 6 +-- .../dao/request/FarmFreshIngredients.py | 11 ++++-- .../backend/dao/request/ReductionRequest.py | 9 ++++- src/snapred/backend/data/DataExportService.py | 10 ++--- .../backend/data/DataFactoryService.py | 29 +++++++++----- src/snapred/backend/data/GroceryService.py | 4 +- src/snapred/backend/data/Indexer.py | 23 +++++++---- src/snapred/backend/data/LocalDataService.py | 38 +++++++++++++------ .../backend/service/CalibrationService.py | 3 +- .../backend/service/NormalizationService.py | 3 +- .../backend/service/ReductionService.py | 8 ++-- src/snapred/backend/service/SousChef.py | 2 + src/snapred/resources/application.yml | 2 +- src/snapred/ui/workflow/DiffCalWorkflow.py | 6 +-- .../ui/workflow/NormalizationWorkflow.py | 6 +-- 16 files changed, 103 insertions(+), 60 deletions(-) diff --git a/src/snapred/backend/dao/request/CreateCalibrationRecordRequest.py b/src/snapred/backend/dao/request/CreateCalibrationRecordRequest.py index c91e94b3f..8060c6538 100644 --- a/src/snapred/backend/dao/request/CreateCalibrationRecordRequest.py +++ b/src/snapred/backend/dao/request/CreateCalibrationRecordRequest.py @@ -5,6 +5,7 @@ from snapred.backend.dao.calibration.Calibration import Calibration from snapred.backend.dao.calibration.FocusGroupMetric import FocusGroupMetric from snapred.backend.dao.CrystallographicInfo import CrystallographicInfo +from snapred.backend.dao.indexing.Versioning import Version, VersionState from snapred.backend.dao.state.PixelGroup import PixelGroup from snapred.meta.mantid.WorkspaceNameGenerator import WorkspaceName, WorkspaceType @@ -18,7 +19,7 @@ class CreateCalibrationRecordRequest(BaseModel, extra="forbid"): runNumber: str useLiteMode: bool - version: Optional[int] = None + version: Version = VersionState.NEXT calculationParameters: Calibration crystalInfo: CrystallographicInfo pixelGroups: Optional[List[PixelGroup]] = None diff --git a/src/snapred/backend/dao/request/CreateIndexEntryRequest.py b/src/snapred/backend/dao/request/CreateIndexEntryRequest.py index a2be99075..3292afed4 100644 --- a/src/snapred/backend/dao/request/CreateIndexEntryRequest.py +++ b/src/snapred/backend/dao/request/CreateIndexEntryRequest.py @@ -1,7 +1,7 @@ -from typing import Optional - from pydantic import BaseModel +from snapred.backend.dao.indexing.Versioning import Version, VersionState + class CreateIndexEntryRequest(BaseModel): """ @@ -10,7 +10,7 @@ class CreateIndexEntryRequest(BaseModel): runNumber: str useLiteMode: bool - version: Optional[int] = None + version: Version = VersionState.NEXT comments: str author: str appliesTo: str diff --git a/src/snapred/backend/dao/request/FarmFreshIngredients.py b/src/snapred/backend/dao/request/FarmFreshIngredients.py index d61f43add..71f9370a3 100644 --- a/src/snapred/backend/dao/request/FarmFreshIngredients.py +++ b/src/snapred/backend/dao/request/FarmFreshIngredients.py @@ -2,13 +2,14 @@ from pydantic import BaseModel, ConfigDict, ValidationError, field_validator, model_validator +from snapred.backend.dao.indexing.Versioning import Version, VersionState from snapred.backend.dao.Limit import Limit, Pair from snapred.backend.dao.state import FocusGroup from snapred.meta.Config import Config from snapred.meta.mantid.AllowedPeakTypes import SymmetricPeakEnum # TODO: this declaration is duplicated in `ReductionRequest`. -Versions = NamedTuple("Versions", [("calibration", Optional[int]), ("normalization", Optional[int])]) +Versions = NamedTuple("Versions", [("calibration", Version), ("normalization", Version)]) class FarmFreshIngredients(BaseModel): @@ -21,7 +22,7 @@ class FarmFreshIngredients(BaseModel): runNumber: str - versions: Versions = Versions(None, None) + versions: Versions = Versions(VersionState.LATEST, VersionState.LATEST) # allow 'versions' to be accessed as a single version, # or, to be accessed ambiguously @@ -83,6 +84,10 @@ def focusGroup(self, fg: FocusGroup): def validate_versions(cls, v) -> Versions: if not isinstance(v, Versions): v = Versions(v) + if v.calibration is None: + raise ValueError("Calibration version must be specified") + if v.normalization is None: + raise ValueError("Normalization version must be specified") return v @field_validator("crystalDBounds", mode="before") @@ -119,4 +124,4 @@ def validate_focusGroups(cls, v: Any): del v["focusGroup"] return v - model_config = ConfigDict(extra="forbid") + model_config = ConfigDict(extra="forbid", validate_assignment=True) diff --git a/src/snapred/backend/dao/request/ReductionRequest.py b/src/snapred/backend/dao/request/ReductionRequest.py index c8d44822c..4ca60f704 100644 --- a/src/snapred/backend/dao/request/ReductionRequest.py +++ b/src/snapred/backend/dao/request/ReductionRequest.py @@ -2,13 +2,14 @@ from pydantic import BaseModel, ConfigDict, field_validator +from snapred.backend.dao.indexing.Versioning import Version, VersionState from snapred.backend.dao.ingredients import ArtificialNormalizationIngredients from snapred.backend.dao.state.FocusGroup import FocusGroup from snapred.backend.error.ContinueWarning import ContinueWarning from snapred.meta.mantid.WorkspaceNameGenerator import WorkspaceName from snapred.meta.mantid.WorkspaceNameGenerator import WorkspaceNameGenerator as wng -Versions = NamedTuple("Versions", [("calibration", Optional[int]), ("normalization", Optional[int])]) +Versions = NamedTuple("Versions", [("calibration", Version), ("normalization", Version)]) class ReductionRequest(BaseModel): @@ -22,7 +23,7 @@ class ReductionRequest(BaseModel): # Calibration and normalization versions: # `None` => - versions: Versions = Versions(None, None) + versions: Versions = Versions(VersionState.LATEST, VersionState.LATEST) pixelMasks: List[WorkspaceName] = [] artificialNormalizationIngredients: Optional[ArtificialNormalizationIngredients] = None @@ -37,6 +38,10 @@ def validate_versions(cls, v) -> Versions: if not isinstance(v, Tuple): raise ValueError("'versions' must be a tuple: '(, )'") v = Versions(v) + if v.calibration is None: + raise ValueError("Calibration version must be specified") + if v.normalization is None: + raise ValueError("Normalization version must be specified") return v model_config = ConfigDict( diff --git a/src/snapred/backend/data/DataExportService.py b/src/snapred/backend/data/DataExportService.py index ae53f0eef..01bd654d3 100644 --- a/src/snapred/backend/data/DataExportService.py +++ b/src/snapred/backend/data/DataExportService.py @@ -1,6 +1,6 @@ import time from pathlib import Path -from typing import Tuple +from typing import Optional, Tuple from pydantic import validate_call @@ -64,11 +64,11 @@ def exportCalibrationIndexEntry(self, entry: IndexEntry): """ self.dataService.writeCalibrationIndexEntry(entry) - def exportCalibrationRecord(self, record: CalibrationRecord): + def exportCalibrationRecord(self, record: CalibrationRecord, entry: Optional[IndexEntry] = None): """ Record must have correct version set. """ - self.dataService.writeCalibrationRecord(record) + self.dataService.writeCalibrationRecord(record, entry) def exportCalibrationWorkspaces(self, record: CalibrationRecord): """ @@ -94,11 +94,11 @@ def exportNormalizationIndexEntry(self, entry: IndexEntry): """ self.dataService.writeNormalizationIndexEntry(entry) - def exportNormalizationRecord(self, record: NormalizationRecord): + def exportNormalizationRecord(self, record: NormalizationRecord, entry: Optional[IndexEntry] = None): """ Record must have correct version set. """ - self.dataService.writeNormalizationRecord(record) + self.dataService.writeNormalizationRecord(record, entry) def exportNormalizationWorkspaces(self, record: NormalizationRecord): """ diff --git a/src/snapred/backend/data/DataFactoryService.py b/src/snapred/backend/data/DataFactoryService.py index d878c1839..4a5fc50a8 100644 --- a/src/snapred/backend/data/DataFactoryService.py +++ b/src/snapred/backend/data/DataFactoryService.py @@ -1,11 +1,12 @@ import os from pathlib import Path -from typing import Dict, List, Optional +from typing import Dict, List from pydantic import validate_call from snapred.backend.dao.calibration.CalibrationRecord import CalibrationRecord from snapred.backend.dao.indexing.IndexEntry import IndexEntry +from snapred.backend.dao.indexing.Versioning import Version, VersionState from snapred.backend.dao.InstrumentConfig import InstrumentConfig from snapred.backend.dao.normalization.NormalizationRecord import NormalizationRecord from snapred.backend.dao.reduction import ReductionRecord @@ -81,7 +82,7 @@ def calibrationExists(self, runId: str, useLiteMode: bool): return self.lookupService.calibrationExists(runId, useLiteMode) @validate_call - def getCalibrationDataPath(self, runId: str, useLiteMode: bool, version: int): + def getCalibrationDataPath(self, runId: str, useLiteMode: bool, version: Version): return self.lookupService.calibrationIndexer(runId, useLiteMode).versionPath(version) def checkCalibrationStateExists(self, runId: str): @@ -102,14 +103,18 @@ def getCalibrationIndex(self, runId: str, useLiteMode: bool) -> List[IndexEntry] return self.lookupService.calibrationIndexer(runId, useLiteMode).getIndex() @validate_call - def getCalibrationRecord(self, runId: str, useLiteMode: bool, version: Optional[int] = None) -> CalibrationRecord: + def getCalibrationRecord( + self, runId: str, useLiteMode: bool, version: Version = VersionState.LATEST + ) -> CalibrationRecord: """ If no version is passed, will use the latest version applicable to runId """ + if version is None: + raise ValueError("Version must be specified") return self.lookupService.readCalibrationRecord(runId, useLiteMode, version) @validate_call - def getCalibrationDataWorkspace(self, runId: str, useLiteMode: bool, version: int, name: str): + def getCalibrationDataWorkspace(self, runId: str, useLiteMode: bool, version: Version, name: str): path = self.lookupService.calibrationIndexer(runId, useLiteMode).versionPath(version) return self.groceryService.fetchWorkspace(os.path.join(path, name) + ".nxs", name) @@ -123,7 +128,7 @@ def normalizationExists(self, runId: str, useLiteMode: bool): return self.lookupService.normalizationExists(runId, useLiteMode) @validate_call - def getNormalizationDataPath(self, runId: str, useLiteMode: bool, version: int): + def getNormalizationDataPath(self, runId: str, useLiteMode: bool, version: Version): return self.lookupService.normalizationIndexer(runId, useLiteMode).versionPath(version) def createNormalizationIndexEntry(self, request: NormalizationExportRequest) -> IndexEntry: @@ -141,14 +146,16 @@ def getNormalizationIndex(self, runId: str, useLiteMode: bool) -> List[IndexEntr return self.lookupService.normalizationIndexer(runId, useLiteMode).getIndex() @validate_call - def getNormalizationRecord(self, runId: str, useLiteMode: bool, version: Optional[int] = None): + def getNormalizationRecord( + self, runId: str, useLiteMode: bool, version: Version = VersionState.LATEST + ) -> NormalizationRecord: """ If no version is passed, will use the latest version applicable to runId """ return self.lookupService.readNormalizationRecord(runId, useLiteMode, version) @validate_call - def getNormalizationDataWorkspace(self, runId: str, useLiteMode: bool, version: int, name: str): + def getNormalizationDataWorkspace(self, runId: str, useLiteMode: bool, version: Version, name: str): path = self.getNormalizationDataPath(runId, useLiteMode, version) return self.groceryService.fetchWorkspace(os.path.join(path, name) + ".nxs", name) @@ -179,18 +186,20 @@ def getReductionState(self, runId: str, useLiteMode: bool) -> ReductionState: return reductionState @validate_call - def getReductionDataPath(self, runId: str, useLiteMode: bool, version: int) -> Path: + def getReductionDataPath(self, runId: str, useLiteMode: bool, version: Version) -> Path: return self.lookupService._constructReductionDataPath(runId, useLiteMode, version) @validate_call - def getReductionRecord(self, runId: str, useLiteMode: bool, version: Optional[int] = None) -> ReductionRecord: + def getReductionRecord( + self, runId: str, useLiteMode: bool, version: Version = VersionState.LATEST + ) -> ReductionRecord: """ If no version is passed, will use the latest version applicable to runId """ return self.lookupService.readReductionRecord(runId, useLiteMode, version) @validate_call - def getReductionData(self, runId: str, useLiteMode: bool, version: int) -> ReductionRecord: + def getReductionData(self, runId: str, useLiteMode: bool, version: Version) -> ReductionRecord: return self.lookupService.readReductionData(runId, useLiteMode, version) @validate_call diff --git a/src/snapred/backend/data/GroceryService.py b/src/snapred/backend/data/GroceryService.py index df7c9d7b2..8b46e227c 100644 --- a/src/snapred/backend/data/GroceryService.py +++ b/src/snapred/backend/data/GroceryService.py @@ -14,7 +14,7 @@ ) from pydantic import validate_call -from snapred.backend.dao.indexing.Versioning import VersionState +from snapred.backend.dao.indexing.Versioning import VERSION_START, VersionState from snapred.backend.dao.ingredients import GroceryListItem from snapred.backend.dao.state import DetectorState from snapred.backend.dao.WorkspaceMetadata import WorkspaceMetadata @@ -338,7 +338,7 @@ def createDiffcalTableWorkspaceName( NOTE: This method will IGNORE runNumber if the provided version is VersionState.DEFAULT """ wsName = wng.diffCalTable().runNumber(runNumber).version(version).build() - if version == VersionState.DEFAULT: + if version in [VersionState.DEFAULT, VERSION_START]: wsName = wsName = wng.diffCalTable().runNumber("default").version(VersionState.DEFAULT).build() return wsName diff --git a/src/snapred/backend/data/Indexer.py b/src/snapred/backend/data/Indexer.py index 40629d893..a5c7a7d84 100644 --- a/src/snapred/backend/data/Indexer.py +++ b/src/snapred/backend/data/Indexer.py @@ -97,7 +97,7 @@ def readDirectoryList(self): version = str(fname).split("_")[-1] # Warning: order matters here: # check VersionState.DEFAULT _before_ the `isdigit` check. - if version == VersionState.DEFAULT: + if version in [VersionState.DEFAULT, self.defaultVersion()]: version = self.defaultVersion() elif version.isdigit(): version = int(version) @@ -173,7 +173,7 @@ def latestApplicableVersion(self, runNumber: str) -> int: elif len(relevantEntries) == 1: version = relevantEntries[0].version else: - if VersionState.DEFAULT in self.index: + if self.defaultVersion() in self.index: relevantEntries.remove(self.index[self.defaultVersion()]) version = relevantEntries[-1].version return version @@ -272,7 +272,7 @@ def getLatestApplicablePath(self, runNumber: str) -> Path: def createIndexEntry(self, *, version, **other_arguments): return IndexEntry( - version=version, + version=self._flattenVersion(version), **other_arguments, ) @@ -311,7 +311,7 @@ def addIndexEntry(self, entry: IndexEntry): def createRecord(self, *, version, **other_arguments): record = RECORD_TYPE[self.indexerType]( - version=version, + version=self._flattenVersion(version), **other_arguments, ) record.calculationParameters.version = record.version @@ -349,15 +349,24 @@ def _flattenVersion(self, version: Version): elif isinstance(version, int): return version else: + if version is None: + raise ValueError("Version must be specified," "likely no available versions found during lookup.") raise ValueError(f"Version must be an int or {VersionState.values()}") + def versionExists(self, version: Version): + return self._flattenVersion(version) in self.index + def writeNewRecord(self, record: Record, entry: IndexEntry): """ Coupled write of a record and an index entry. As required for new records. """ - if record.version in self.index: + if self.versionExists(record.version): raise ValueError(f"Version {record.version} already exists in index, please write a new version.") + + if entry.appliesTo is None: + entry.appliesTo = ">=" + record.runNumber + self.addIndexEntry(entry) # make sure they flatten to the same value. record.version = entry.version @@ -370,7 +379,7 @@ def writeRecord(self, record: Record): """ record.version = self._flattenVersion(record.version) - if record.version not in self.index: + if not self.versionExists(record.version): raise ValueError(f"Version {record.version} not found in index, please write an index entry first.") filePath = self.recordPath(record.version) @@ -384,7 +393,7 @@ def writeRecord(self, record: Record): def createParameters(self, *, version, **other_arguments) -> CalculationParameters: return PARAMS_TYPE[self.indexerType]( - version=version, + version=self._flattenVersion(version), **other_arguments, ) diff --git a/src/snapred/backend/data/LocalDataService.py b/src/snapred/backend/data/LocalDataService.py index 868000053..50f5739f0 100644 --- a/src/snapred/backend/data/LocalDataService.py +++ b/src/snapred/backend/data/LocalDataService.py @@ -446,7 +446,7 @@ def _statePathForWorkflow(self, stateId: str, useLiteMode: bool, indexerType: In raise NotImplementedError(f"Indexer of type {indexerType} is not supported by the LocalDataService") return path - @lru_cache + # @lru_cache def _indexer(self, stateId: str, useLiteMode: bool, indexerType: IndexerType): path = self._statePathForWorkflow(stateId, useLiteMode, indexerType) return Indexer(indexerType=indexerType, directory=path) @@ -488,11 +488,11 @@ def createNormalizationRecord(self, request: CreateNormalizationRecordRequest) - return indexer.createRecord(**request.model_dump()) def normalizationExists(self, runId: str, useLiteMode: bool) -> bool: - version = self.normalizationIndexer(runId, useLiteMode).currentVersion() + version = self.normalizationIndexer(runId, useLiteMode).getLatestApplicableVersion(runId) return version is not None @validate_call - def readNormalizationRecord(self, runId: str, useLiteMode: bool, version: Optional[int] = VersionState.LATEST): + def readNormalizationRecord(self, runId: str, useLiteMode: bool, version: Optional[Version] = VersionState.LATEST): """ Will return a normalization record for the given version. If no version given, will choose the latest applicable version from the index. @@ -500,9 +500,12 @@ def readNormalizationRecord(self, runId: str, useLiteMode: bool, version: Option indexer = self.normalizationIndexer(runId, useLiteMode) if version is VersionState.LATEST: version = indexer.latestApplicableVersion(runId) + record = None + if version is not None: + record = indexer.readRecord(version) logger.info(indexer.index) logger.info(f"latest applicable version: {version} for runId: {runId} ") - return indexer.readRecord(version) + return record def writeNormalizationRecord(self, record: NormalizationRecord, entry: Optional[IndexEntry] = None): """ @@ -547,22 +550,25 @@ def createCalibrationRecord(self, request: CreateCalibrationRecordRequest) -> Ca return indexer.createRecord(**request.model_dump()) def calibrationExists(self, runId: str, useLiteMode: bool) -> bool: - version = self.calibrationIndexer(runId, useLiteMode).currentVersion() + version = self.calibrationIndexer(runId, useLiteMode).getLatestApplicableVersion(runId) return version is not None @validate_call - def readCalibrationRecord(self, runId: str, useLiteMode: bool, version: Optional[int] = VersionState.LATEST): + def readCalibrationRecord(self, runId: str, useLiteMode: bool, version: Version = VersionState.LATEST): """ Will return a calibration record for the given version. If no version given, will choose the latest applicable version from the index. """ indexer = self.calibrationIndexer(runId, useLiteMode) if version is VersionState.LATEST: - # NOTE Indexer.readRecord defaults to currentVersion version = indexer.latestApplicableVersion(runId) - return indexer.readRecord(version) + record = None + if version is not None: + record = indexer.readRecord(version) + + return record - def writeCalibrationRecord(self, record: CalibrationRecord): + def writeCalibrationRecord(self, record: CalibrationRecord, entry: Optional[IndexEntry] = None): """ Persists a `CalibrationRecord` to either a new version folder, or overwrite a specific version. Record must be set with correct version. @@ -570,8 +576,12 @@ def writeCalibrationRecord(self, record: CalibrationRecord): """ indexer = self.calibrationIndexer(record.runNumber, record.useLiteMode) - # write record to file - indexer.writeRecord(record) + if entry is None: + # write record to file + indexer.writeRecord(record) + else: + # write record to file + indexer.writeNewRecord(record, entry) # separately write the calibration state indexer.writeParameters(record.calculationParameters) @@ -776,9 +786,13 @@ def readCalibrationState(self, runId: str, useLiteMode: bool, version: Optional[ indexer = self.calibrationIndexer(runId, useLiteMode) # NOTE if we prefer latest version in index, uncomment below + parameters = None if version is VersionState.LATEST: version = indexer.latestApplicableVersion(runId) - return indexer.readParameters(version) + if version is not None: + parameters = indexer.readParameters(version) + + return parameters @validate_call def readNormalizationState(self, runId: str, useLiteMode: bool, version: Optional[Version] = VersionState.LATEST): diff --git a/src/snapred/backend/service/CalibrationService.py b/src/snapred/backend/service/CalibrationService.py index a0ed0098b..34ae713e5 100644 --- a/src/snapred/backend/service/CalibrationService.py +++ b/src/snapred/backend/service/CalibrationService.py @@ -347,8 +347,7 @@ def save(self, request: CalibrationExportRequest): record.workspaces = savedWorkspaces # save the objects at the indicated version - self.saveCalibrationToIndex(entry) - self.dataExportService.exportCalibrationRecord(record) + self.dataExportService.exportCalibrationRecord(record, entry) self.dataExportService.exportCalibrationWorkspaces(record) @FromString diff --git a/src/snapred/backend/service/NormalizationService.py b/src/snapred/backend/service/NormalizationService.py index 35b436172..41a3ac7d8 100644 --- a/src/snapred/backend/service/NormalizationService.py +++ b/src/snapred/backend/service/NormalizationService.py @@ -299,9 +299,8 @@ def saveNormalization(self, request: NormalizationExportRequest): record.workspaceNames = savedWorkspaces # save the objects at the indicated version - self.dataExportService.exportNormalizationRecord(record) + self.dataExportService.exportNormalizationRecord(record, entry) self.dataExportService.exportNormalizationWorkspaces(record) - self.saveNormalizationToIndex(entry) def saveNormalizationToIndex(self, entry: IndexEntry): """ diff --git a/src/snapred/backend/service/ReductionService.py b/src/snapred/backend/service/ReductionService.py index b7b8617f1..a3c11afba 100644 --- a/src/snapred/backend/service/ReductionService.py +++ b/src/snapred/backend/service/ReductionService.py @@ -401,15 +401,15 @@ def fetchReductionGroceries(self, request: ReductionRequest) -> Dict[str, Any]: # gather the input workspace and the diffcal table self.groceryClerk.name("inputWorkspace").neutron(request.runNumber).useLiteMode(request.useLiteMode).add() - if calVersion: + if calVersion is not None: self.groceryClerk.name("diffcalWorkspace").diffcal_table(request.runNumber, calVersion).useLiteMode( request.useLiteMode ).add() - if int(normVersion) >= int(request.runNumber): - raise RuntimeError(f"Normalization version {normVersion} is not valid for run number {request.run}.") + if normVersion is not None: + if int(normVersion) >= int(request.runNumber): + raise RuntimeError(f"Normalization version {normVersion} is not valid for run number {request.run}.") - if normVersion: self.groceryClerk.name("normalizationWorkspace").normalization(request.runNumber, normVersion).useLiteMode( request.useLiteMode ).add() diff --git a/src/snapred/backend/service/SousChef.py b/src/snapred/backend/service/SousChef.py index 768ec7258..e1ca1a5c1 100644 --- a/src/snapred/backend/service/SousChef.py +++ b/src/snapred/backend/service/SousChef.py @@ -205,6 +205,8 @@ def _pullCalibrationRecordFFI( self, ingredients: FarmFreshIngredients, ) -> FarmFreshIngredients: + if ingredients.versions.calibration is None: + raise ValueError("Calibration version must be specified") calibrationRecord = self.dataFactoryService.getCalibrationRecord( ingredients.runNumber, ingredients.useLiteMode, ingredients.versions.calibration ) diff --git a/src/snapred/resources/application.yml b/src/snapred/resources/application.yml index 8d6c5ba56..01d714ac6 100644 --- a/src/snapred/resources/application.yml +++ b/src/snapred/resources/application.yml @@ -181,7 +181,7 @@ version: friendlyName: error: "uninitialized" # alphanumeric default: 0 # alphanumeric - start: 1 # MUST be nonnegative integer + start: 0 # MUST be nonnegative integer cis_mode: false diff --git a/src/snapred/ui/workflow/DiffCalWorkflow.py b/src/snapred/ui/workflow/DiffCalWorkflow.py index 00e55f8f4..1447577f5 100644 --- a/src/snapred/ui/workflow/DiffCalWorkflow.py +++ b/src/snapred/ui/workflow/DiffCalWorkflow.py @@ -6,7 +6,7 @@ from snapred.backend.dao import RunConfig from snapred.backend.dao.indexing.IndexEntry import IndexEntry -from snapred.backend.dao.indexing.Versioning import VersionedObject +from snapred.backend.dao.indexing.Versioning import VersionedObject, VersionState from snapred.backend.dao.Limit import Pair from snapred.backend.dao.request import ( CalibrationAssessmentRequest, @@ -479,10 +479,10 @@ def _resetSaveView(self): def _saveCalibration(self, workflowPresenter): view = workflowPresenter.widget.tabView runNumber = view.fieldRunNumber.get() - version = view.fieldVersion.get(None) + version = view.fieldVersion.get(VersionState.NEXT) appliesTo = view.fieldAppliesTo.get(f">={runNumber}") # validate the version number - version = VersionedObject.parseVersion(version, exclude_default=True) + version = VersionedObject(version=version).version # validate appliesTo field appliesTo = IndexEntry.appliesToFormatChecker(appliesTo) diff --git a/src/snapred/ui/workflow/NormalizationWorkflow.py b/src/snapred/ui/workflow/NormalizationWorkflow.py index 77d117075..16dab2093 100644 --- a/src/snapred/ui/workflow/NormalizationWorkflow.py +++ b/src/snapred/ui/workflow/NormalizationWorkflow.py @@ -1,7 +1,7 @@ from qtpy.QtCore import Slot from snapred.backend.dao.indexing.IndexEntry import IndexEntry -from snapred.backend.dao.indexing.Versioning import VersionedObject +from snapred.backend.dao.indexing.Versioning import VersionedObject, VersionState from snapred.backend.dao.request import ( CalibrationWritePermissionsRequest, CreateIndexEntryRequest, @@ -210,10 +210,10 @@ def _specifyNormalization(self, workflowPresenter): # noqa: ARG002 def _saveNormalization(self, workflowPresenter): view = workflowPresenter.widget.tabView runNumber = view.fieldRunNumber.get() - version = view.fieldVersion.get() + version = view.fieldVersion.get(VersionState.NEXT) appliesTo = view.fieldAppliesTo.get(f">={self.calibrationRunNumber}") # validate version number - version = VersionedObject.parseVersion(version, exclude_default=True) + version = VersionedObject(version=version).version # validate appliesTo field appliesTo = IndexEntry.appliesToFormatChecker(appliesTo)