Skip to content

Conversation

GianlucaFicarelli
Copy link
Collaborator

@GianlucaFicarelli GianlucaFicarelli commented Aug 6, 2025

Fix #292

@GianlucaFicarelli GianlucaFicarelli self-assigned this Aug 6, 2025
@GianlucaFicarelli GianlucaFicarelli changed the title Add circuit hierarchy enpoint Add circuit hierarchy endpoint Aug 6, 2025
tags=["hierarchy"],
)

router.get("/circuit")(app.service.hierarchy.read_circuit_hierarchy)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note: we can decide for a different endpoint name, I don't have a string opinion.

  • /hierarchy/circuit: it can be useful if we think we can reuse the same logic for other entities
  • /circuit-hierarchy: it's specific for circuits
  • ...

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't have a strong preference, I usually like things organized like circuit/hierarchy, but that's just how my brain works.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

/circuit/hierarchy could work for me as well, however it should be added before /circuit/{uuid}, because FastAPI evaluates routes in the order they are added.

Copy link
Contributor

@eleftherioszisis eleftherioszisis Aug 6, 2025

Choose a reason for hiding this comment

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

To me as long as there is either a prefix or postfix for circuit I am fine. /circuit/hierarchy seems more intuitive but I don't have a too strong of an opinion. From the sdk side it doesn't really matter because there will be a dedicated method that will construct the path in either way.

It would be nice if we could eventually reuse the construction of the hierarchy for other entities that have derivations too and have some sort of a common query function as we have for read/create

Copy link
Collaborator Author

@GianlucaFicarelli GianlucaFicarelli Aug 6, 2025

Choose a reason for hiding this comment

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

If we change the route from /hierarchy/circuit to /circuit/hierarchy I can move the endpoint definition in the to routers/circuit.py, but keep service/hierarchy.py, as the logic isn't very specific to the circuit.

It can remain generic as long as we don't add attributes that are specific to the circuit, or we'll need different schemas for the response.

Copy link
Collaborator

@mgeplf mgeplf left a comment

Choose a reason for hiding this comment

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

LGTM, but I'm not the end user, so I'll let Bilal have a look.

Very clean.

@bilalesi
Copy link
Contributor

LGTM, thanks @GianlucaFicarelli

…_enpoint

* origin/main:
  Add timezone to scientific_artifact.experiment_date (#326)
  Generic entity endpoint (#290)
  Add circuit contributions (#325)
  Bump dependencies (#322)
  Sort dynamic enums (#321)

class HierarchyTree(BaseModel):
derivation_type: DerivationType
data: list[HierarchyNode]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The latest changes take in account what have been discussed and mentioned in this comment:
#292 (comment)

Side notes:

  • derivation_type is now moved at the top level of the response payload, because it's the same for every relation.
  • I added authorized_public and authorized_project_id to the returned entities, because they should make it easier to debug issues with the expected response. We can decide now or later to make them optional to reduce the payload size.
  • I kept parent_id: it's not strictly needed because it's implicit in the tree structure, but it's used when the tree is built so it's just easier to dump the full payload. We can decide now or later to remove it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Unless we remove things now, they will probably be required forever :)
OTOH, we haven't really been too careful about optimizing payloads thus far, so maybe we don't need to start now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I would leave these fields (authorized_public, authorized_project_id and parent_id) unless we see that the payload is too big.
For reference, although it can change, the current ALL_CIRCUITS.json contains 155 circuits and it's around 7.5 MB but it has a lot more information (especially metadata like contributors, organizations, publications...)

Copy link
Collaborator

Choose a reason for hiding this comment

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

yup, makes sense

155 circuits and it's around 7.5 MB

wow; 40k per circuit? nuts

Copy link
Collaborator

@mgeplf mgeplf left a comment

Choose a reason for hiding this comment

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

LGTM, just some small nitpicks. I'll let @bilalesi do the final approval.

@bilalesi
Copy link
Contributor

lgtm, things are more clear now

@GianlucaFicarelli GianlucaFicarelli merged commit 336142e into main Aug 13, 2025
1 check passed
@GianlucaFicarelli GianlucaFicarelli deleted the add_circuit_hierarchy_enpoint branch August 13, 2025 13:32
GianlucaFicarelli added a commit that referenced this pull request Aug 18, 2025
* origin/main:
  Add filter by authorized_public and authorized_project_id (#335)
  Fix legacy attributes (#328)
  Add circuit hierarchy endpoint (#320)
  Remove contribution from publication (#331)
GianlucaFicarelli added a commit that referenced this pull request Aug 21, 2025
* origin/main:
  IonChannelModel inheriting from ScientificArtifact (#300)
  Add external data source and url (#327)
  Add Calibration & Validation activities (#307)
  Update uv and relax uv pinning in Dockerfile (#336)
  Add filter by authorized_public and authorized_project_id (#335)
  Fix legacy attributes (#328)
  Add circuit hierarchy endpoint (#320)
  Remove contribution from publication (#331)
GianlucaFicarelli added a commit that referenced this pull request Aug 28, 2025
…-model

* origin/main:
  Add the ability to filter by name to IonChannelModel (#338)
  IonChannelModel inheriting from ScientificArtifact (#300)
  Add external data source and url (#327)
  Add Calibration & Validation activities (#307)
  Update uv and relax uv pinning in Dockerfile (#336)
  Add filter by authorized_public and authorized_project_id (#335)
  Fix legacy attributes (#328)
  Add circuit hierarchy endpoint (#320)
  Remove contribution from publication (#331)
  Add timezone to scientific_artifact.experiment_date (#326)
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.

Build circuit hierarchy for read_many
4 participants