7 - API (feat): Unify Proposal Number#233
Draft
RobertRosca wants to merge 9 commits into
Draft
Conversation
Member
|
We might have to get ready for a bit more generalization. From the ongoing Petra III integration, it seems that they have proposals as strings, here: https://github.com/European-XFEL/DAMNIT/blob/bb53ce207593fff57c41716f8c4c435cee271e75/damnit/ctxsupport/find_beamtime.py#L7 |
CammilleCC
reviewed
Jul 13, 2026
| lint = [ | ||
| "pyright>=1.1.406", | ||
| "ruff>=0.7", | ||
| "ty>=0.0.42", |
Member
There was a problem hiding this comment.
Why do we use pyright AND ty? Might make more sense to choose one over the other. Also please include the chosen type checker in the CI and pre-commit.
RobertRosca
force-pushed
the
refactor/remove-global-state
branch
from
July 17, 2026 06:20
c90b2c7 to
afef36c
Compare
RobertRosca
force-pushed
the
feat/unify-proposal-number
branch
from
July 17, 2026 06:20
3512097 to
71ac1a4
Compare
RobertRosca
force-pushed
the
refactor/remove-global-state
branch
from
July 17, 2026 06:21
afef36c to
102d22a
Compare
RobertRosca
force-pushed
the
feat/unify-proposal-number
branch
2 times, most recently
from
July 17, 2026 08:40
5876528 to
2e7dc44
Compare
RobertRosca
force-pushed
the
refactor/remove-global-state
branch
from
July 17, 2026 08:40
102d22a to
3dfd6d2
Compare
RobertRosca
force-pushed
the
feat/unify-proposal-number
branch
from
July 17, 2026 09:09
2e7dc44 to
9dd16b1
Compare
RobertRosca
force-pushed
the
refactor/remove-global-state
branch
from
July 17, 2026 09:11
0873ce9 to
dd5d976
Compare
RobertRosca
force-pushed
the
feat/unify-proposal-number
branch
from
July 17, 2026 09:11
9dd16b1 to
5358df4
Compare
RobertRosca
force-pushed
the
refactor/remove-global-state
branch
from
July 17, 2026 09:12
dd5d976 to
1d7fdf0
Compare
RobertRosca
force-pushed
the
feat/unify-proposal-number
branch
from
July 17, 2026 09:12
5358df4 to
44d3d84
Compare
RobertRosca
force-pushed
the
refactor/remove-global-state
branch
from
July 17, 2026 09:12
1d7fdf0 to
bd160c7
Compare
RobertRosca
force-pushed
the
feat/unify-proposal-number
branch
2 times, most recently
from
July 17, 2026 10:46
87581d5 to
f7960cc
Compare
RobertRosca
force-pushed
the
refactor/remove-global-state
branch
from
July 17, 2026 10:46
bd160c7 to
15f9109
Compare
RobertRosca
force-pushed
the
feat/unify-proposal-number
branch
from
July 17, 2026 11:01
f7960cc to
f77a5ad
Compare
RobertRosca
force-pushed
the
refactor/remove-global-state
branch
from
July 17, 2026 11:01
15f9109 to
5c8c396
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR no. 7 of the big refactor.
Proposal numbers are kinda confusing throughout as they are untyped
str/ints which are used throughout the code for e.g. GraphQL input, filesystem paths, keys, etc..., all of which currently does validation/formatting ad hoc wherever needed.This makes it hard to hard what a 'proposal number' is or what it's intended to be, especially with strings that colud be one of
'1234','001243','p001243','p1234'.This PR tries to help with this by adding one
ProposalNumbervalue type (plus a matchingProposalNoGraphQL scalar) which is then used across the slices. Adds ADR-004 for the reasoning.Details
ProposalNumber+ProposalNoProposalNumber(inshared/models.py) is a pureintsubclass that:p{n:06d}form via__str__(e.g.p001234)This replaces the old
Annotated[int, Field(...)]alias, and drops the duplicateProposalIdalias that was the same thing under a different name.ProposalNois the strawberry scalar wrapping it (serialises to a plain int), so the value type is used at the graphql edge too.One gotcha worth calling out: since
str(proposal)now givesp001234rather than1234, anywhere that built a string from the number needed a look - the MyMdC client now formats it as an integer explicitly when building API URLs, otherwise thep-prefixed form would leak into the requests.TBH I'm not set on this design, was just curious about how well a weird custom
intsubclass would work for this. A saner and clearer alternative would be not screwing with__str__for the subclass and instead adding some explicit.as_str()method which returns the prefixed/padded proposal number string.Path resolution
get_damnit_pathnow raisesProposalNotFoundError(ADR-001) instead of a bareRuntimeErrorwhen a proposal directory can't be found.ADR-004 is included here but it's only half-landed (the usual pattern by now): it describes both the pure value type and an injectable
ProposalPathLocatorthat owns the slow GPFS number-to-directory resolution behind a swappable seam. Only the value type half is in this branch - the locator (async resolution, off-event-loop timeouts,GPFS vs fixed implementations) is a later branch. Path resolution still lives in
get_damnit_pathreading settings for now.ty
This branch adds
tyto thelintgroup since I... accidentally added it.Tests
test_models.pycoversProposalNumbervalidation and formattingProposalNoscalar rejection and the path-not-found caseschema.graphql) is updated for the new scalarStack created with GitHub Stacks CLI • Give Feedback 💬