Uploaded image for project: 'Data Management'
  1. Data Management
  2. DM-15474

Implement HTTP PUT for metrics and specifications resources

    XMLWordPrintable

    Details

    • Type: Story
    • Status: Done
    • Resolution: Done
    • Fix Version/s: None
    • Component/s: squash
    • Labels:
      None

      Description

      This is required in order to update metric definitions and specifications using the SQuaSH REST API.

        Attachments

          Issue Links

            Activity

            Hide
            afausti Angelo Fausti added a comment -

            Updating a metric definition

            metric = {'name': 'validate_drp.PA1',
             'description': 'The maximum rms of the unresolved source magnitude distribution around the mean value.',
             'unit': 'mmag',
             'tags': ['photometry'],
             'reference': {'doc': 'LPM-17', 'page': 21, 'url': 'http://ls.st/lpm-17'}}
             
            r = requests.put(SQUASH_API_URL + "/metric/{}".format(metric['name']), json=metric, headers=headers)
             
            r.json()
             
            {'name': 'validate_drp.PA1',
             'package': 'validate_drp',
             'display_name': 'PA1',
             'description': 'The maximum rms of the unresolved source magnitude distribution around the mean value.',
             'unit': 'mmag',
             'tags': ['photometry'],
             'reference': {'doc': 'LPM-17', 'url': 'http://ls.st/lpm-17', 'page': 21}}
            

            Show
            afausti Angelo Fausti added a comment - Updating a metric definition metric = {'name': 'validate_drp.PA1', 'description': 'The maximum rms of the unresolved source magnitude distribution around the mean value.', 'unit': 'mmag', 'tags': ['photometry'], 'reference': {'doc': 'LPM-17', 'page': 21, 'url': 'http://ls.st/lpm-17'}}   r = requests.put(SQUASH_API_URL + "/metric/{}".format(metric['name']), json=metric, headers=headers)   r.json()   {'name': 'validate_drp.PA1', 'package': 'validate_drp', 'display_name': 'PA1', 'description': 'The maximum rms of the unresolved source magnitude distribution around the mean value.', 'unit': 'mmag', 'tags': ['photometry'], 'reference': {'doc': 'LPM-17', 'url': 'http://ls.st/lpm-17', 'page': 21}}
            Hide
            afausti Angelo Fausti added a comment - - edited

            Updating a specification

            spec = {'name': 'validate_drp.AD1_design.srd',
             'type': 'threshold',
             'threshold': {'value': 20.0, 'unit': 'marcsec', 'operator': '<='},
             'metadata_query': {},
             'tags': ['design', 'achromatic', 'AD1']}
             
             
            r = requests.put(SQUASH_API_URL + "/spec/{}".format(spec['name']), json=spec, headers=headers)
             
            r.json()
             
            {'name': 'validate_drp.AD1_design.srd',
             'threshold': {'unit': 'marcsec', 'value': 20, 'operator': '<='},
             'tags': ['design', 'achromatic', 'AD1'],
             'metadata_query': {}}
            

            Show
            afausti Angelo Fausti added a comment - - edited Updating a specification spec = {'name': 'validate_drp.AD1_design.srd', 'type': 'threshold', 'threshold': {'value': 20.0, 'unit': 'marcsec', 'operator': '<='}, 'metadata_query': {}, 'tags': ['design', 'achromatic', 'AD1']}     r = requests.put(SQUASH_API_URL + "/spec/{}".format(spec['name']), json=spec, headers=headers)   r.json()   {'name': 'validate_drp.AD1_design.srd', 'threshold': {'unit': 'marcsec', 'value': 20, 'operator': '<='}, 'tags': ['design', 'achromatic', 'AD1'], 'metadata_query': {}}
            Hide
            afausti Angelo Fausti added a comment -

            Implemented the following responses for the PUT method for the metric resource, and similarly for the spec resource.

                      200:
                        description: Metric successfully updated.
                      404:
                        description: Metric not found.
                      401:
                        description: >
                            Authorization Required. Request does not contain a
                            valid access token.
                      500:
                        description: An error occurred updating this metric.
            

            Show
            afausti Angelo Fausti added a comment - Implemented the following responses for the PUT method for the metric resource, and similarly for the spec resource. 200: description: Metric successfully updated. 404: description: Metric not found. 401: description: > Authorization Required. Request does not contain a valid access token. 500: description: An error occurred updating this metric.
            Hide
            afausti Angelo Fausti added a comment - - edited

            Added example notebook to update metrics definitions and specifications:

            https://github.com/lsst-sqre/squash-restful-api/blob/tickets/DM-15474/tests/update_metrics.ipynb

            this can be adapted to automate the update of the SQuaSH production database when changes are merged to verify_metrics. We could also test the update using the SQuaSH demo instance first, when a PR is done in verify_metrics.

            Show
            afausti Angelo Fausti added a comment - - edited Added example notebook to update metrics definitions and specifications: https://github.com/lsst-sqre/squash-restful-api/blob/tickets/DM-15474/tests/update_metrics.ipynb this can be adapted to automate the update of the SQuaSH  production database when changes are merged to  verify_metrics . We could also test the update using the SQuaSH  demo  instance first, when a PR is done in  verify_metrics .
            Show
            afausti Angelo Fausti added a comment - See PR https://github.com/lsst-sqre/squash-restful-api/pull/28
            Hide
            afausti Angelo Fausti added a comment -

            SQuaSH production instance updated see e.g. https://squash-restful-api.lsst.codes/apidocs/

            Show
            afausti Angelo Fausti added a comment - SQuaSH production instance updated see e.g. https://squash-restful-api.lsst.codes/apidocs/

              People

              Assignee:
              afausti Angelo Fausti
              Reporter:
              afausti Angelo Fausti
              Watchers:
              Angelo Fausti
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Jenkins

                  No builds found.