-
Notifications
You must be signed in to change notification settings - Fork 323
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
Accessing and modifying description and labels of Enso Cloud assets #11255
Conversation
a0210bf
to
edfde57
Compare
Context.Output.if_enabled disabled_message="Cannot remove a label when writing is disabled. Press the Write button ▶ to perform the operation." panic=False <| | ||
labels = self.labels | ||
if labels.contains label . not then False else | ||
new_labels = labels.filter l-> l != label |
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 would be nice to have this as Vector.remove_element
.
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, but adding it I'd have to add unit tests for it and I don't want to postpone this PR.
Let's add it in a separate PR when we see it used more, or see a need for it for end-users.
4fd50b7
to
8b677f9
Compare
8b677f9
to
28a2e5a
Compare
# Conflicts: # distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Existing_Enso_Asset.enso
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.
Generally looks good - a few suggestions.
Context.Output.if_enabled disabled_message="Cannot add a label when writing is disabled. Press the Write button ▶ to perform the operation." panic=False <| | ||
labels = self.labels | ||
if labels.contains label then self else | ||
ensure_tags_exist [label] . if_not_error <| | ||
new_labels = labels+[label] | ||
update_asset_labels self new_labels . if_not_error self |
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.
Context.Output.if_enabled disabled_message="Cannot add a label when writing is disabled. Press the Write button ▶ to perform the operation." panic=False <| | |
labels = self.labels | |
if labels.contains label then self else | |
ensure_tags_exist [label] . if_not_error <| | |
new_labels = labels+[label] | |
update_asset_labels self new_labels . if_not_error self | |
labels = self.labels | |
if labels.contains label then self else | |
ensure_tags_exist [label] . if_not_error <| | |
new_labels = labels+[label] | |
Context.Output.if_enabled disabled_message="Cannot add a label when writing is disabled. Press the Write button ▶ to perform the operation." panic=False <| | |
update_asset_labels self new_labels . if_not_error self |
Could make it only check the context as last step then allow user to fix issue
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, we shouldn't change the order. Perhaps I should rename the ensure_tags_exist
method to make it clearer.
This method creates tags if they don't exist. So it is a method with side-effects, that calls into the Cloud. Hence, it itself should be behind the Output context.
I will rename the method to create_tags_if_not_exist
to make it clearer that this is more than a pre-check.
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.
But I can indeed move the contains
check before context check 👍
Sorry at first I did not notice this part
distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Enso_File.enso
Outdated
Show resolved
Hide resolved
Adding labels is not atomic. If two processes are modifying labels of | ||
the same asset at the same time, some changes may be lost. | ||
add_label : Text -> Enso_File | ||
add_label self (label : Text) -> Enso_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.
worth routing this through set_labels
?
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 was thinking of it, but then the message if Context was disabled would be 'Cannot set labels...', but I wanted a more appropriate/precise 'Cannot add a label'.
distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Enso_File.enso
Outdated
Show resolved
Hide resolved
Context.Output.if_enabled disabled_message="Cannot create a label when writing is disabled. Press the Write button ▶ to perform the operation." panic=False <| | ||
create_tag name color . if_not_error Nothing |
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.
worth testing existance?
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.
OK. Although ideally that should be checked on the cloud side and only a special error returned.
## PRIVATE | ||
new_with_metadata id:Text title:Text metadata:Asset_Metadata -> Existing_Enso_Asset = | ||
Existing_Enso_Asset.Value title id (asset_type_from_id id) metadata |
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.
## PRIVATE | |
new_with_metadata id:Text title:Text metadata:Asset_Metadata -> Existing_Enso_Asset = | |
Existing_Enso_Asset.Value title id (asset_type_from_id id) metadata | |
## PRIVATE | |
new id:Text title:Text metadata:(Nothing|Asset_Metadata)=Nothing -> Existing_Enso_Asset = | |
Existing_Enso_Asset.Value title id (asset_type_from_id id) metadata |
Could we not have a single new
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.
I wanted to make it very clear when the asset is constructed with or without metadata. IMO it is a bit clearer when this is verbose. But I can merge them - initially there were more differences in the logic, now indeed it's very similar
Pull Request Description
Audit_Spec
on the CI #11278 by ensuring that every scheduled message goes to the desired endpoint, by splitting each batch by endpoint.Important Notes
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
TypeScript,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.