Conversation
In this case, make the Fink broker appear in TOMToolkit's list of DataServices, when tom_fink is INSTALLED. TOMToolkit will look for certain methods in the AppConfig of a TOM's INSTALLED_APPS to ask the App how to integrate it into the TOM. This makes apps more self contained and reduces app-specific configuration data in settings.py.
This is part of the "DataServices refactor" of the Fink broker interface.
- minimal form changes: remove GenericQueryForm.common_layout
(it is replaced by layout in the BaseQueryForm)
- the FinkBroker has been removed
- FinkBroker.to_generic_alert and FinkBroker.to_target functionality
condensed into create_target_from_query
- FinkerBroker.fetch_alerts is now FinkDataService._fetch_alerts
and FinkDataServic.query_service just calls _fetch_alerts.
- minimal form changes: remove GenericQueryForm.common_layout
(it is replaced by layout in the BaseQueryForm)
- the FinkBroker has been removed
- FinkBroker.to_generic_alert and FinkBroker.to_target functionality
condensed into create_target_from_query
- FinkerBroker.fetch_alerts is now FinkDataService._fetch_alerts
and FinkDataServic.query_service just calls _fetch_alerts.
condense query results in to structure suitable for presenting in the selectable "create target" table.
The target table row dictionary was updated to be appropriate for one-target-one-row. These changes follow from that and use the appropriate dict keys to get the data to create the target.
Setting up these DataService subclass properties in this way allows the base class to display this info on the RunQueryView, etc.
...using the DataService base class methods and compatibly-written partials.
...by implementing query_photometry() method
The data is already in memory (in the response JSON payload). So, there's not advantage to converting it to an Iterator. Other refactor: group target method together and photometry methods togeter.
|
The latest commits implement Photometry updating and divide the Form into Simple and Advanced using the DataSerivce base class-provided mechanisms. |
jchate6
left a comment
There was a problem hiding this comment.
Also, the README needs to be updated.
Let me know if you want to go through this, or have me make these changes.
There was a problem hiding this comment.
Should probably actually have some tests.
|
|
||
| class FinkDataService(DataService): | ||
| """ | ||
| This is an Example Data Service with the minimum required |
|
|
||
| def build_query_parameters(self, parameters, **kwargs): | ||
| """ | ||
| Use this function to convert the form results into the query parameters understood |
| self.query_parameters = parameters | ||
| return self.query_parameters | ||
|
|
||
| def _fetch_alerts(self, parameters: dict) -> Iterator: |
There was a problem hiding this comment.
This function effectively ignores the point of having a build_query_parameters. You are including both the functionality of translating form fields into fink-readable parameters (class_name, n_alert = parameters["classsearch"].split(",")) and the submission of a valid request to fink.
This makes this more difficult to test and maintain.
| "stopdate": end, | ||
| }, | ||
| ) | ||
| elif len(parameters["ssosearch"].strip()) > 0: |
There was a problem hiding this comment.
If this functionality isn't working, it should be (temporarily) removed from the query form and this method.
| :param self: Description | ||
| :param target_result: Dict of Target data for selected Target | ||
| :type target_result: Dict[str, Any] | ||
| :param kwargs: Description |
| """ | ||
|
|
||
| # extract values from query target_result and create Target | ||
| # NOTE: use constructor, not get_or_create, CreateTargetFromQueryView will save the Target |
There was a problem hiding this comment.
This is now in to_target to keep it out of the view and give the data service access.
| # search among the target's aliases for something that starts with 'ZTF' | ||
| ztf_aliases = target.aliases.filter(name__startswith='ZTF').order_by('-created') | ||
| if not ztf_aliases.exists(): | ||
| raise ValueError( |
There was a problem hiding this comment.
this should use QueryServiceError imported from tom_dataservices.dataservices
I'll add a note about this to the basic docs.
| # Photometry | ||
| # | ||
|
|
||
| def query_photometry(self, query_parameters, **kwargs): |
There was a problem hiding this comment.
A lot of your comments in this section would be better captured in the doc string.
| target=target, | ||
| timestamp=timestamp, | ||
| data_type=data_type, | ||
| source_name='Fink', |
There was a problem hiding this comment.
Use self.name for consistency.
Adds
FinkDataServiceclass; deprecatesFinkBrokerMy tests are passing with
poetry run python tom_fink/tests/run_tests.pyand a local, but un alteredtom_base(dev).