Skip to content

PyISPyB integration: add REST implementation, corresponding to current SOAP ISPyB solution#1614

Merged
marcus-oscarsson merged 9 commits into
developfrom
maxiv-soleil-pyispyb-integration
Jul 9, 2026
Merged

PyISPyB integration: add REST implementation, corresponding to current SOAP ISPyB solution#1614
marcus-oscarsson merged 9 commits into
developfrom
maxiv-soleil-pyispyb-integration

Conversation

@dominikatrojanowska

Copy link
Copy Markdown
Contributor

Replace the legacy SOAP-based ISPyB client with a new PyISPyB REST implementation backed by Keycloak token authentication. Introduce PyISPyBDataAdapter and PyISPyBRestClientas abstract, reusable components, removing the old ISPyBAdapter. Add adjustable timeouts, improved error handling, and legacy method compatibility. Update tests to reflect the new REST implementation and handle Max IV specific duo and sdm dependencies gracefully.

@dominikatrojanowska dominikatrojanowska force-pushed the maxiv-soleil-pyispyb-integration branch from fe4edf4 to e9ff884 Compare May 22, 2026 09:28
Comment thread mxcubecore/model/lims_session.py Outdated
Comment thread mxcubecore/model/lims_session.py Outdated
number: str = ""
title: str = ""
name: str = ""
state: str = ""

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What does state mean in this context ?

@dominikatrojanowska dominikatrojanowska May 22, 2026

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.

Proposal can be in closed or open state. Not sure if any other is possible here. At Max IV we are looking only for open proposals: https://github.com/mxcube/mxcubecore/pull/1614/changes#diff-6a47fcd7804afcce43cfdf9b3ce2bb8721e74ea9ede437f049b53f1f376e2d67R44

@marcus-oscarsson marcus-oscarsson May 22, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see, I would somehow say that get_beamline_proposals should not at all return proposals that are closed then ? Like this you would not need state

@dominikatrojanowska dominikatrojanowska May 22, 2026

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.

That's another application endpoint (PyISPyB) that delivers proposals 🤔 I guess in other use cases (app's inner requests for example) it may be required to get all proposals regardless of their state. I can implement or ask about new endpoint for our purpose with the default filtering to get only those in Open state. Let me know :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe you can just filter on retrieval so that you don't need state once everything is retrieved ? There is no need to pass it around if its not used.

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.

ok, removed this state field

Comment thread mxcubecore/HardwareObjects/abstract/PyISPyBDataAdapter.py Outdated
Comment thread mxcubecore/HardwareObjects/MAXIV/ISPyBLims.py Outdated
@marcus-oscarsson

Copy link
Copy Markdown
Member

Looks good overall, just a few comments to consider

Comment thread mxcubecore/HardwareObjects/abstract/PyISPyBDataAdapter.py Outdated
Comment thread mxcubecore/HardwareObjects/abstract/PyISPyBDataAdapter.py Outdated
Comment thread mxcubecore/HardwareObjects/abstract/PyISPyBRestClient.py Outdated
Comment thread ruff.toml Outdated
@dominikatrojanowska dominikatrojanowska changed the title Refactor ISPyB integration: replace SOAP client with PyISPyB REST client PyISPyB integration: add REST implementation, corresponding to current SOAP ISPyB solution Jun 3, 2026
@dominikatrojanowska dominikatrojanowska force-pushed the maxiv-soleil-pyispyb-integration branch from 7ee0fdd to df9b3b5 Compare June 3, 2026 10:04
Comment thread mxcubecore/HardwareObjects/abstract/PyISPyBDataAdapter.py Outdated
@dominikatrojanowska dominikatrojanowska force-pushed the maxiv-soleil-pyispyb-integration branch 2 times, most recently from fe9bbff to e9a0e1e Compare June 19, 2026 16:15
)

@staticmethod
def __to_sample(sample_data: dict) -> dict:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

There is nothing wrong with it - but why are you using double_underscore? As I understand it, that is specific for functions that cannot be called even from subclasses, whereas the normal syntax for private functions is a single underscore.

@dominikatrojanowska dominikatrojanowska Jul 8, 2026

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.

That's quite right about _private and __protected members. Actually there is something called name mangling to access even the protected but generally it should be avoided.

This implementation bases on ISPyBDataAdapter and originally these helpers are protected members. I've just find no reason to change that.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Fair enough. I have a suspicion that in many cases (possibly including this one) people are using protected members without justification, but it certainly makes more sense to leave things as they are and do the nitpicking and clean-up later (if at all).

@dominikatrojanowska dominikatrojanowska force-pushed the maxiv-soleil-pyispyb-integration branch from 0b7c7b5 to dc99421 Compare July 8, 2026 06:47
@marcus-oscarsson

Copy link
Copy Markdown
Member

Looks good as far as I can see, not sure if there are still changes requested @mockoocy. Otherwise I think we can rebase and merge

dominikatrojanowska and others added 9 commits July 9, 2026 14:25
Replace the legacy SOAP-based ISPyB client with a new PyISPyB REST implementation
backed by Keycloak token authentication. Introduce ``PyISPyBDataAdapter`` and
``PyISPyBRestClient``as abstract, reusable components, removing the old ``ISPyBAdapter``.
Add adjustable timeouts, improved error handling, and legacy method compatibility.
Update tests to reflect the new REST implementation and handle Max IV specific  ``duo``
and ``sdm`` dependencies gracefully.
Replace the legacy SOAP-based ISPyB client with a new PyISPyB REST implementation
backed by Keycloak token authentication. Introduce ``PyISPyBDataAdapter`` and
``PyISPyBRestClient``as abstract, reusable components, removing the old ``ISPyBAdapter``.
Add adjustable timeouts, improved error handling, and legacy method compatibility.
Update tests to reflect the new REST implementation and handle Max IV specific  ``duo``
and ``sdm`` dependencies gracefully.
Implement PyISPyB token refresh and implement integration tests

- Add refresh token support to REST client
- Add mocked API tests for PyISPyB client and adapter methods
- Align adapter endpoints with PyISPyB API

Co-authored-by: dominikatrojanowska <154609837+dominikatrojanowska@users.noreply.github.com>
Co-authored-by: Mohsen Dahesh <mohsen.dahesh@synchrotron-soleil.fr>
@marcus-oscarsson marcus-oscarsson force-pushed the maxiv-soleil-pyispyb-integration branch from dc99421 to fa49625 Compare July 9, 2026 12:25
@marcus-oscarsson marcus-oscarsson merged commit 6cbf2ed into develop Jul 9, 2026
9 checks passed
@marcus-oscarsson marcus-oscarsson deleted the maxiv-soleil-pyispyb-integration branch July 9, 2026 12:43
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.

5 participants