Revised CalCat API
Compare changes
- Thomas Kluyver authored
src/cal_tools/calcat_interface2.py
0 → 100644
+ 839
− 0
This is based on our discussion last week, but it's still a WIP. In particular, I haven't implemented actually loading the constants yet.
I've tweaked the design slightly: rather than having CalibrationData
subclasses for each detector type, you use CalibrationData.from_conditions()
with a detector specific object like AGIPDConditions
. Jump to the tests to see what this looks like.
Questions:
.select_modules()
and .select_calibrations()
take *args
or a list?
I wonder if this method should throw a
TypeError
if it's not string (or any of the handled types). Also, do we want to define the string time formats supported by CalCat and check for it?We can probably avoid by pushing people towards
datetime
/date
, but I'm afraid of users passing some string wrongly understood by CalCat.@manettim Is there a single point in CalCat that interprets date strings?
I think it's this method in CalCat:
https://git.xfel.eu/ITDM/calibration_catalog/-/blob/develop/app/controllers/api/v2/base_controller.rb#L267-270
The method it's calling seems to allow quite a range of inputs: https://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html#method-i-parse . It's probably not practical to precisely replicate its rules in Python, though we could apply stricter rules.
Rejecting anything besides strings and datetime objects is a good idea, though.
That's correct!
We can implement strict rules on the format if you wish.