Draft: Resolve "Merge fork done for MXCuBE with main branch"
Closes #36
@denolf @beteva I took from the mxcube_fixed code and reworked some parts based on your comments.
For me, as a developer who wants to use this, I would like this library to abstract how things are done and provide easy access to the actions I can perform on the catalog, logbook, and sample tracking... The current constructor (that is left for compatibility) is rather complicated with more than 10 optional parameters that are difficult to figure out what they are used for and how to combine them.
Class diagram
graph TD
A[ICATClient] -->|has| B(Catalogue)
A[ICATClient] -->|has| C(Tracking)
B --> |uses| D(ICAT+)
B --> |uses| E(ingester Client)
C --> |uses| D(ICAT+)
MXCuBE Status
The approach used on MXCuBE, with room for improvement, is:
# Initialize ICAT client and catalogue
self.icatClient = IcatClient(
catalogue_url=self.url,
tracking_url=self.url,
metadata_urls=["bcu-mq-01:61613"],
catalogue_queues=["bcu-mq-01:61613"],
)
The code above will instantiate the catalog and the sample tracking part. As I said I would simplify even more the constructor.
And icatclient contains two objects that are used by MXCuBE: catalogue
and tracking
. These two object will encapsulate the operation around the catalogue (investigations, datasets, samples, etc...) and the tracking (shipping, parcels, containers, etc..).
It needs to be authenticated/authorized that is done in the main class and should return a session object:
self.icat_session: ICATSession = self.icatClient.do_log_in(password)
Catalogue
The use of the catalogue is limited to:
self.catalogue.reschedule_investigation(session_id)
self.catalogue.get_investigations_by(session_id, ...)
Note: It is important to realize that the developer does not need to know that the reschedule_investigation
is done via ingester and the get_investigation_by
by icat+. This is in my opinion the good approach that helps to use this library without the need to know the details.
Sample Tracking
The use of the tracking is limited to:
parcels = self.tracking.get_parcels_by(session_id)
Ingestion
The ingestion procedure has not been changed and remains:
icatClient.store_dataset(
beamline=beamline,
proposal=proposal,
dataset=dataset_name,
path=str(directory),
metadata=metadata,
)