DM-9034: Upload full validate_base blobs, measurement metadata and metric definitions #7
Conversation
- metric definition from validate_drp is uploaded to SQUASH in a separate request - renamed squash.json to job.json
- added blobs and measurement metadata to job json document as expected by SQUASH api/jobs endpoint - shim metrics definition to SQUASH api/metrics endpoint, check for registered metrics and add new metrics only
- --api-url option now expects the SQUASH API root url instead of the jobs endpoint - new function to load registered metrics from SQUASH - upload metrics definition to SQUASH - since metrics definition are uploaded dynamically the --metrics (accepted metrics) option is no longer required
@afausti Looks like you'll need to fix the schema loader import in https://github.com/lsst-sqre/post-qa/blob/tickets/DM-9034/tests/test_cli.py#L12 |
@jonathansick I fixed most of the tests after the changes in this PR, but couldn't make the
I don't understand how do you mock the api to make the json upload test. |
setup.py
Outdated
@@ -18,6 +18,7 @@ def read(filename): | |||
filename) | |||
return open(full_filename, mode='r', encoding='utf-8').read() | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that flake8 behaves differently when I run it locally, this commit can probably be ignored.
@afausti I see the problem with
And now we need to add another
And also add one for the new POST: Note that in I can help you set up all of these mocks, but first we'd need to write down all the expected JSON responses and status codes (I don't know these yet). |
@jonathansick thanks for the guidance in using responses, tests are passing now. |
👏 I'll do a proper review by tomorrow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this looks really great. I like the test coverage and the validation. I have some questions/suggestions, particularly about building a new metric json upload—see line comments.
Also, I know you reverted the change, but in my local environment I'm also seeing an E305 error at setup.py
line 21 (needs two blank lines). Could you try putting this in?
(Looks like there could be an issue with flake8 in the CI)
postqa/jsonshim.py
Outdated
'parameters': metric['parameters'], | ||
# Unit is being stored as part of the metric specification in | ||
# SQuaSH | ||
'unit': vdrp_measurement_doc['unit'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd recommend add a FIXME comment here pointing to DM-9312.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed, thanks for opening the ticket.
"metrics": "http://squash.lsst.codes/dashboard/api/metrics/", | ||
"measurements": "http://squash.lsst.codes/dashboard/api/measurements/", | ||
"datasets": "http://squash.lsst.codes/dashboard/api/datasets/" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GitHub is worried that there's no newline at the end of this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, will fix that.
postqa/jsonshim.py
Outdated
if vdrp_measurement_doc['value'] is None: | ||
continue | ||
if vdrp_measurement_doc['metric']['name'] not in registered_metrics: | ||
metrics.append(shim_metric_definition(vdrp_measurement_doc)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible for a metric to appear multiple times in this list? Like, if there's multiple AM1 measurements in different bands, or multiple measurements against different specifications of a metric, then couldn't we have duplicates here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point. In this implementation the metric name is unique so if there is already an AM1 registered it would not pick another AM1 with a different specification.
I see the problem when a metric, say AD1, depends on another metric specification, in this case AF1. We end up with three measurements of AD1 for each AF1 specification level, right?
I think if a metric has a different parameter or specification it should be named differently, so that we can identify each metric uniquely by its name, or perhaps have another mechanism like a composite primary key based on the metric name and specification? we should think on how to display the metric measurements in this situation too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose to defer this issue to another ticket in order to close this one. Opened https://jira.lsstcorp.org/browse/DM-9330
postqa/jsonshim.py
Outdated
measurements.append(shim_vdrp_measurement(vdrp_measurement_doc)) | ||
|
||
metric_json = metrics |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe rename metrics
to new_metrics_json
from the outset so it's clear these are metric's we'll be uploading and avoids having to rename the variable here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed.
postqa/cli.py
Outdated
upload_json(job_json, api_url=args.api_url, | ||
api_user=args.api_user, api_password=args.api_password) | ||
|
||
upload_json_doc(metric_json, api_url=args.api_url, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we (or should we) skip this upload if there are no new metrics, beyond what's in registered_metrics
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed it does a POST request of an empty json doc, I can improve that.
postqa/cli.py
Outdated
return registered_metrics | ||
|
||
|
||
def upload_json_doc(json_doc, api_url, api_endpoint, api_user=None, api_password=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this line is too long; maybe wrap at api_user
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed.
@afausti I've push a commit with the Travis set up for PyPI deployments. Make sure you Here's the deployment procedure:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, see my comment for the release procedure.
Changes in this PR include upload of data blobs produced by validate_drp job, measurement metadata and metric definitions to SQUASH API