You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "Vitor-Avila (via GitHub)" <gi...@apache.org> on 2024/05/18 07:29:41 UTC
[PR] chore(tags): Handle tagging as part of asset update call [superset]
Vitor-Avila opened a new pull request, #28570:
URL: https://github.com/apache/superset/pull/28570
### SUMMARY
Currently, if a change is made to the Tags configuration for an asset via the PropertiesModal, the modification is handled in a separate request. This causes two issues:
* Content owners with `write access on $asset_type` have the impression they can change the tags configuration (since they can save it).
* The operation silently fails -- no error in the UI.
This PR moves the tag handling to the API call to update asset, providing an error to the user if permissions are missing. The PR also introduces a new permission so that users that don't have `can write on Tag` can still add existing tags to the assets they own (and have permission to modify).
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
**BEFORE**
https://github.com/apache/superset/assets/96086495/916eab85-63a8-4425-ae05-fdef310400e2
**AFTER**
Had to add to GDrive due to filesize
https://drive.google.com/file/d/1141h-OqqvOFH4Ok4yXISwKCzIs3TP9gZ/view?usp=sharing
### TESTING INSTRUCTIONS
Added both integration and unit tests. For manual testing:
1. Log in with a role that doesn't have `can write on Tag` but has `can write on Dashboard`.
2. Edit the properties for a dashboard, changing the Tags config.
3. Validate the change happens in the same network call and that errors are properly displayed.
### ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] chore(tags): Handle tagging as part of asset update call [superset]
Posted by "hughhhh (via GitHub)" <gi...@apache.org>.
hughhhh commented on code in PR #28570:
URL: https://github.com/apache/superset/pull/28570#discussion_r1607372225
##########
superset/commands/utils.py:
##########
@@ -102,3 +107,79 @@ def get_datasource_by_id(datasource_id: int, datasource_type: str) -> BaseDataso
)
except DatasourceNotFound as ex:
raise DatasourceNotFoundValidationError() from ex
+
+
+def validate_tags(
+ object_type: str,
Review Comment:
couldn't this be ENUM of resource `CHART || DASHBOARD || QUERY`
https://sourcegraph.com/github.com/apache/superset@389d8b5b5daa260d29783b077e6808704fa49c90/-/blob/superset/tags/models.py?L83
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] chore(tags): Handle tagging as part of asset update call [superset]
Posted by "Vitor-Avila (via GitHub)" <gi...@apache.org>.
Vitor-Avila commented on PR #28570:
URL: https://github.com/apache/superset/pull/28570#issuecomment-2123804315
> Also @Vitor-Avila we need to update the calls for `Query` and `Dataset` to make sure they have the same ability to update the tags as well
@hughhhh for Saved Queries I'm not sure if it makes sense since you can't really assign a Tag via the UI to a single query -- you can only assign tags to Saved Queries via the **BULK SELECT** (and in this case I think it makes sense to use the `bulk_create` approach which is already the case).
Tags are not fully supported with Datasets yet (not sure if the association works, but the Datasets list doesn't show Tags, the Datasets properties modal doesn't show tags, Datasets schemas don't have tags, etc) so this would be a bigger change a bit out of the scope of this PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] chore(tags): Handle tagging as part of asset update call [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #28570:
URL: https://github.com/apache/superset/pull/28570#issuecomment-2118678825
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/28570?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
Attention: Patch coverage is `69.86301%` with `22 lines` in your changes are missing coverage. Please review.
> Project coverage is 64.55%. Comparing base [(`76d897e`)](https://app.codecov.io/gh/apache/superset/commit/76d897eaa2f9e137102bc194c2e3109c29d0348f?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`41e3a9a`)](https://app.codecov.io/gh/apache/superset/pull/28570?dropdown=coverage&src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
> Report is 144 commits behind head on master.
| [Files](https://app.codecov.io/gh/apache/superset/pull/28570?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [superset/commands/chart/update.py](https://app.codecov.io/gh/apache/superset/pull/28570?src=pr&el=tree&filepath=superset%2Fcommands%2Fchart%2Fupdate.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvY29tbWFuZHMvY2hhcnQvdXBkYXRlLnB5) | 25.00% | [9 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/28570?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/commands/dashboard/update.py](https://app.codecov.io/gh/apache/superset/pull/28570?src=pr&el=tree&filepath=superset%2Fcommands%2Fdashboard%2Fupdate.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvY29tbWFuZHMvZGFzaGJvYXJkL3VwZGF0ZS5weQ==) | 25.00% | [9 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/28570?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/charts/api.py](https://app.codecov.io/gh/apache/superset/pull/28570?src=pr&el=tree&filepath=superset%2Fcharts%2Fapi.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvY2hhcnRzL2FwaS5weQ==) | 33.33% | [2 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/28570?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/dashboards/api.py](https://app.codecov.io/gh/apache/superset/pull/28570?src=pr&el=tree&filepath=superset%2Fdashboards%2Fapi.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvZGFzaGJvYXJkcy9hcGkucHk=) | 33.33% | [2 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/28570?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #28570 +/- ##
==========================================
+ Coverage 60.48% 64.55% +4.06%
==========================================
Files 1931 521 -1410
Lines 76236 37546 -38690
Branches 8568 0 -8568
==========================================
- Hits 46114 24238 -21876
+ Misses 28017 13308 -14709
+ Partials 2105 0 -2105
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/28570/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [hive](https://app.codecov.io/gh/apache/superset/pull/28570/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `49.05% <32.87%> (-0.11%)` | :arrow_down: |
| [javascript](https://app.codecov.io/gh/apache/superset/pull/28570/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [presto](https://app.codecov.io/gh/apache/superset/pull/28570/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `53.60% <32.87%> (-0.20%)` | :arrow_down: |
| [python](https://app.codecov.io/gh/apache/superset/pull/28570/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `64.55% <69.86%> (+1.06%)` | :arrow_up: |
| [unit](https://app.codecov.io/gh/apache/superset/pull/28570/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `58.95% <67.12%> (+1.33%)` | :arrow_up: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/superset/pull/28570?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] chore(tags): Handle tagging as part of asset update call [superset]
Posted by "hughhhh (via GitHub)" <gi...@apache.org>.
hughhhh commented on code in PR #28570:
URL: https://github.com/apache/superset/pull/28570#discussion_r1607369819
##########
superset/charts/schemas.py:
##########
@@ -284,7 +285,9 @@ class ChartPutSchema(Schema):
)
is_managed_externally = fields.Boolean(allow_none=True, dump_default=False)
external_url = fields.String(allow_none=True)
- tags = fields.Nested(TagSchema, many=True)
Review Comment:
Where are we removing the `TagSchema` reference here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] chore(tags): Handle tagging as part of asset update call [superset]
Posted by "hughhhh (via GitHub)" <gi...@apache.org>.
hughhhh commented on code in PR #28570:
URL: https://github.com/apache/superset/pull/28570#discussion_r1608754326
##########
superset/charts/schemas.py:
##########
@@ -284,7 +285,9 @@ class ChartPutSchema(Schema):
)
is_managed_externally = fields.Boolean(allow_none=True, dump_default=False)
external_url = fields.String(allow_none=True)
- tags = fields.Nested(TagSchema, many=True)
Review Comment:
So we should prolly centralize `TagSchema` somewhere it could be used in all the resource update schemas
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] chore(tags): Handle tagging as part of asset update call [superset]
Posted by "Vitor-Avila (via GitHub)" <gi...@apache.org>.
Vitor-Avila commented on code in PR #28570:
URL: https://github.com/apache/superset/pull/28570#discussion_r1607603186
##########
superset/commands/utils.py:
##########
@@ -102,3 +107,79 @@ def get_datasource_by_id(datasource_id: int, datasource_type: str) -> BaseDataso
)
except DatasourceNotFound as ex:
raise DatasourceNotFoundValidationError() from ex
+
+
+def validate_tags(
+ object_type: str,
Review Comment:
def could! I was already using `ObjectType` for the `update_tags` method, but here thought about going with `string` because I'm using `security_manager.can_access` to check if the user has the required perm, which is case sensitive. We have two options here:
1. Create a new `enum` with:
``` python
class AssetTypes(enum.Enum):
CHART = "Chart"
DASHBOARD = "Dashboard"
```
2. Use the existing `ObjectType` and then call `can_access` using `capitalize()`:
``` python
if not security_manager.can_access("can_tag", object_type.name.capitalize()):
```
@hughhhh would you have any preferences?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] chore(tags): Handle tagging as part of asset update call [superset]
Posted by "Vitor-Avila (via GitHub)" <gi...@apache.org>.
Vitor-Avila commented on code in PR #28570:
URL: https://github.com/apache/superset/pull/28570#discussion_r1607567167
##########
superset/charts/schemas.py:
##########
@@ -284,7 +285,9 @@ class ChartPutSchema(Schema):
)
is_managed_externally = fields.Boolean(allow_none=True, dump_default=False)
external_url = fields.String(allow_none=True)
- tags = fields.Nested(TagSchema, many=True)
Review Comment:
that's a good catch -- I scanned for un-used imports but didn't realize that `TagSchema` was actually defined in this same file. I'll remove its definition in a follow up commit.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] chore(tags): Handle tagging as part of asset update call [superset]
Posted by "hughhhh (via GitHub)" <gi...@apache.org>.
hughhhh commented on code in PR #28570:
URL: https://github.com/apache/superset/pull/28570#discussion_r1608745506
##########
superset/commands/utils.py:
##########
@@ -102,3 +107,79 @@ def get_datasource_by_id(datasource_id: int, datasource_type: str) -> BaseDataso
)
except DatasourceNotFound as ex:
raise DatasourceNotFoundValidationError() from ex
+
+
+def validate_tags(
+ object_type: str,
Review Comment:
Let's go with #2 using `ObjectType` enum
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] chore(tags): Handle tagging as part of asset update call [superset]
Posted by "hughhhh (via GitHub)" <gi...@apache.org>.
hughhhh commented on code in PR #28570:
URL: https://github.com/apache/superset/pull/28570#discussion_r1607372225
##########
superset/commands/utils.py:
##########
@@ -102,3 +107,79 @@ def get_datasource_by_id(datasource_id: int, datasource_type: str) -> BaseDataso
)
except DatasourceNotFound as ex:
raise DatasourceNotFoundValidationError() from ex
+
+
+def validate_tags(
+ object_type: str,
Review Comment:
couldn't this be ENUM of resource `CHART || DASHBOARD || QUERY`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] chore(tags): Handle tagging as part of asset update call [superset]
Posted by "hughhhh (via GitHub)" <gi...@apache.org>.
hughhhh commented on PR #28570:
URL: https://github.com/apache/superset/pull/28570#issuecomment-2123239836
Also @Vitor-Avila we need to update the calls for `Query` and `Dataset` to make sure they have the same ability to update the tags as well
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] chore(tags): Handle tagging as part of asset update call [superset]
Posted by "Vitor-Avila (via GitHub)" <gi...@apache.org>.
Vitor-Avila commented on code in PR #28570:
URL: https://github.com/apache/superset/pull/28570#discussion_r1607603716
##########
superset/charts/schemas.py:
##########
@@ -284,7 +285,9 @@ class ChartPutSchema(Schema):
)
is_managed_externally = fields.Boolean(allow_none=True, dump_default=False)
external_url = fields.String(allow_none=True)
- tags = fields.Nested(TagSchema, many=True)
Review Comment:
I'll hold on committing this change ☝️ until I get your feedback on the other comment.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] chore(tags): Handle tagging as part of asset update call [superset]
Posted by "hughhhh (via GitHub)" <gi...@apache.org>.
hughhhh merged PR #28570:
URL: https://github.com/apache/superset/pull/28570
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org