Skip to content

More annortations in JobGenerator - #883

Merged
tmaeno merged 3 commits into
PanDAWMS:masterfrom
tmaeno:master
Nov 23, 2026
Merged

tmaeno merged 3 commits into
PanDAWMS:masterfrom
tmaeno:master

Conversation

@tmaeno

@tmaeno tmaeno commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

This pull request refines type safety and error handling in the JobGenerator.py module, primarily by updating type annotations for output dataset maps and strengthening checks when retrieving datasets. These changes improve code reliability and make the type expectations clearer throughout the job generation process.

Type annotation improvements:

  • Updated all type hints for outDsMap from dict[int, Any] to dict[int, JediDatasetSpec] in method signatures and local variable declarations, ensuring that only JediDatasetSpec objects are stored and passed around as output datasets. [1] [2] [3] [4]

Error handling enhancements:

  • Strengthened the dataset retrieval logic by checking both the success flag (ds_ok) and whether the returned dataset (tmpDataset) is None, preventing cases where a missing dataset could cause downstream errors. This pattern is now consistently applied in both doGenerate, doGeneratePrePro, and related methods. [1] [2] [3]

tmaeno and others added 3 commits November 23, 2026 12:36
doGenerate and doGeneratePrePro look up the dataset of each output file
with getDatasetWithID_JEDI. The check after each lookup is commented "not
found", but it only tested the success flag. getDatasetWithID_JEDI
returns (True, None) when the row is missing, so the None went into the
dataset map.

Each of the three lookups now reports a missing dataset through the error
path it already had for a failed read, with the same message.

- For the output files of a job, and for the log file of a prepro job, the
  None was passed to convertToJobFileSpec right away. Its AttributeError
  ended in the generic except. The outcome is the same as before, with a
  message that names the dataset.
- For the files of other sites' parallel jobs, the None was used only when
  a job was cloned for several sites. A missing row now fails job
  generation whether or not that happens. The datasets in question are the
  ones getOutputFiles_JEDI has just created the files in.

doGeneratePrePro's store of the dataset no longer needs its
type: ignore[assignment].
doGenerate keeps the output datasets it looks up in outDsMap, keyed by
datasetID, and returns it for cloning jobs. The map was declared
dict[int, Any], so a dataset taken from it was untyped. That includes
tmpDatasetSpec in the output loop, which shares its name with the input
loops. mypy then checked nothing done with those datasets, and the code map
could not tell where the calls on them go.

It is now dict[int, JediDatasetSpec] where it is made, in doGenerate's
return and failure value, and in increaseEventServiceConsumers and
makeJumboJobs, which take it. clonePandaJob and doGeneratePrePro already
used that type. The commit before this one keeps None out of the map.
@tmaeno
tmaeno merged commit c697ab6 into PanDAWMS:master Nov 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant