-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[asset selection] Introduce AssetSelection.to_selection_str (#26047)
## Summary On the backend, `AssetSelection` is a nice serializable representation of an asset selection, which we might generate through a few methods: - From an Antlr asset selection string - From a set of frontend filters, saved in a catalog view - Potentially from snapshotted user code, though we don't do this right now (for example, examining an asset job or sensor/schedule target and being able to copy an Antlr-ready string) We don't have a good way to convert this selection back into a user-readable Antlr string. There are a few possible solutions here: - Save the user-specified Antlr string alongside a selection. This seems like a promising approach when the initial source of truth is an Antlr string. - Generate an Antlr string. This is the approach we'll need if the source of truth is user code or frontend filters where no Antlr string previously existed. This PR introduces a `to_selection_str()` method on `AssetSelection` subclasses, which output a valid Antlr string representing that selection: - The string must be parsed into an identical AssetSelection - The string may not identically match the original Antlr string, if one exists ## Test Plan New tests which 1. Ensure that Antlr strings can be converted to selections, back into equivalent strings (e.g. produce the same selection, but may not be equal) 2. Ensure that we have all Antlr literals under test, a rough proxy for ensuring we have full coverage of the grammar Updates the existing `__str__` tests, which were introduced in #19059 for similar purposes but never fully fleshed out. For now, drops check selection stuff since the Antlr syntax doesn't include it.
- Loading branch information
Showing
6 changed files
with
160 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.