-
Notifications
You must be signed in to change notification settings - Fork 296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support prescribed labels #3848
Conversation
engine/apps/labels/utils.py
Outdated
@@ -16,32 +16,28 @@ | |||
ASSOCIATED_MODEL_NAME = "AssociatedLabel" | |||
|
|||
|
|||
class LabelUpdateParam(typing.TypedDict): | |||
class Key(typing.TypedDict): |
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 propose to rename it to LabelKey
engine/apps/labels/utils.py
Outdated
|
||
|
||
class LabelParams(typing.TypedDict): | ||
class Value(typing.TypedDict): |
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 propose to rename it to LabelValue
Co-authored-by: Yulya Artyukhina <Ferril.darkdiver@gmail.com>
Co-authored-by: Yulya Artyukhina <Ferril.darkdiver@gmail.com>
b8a7748
to
3a72579
Compare
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.
LGTM. Consider adding simple unit tests for the new Celery tasks
self._update_labels_cache(result) | ||
return Response(result, status=response.status_code) | ||
value, response = LabelsAPIClient(organization.grafana_url, organization.api_token).get_value(key_id, value_id) | ||
# TODO: update_labels_cache expects LabelOption, but get value returns a Value. Investigate, temporary disable. |
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.
Does this TODO need to be addressed before merging the PR?
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.
No, it's for future iterations.
engine/apps/labels/models.py
Outdated
update_labels_cache.apply_async((labels_data,)) | ||
# Many labels | ||
update_label_pairs_cache.apply_async((label_pairs,)) | ||
# update_labels_cache.apply_async((label_pairs,)) |
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.
Looks like this line should be deleted
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.
thanks
# Conflicts: # engine/apps/labels/tasks.py # engine/apps/labels/tests/test_labels_cache.py # grafana-plugin/src/containers/IntegrationLabelsForm/IntegrationLabelsForm.tsx
just FYI for next time, this PR introduced linting issues into |
@joeyorlando Oh, I thought it was introduced here. Did I bring new one? |
# What this PR does **Cleanup label typing:** 1. LabelParam -> two separate types LabekKey and LabelValue 2. LabelData -> renamed to LabelPair. 3. LabelKeyData -> renamed to LabelOption Data is not giving any info about what this type represents. 4. Remove LabelsData and LabelsKeysData types. They are just list of types listed above and with new naming it feels obsolete. 5. ValueData removed. LabelPair is used instead. 6. Rework AlertGroupCustomLabel to use LabelKey type for key to make type system more consistent. Name model type AlertGroupCustomLabel**DB** and api type AlertGroupCustomLabel**API** to clearly distinguish them. **Split update_labels_cache into two tasks** update_label_option_cache and update_label_pairs_cache. Original task was expecting array of LabelsData (now it's LabelPair) OR one LabelKeyData ( now it's LabelOption). I believe having one function with two sp different argument types makes it more complicated for understanding. **Make OnCall backend support prescribed labels**. OnCall will sync and store "prescribed" field for key and values, so Label dropdown able to disable editing for certain labels. ## Which issue(s) this PR fixes ## Checklist - [x] Unit, integration, and e2e (if applicable) tests updated - [ ] Documentation added (or `pr:no public docs` PR label added if not required) - [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not required) --------- Co-authored-by: Maxim Mordasov <maxim.mordasov@grafana.com> Co-authored-by: Yulya Artyukhina <Ferril.darkdiver@gmail.com>
What this PR does
Cleanup label typing:
Data is not giving any info about what this type represents.
Split update_labels_cache into two tasks update_label_option_cache and update_label_pairs_cache.
Original task was expecting array of LabelsData (now it's LabelPair) OR one LabelKeyData ( now it's LabelOption). I believe having one function with two sp different argument types makes it more complicated for understanding.
Make OnCall backend support prescribed labels. OnCall will sync and store "prescribed" field for key and values, so Label dropdown able to disable editing for certain labels.
Which issue(s) this PR fixes
Checklist
pr:no public docs
PR label added if not required)CHANGELOG.md
updated (orpr:no changelog
PR label added if not required)