Skip to content

feat: update tiled node insertion structure - #1669

Open
ZohebShaikh wants to merge 3 commits into
tiled-updatefrom
tiled-path-change
Open

ZohebShaikh wants to merge 3 commits into
tiled-updatefrom
tiled-path-change

Conversation

@ZohebShaikh

Copy link
Copy Markdown
Contributor

Stack created with GitHub Stacks CLIGive Feedback 💬

@ZohebShaikh
ZohebShaikh added this pull request to stack #1670 September 11, 2026 10:44
@codecov

codecov Bot commented Sep 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.39%. Comparing base (028eef4) to head (5b5bb6f).

Additional details and impacted files
@@               Coverage Diff                @@
##           tiled-update    #1669      +/-   ##
================================================
+ Coverage         96.34%   96.39%   +0.05%     
================================================
  Files                46       46              
  Lines              3665     3690      +25     
================================================
+ Hits               3531     3557      +26     
+ Misses              134      133       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ZohebShaikh
ZohebShaikh force-pushed the tiled-path-change branch 2 times, most recently from 4414034 to abcd7ff Compare September 11, 2026 14:45
diamond-policies:
service: ghcr
resource: ghcr.io/diamondlightsource/authz-policy:0.0.24
resource: ghcr.io/zohebshaikh/authz-policy:0.0.25-alpha

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR here

@ZohebShaikh
ZohebShaikh force-pushed the tiled-path-change branch 5 times, most recently from a0df79b to a5635b9 Compare September 11, 2026 15:49
@ZohebShaikh
ZohebShaikh marked this pull request as ready for review September 16, 2026 08:10
@ZohebShaikh
ZohebShaikh requested a review from a team as a code owner September 16, 2026 08:10

@tpoliaw tpoliaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really know how the authorization stuff for tiled works but it looks plausible.

The amount of stuff going on in the begin_task is starting to look a bit suspect though. Can be a later PR but is it possible offload some of it to the tiled writer or client?

headers=pass_through_headers,
)

if task.task_id is not None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if we get this far and there is no task_id, nothing is going to work. It would be better to remove this check and the one on line 270 and replace them with

if not task.task_id:
    raise ValueError("No task_id provided")

and then we wouldn't have to worry about it for the rest of the function.


INSTRUMENT_SESSION_RE = re.compile(r"^[a-z]{2}(?P<proposal>\d+)-(?P<visit>\d+)$")
# Full proposal code (e.g. "cm12345" from "cm12345-1") for building tiled node paths.
TILED_PROPOSAL_RE = re.compile(r"^(?P<proposal>[a-z]{2}\d+)-\d+$")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we combine this with the other regex somehow instead of having two that do subtly different things?

Something like ^(?P<proposal>(?P<code>[a-z]{2})(?P<proposal_number>\d+))-(?P<visit>\d+)$ would give us code, proposal, proposal_number and visit so it could be used for both.

level_access_tags = [
[json.dumps({"beamline": instrument})],
[json.dumps({"beamline": instrument, "proposal": proposal})],
[json.dumps(session_blob)],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think having access_blob as its own function makes sense any more. It should either be updated to return all three of these, or the proposal/visit/beamline line should be inlined here.

It's also going from dict -> json -> dict -> json where it probably shouldn't

# access policy expects a container to be tagged with.
session_blob = json.loads(access_blob(instrument_session, instrument))
level_access_tags = [
[json.dumps({"beamline": instrument})],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be a bit late at this stage but why are we using beamline instead of instrument?

Comment on lines +242 to +247
if (
e.response.status_code == status.HTTP_409_CONFLICT
): # already exists
...
else:
raise

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (
e.response.status_code == status.HTTP_409_CONFLICT
): # already exists
...
else:
raise
if response.status_code != status.HTTP_409_CONFLICT:
raise
# else: node already exists, continue

[json.dumps({"beamline": instrument, "proposal": proposal})],
[json.dumps(session_blob)],
]
for key, access_tags in zip(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could level_access_tags be a dict instead of having to immediately zip the list with something else?

assert stream_resource["uri"] == f"file://localhost/tmp/adsim-{scan_id}-det.h5"

tiled_url = f"http://localhost:8407/api/v1/metadata/{start_doc['uid']}"
proposal = TILED_PROPOSAL_RE.match(start_doc["instrument_session"])["proposal"] # type: ignore

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this type ignore still needed?

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.

2 participants