-
Notifications
You must be signed in to change notification settings - Fork 55
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
Allow converting PDFv1 to PDFv2 in-memory only #1670
Conversation
# FIXME: this property only exists to help implement | ||
# nativeapp_definition_v2_to_v1. Consider changing the way | ||
# this calculation is provided to commands in order to remove | ||
# this logic (then make project_definition a non-cloned @property) | ||
# nativeapp_definition_v2_to_v1 and single_app_and_package. | ||
# Consider changing the way this calculation is provided to commands | ||
# in order to remove this logic (then make project_definition a non-cloned @property) |
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 know this is proliferating a self-proclaimed undesirable pattern, but I think it's worth it for the simplicity of the change. We'll have a better opportunity to fix this once this v1-to-v2 refactor is done.
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
if envs is not None: | ||
data["env"] = envs |
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.
None
isn't a valid value for env
according to the pydantic model. When saving the converted PDF to disk, None
is omitted but when converting in-memory, we need to omit it here.
d51894d
to
07bf2a7
Compare
07bf2a7
to
8cf6f44
Compare
Allows converting a v1 definition to v2 only in-memory, without saving the resultant v2 definition to `snowflake.yml`. This will be used in a future decorator added in #1667 to allow v1 commands to operate natively on v2 entities by implicitly converting the definition. Since the definition conversion process currently updates package script files in-place, we need a way to isolate those changes to a temp directory instead of touching the user's project directory. This is achieved by creating a tempdir to hold these conversions and by replacing the package script filenames in the project definition with absolute paths to those temp files, taking advantage of the (documented) fact that `Path(...) / "/tmp/foo"` ignores the first `Path` since the second is absolute, resulting in just `Path("/tmp/foo")`. Since the definition contents will never be emitted to disk to be loaded in the future, another thing we need to do is evaluate templates in the converted project definition immediately instead of returning a definition with tags in it. In addition, since we're modifying the project definition in-memory, we also need to override the template context to be used for future template expansions in other files, so this ability was added to the CLI global context manager.
Pre-review checklist
Changes description
Extracted from #1667 to get separate CLI team codeowner review.
Allows converting a v1 definition to v2 only in-memory, without saving the resultant v2 definition to
snowflake.yml
. This will be used in a future decorator added in #1667 to allow v1 commands to operate natively on v2 entities by implicitly converting the definition.Since the definition conversion process currently updates package script files in-place, we need a way to isolate those changes to a temp directory instead of touching the user's project directory. This is achieved by creating a tempdir to hold these conversions and by replacing the package script filenames in the project definition with absolute paths to those temp files, taking advantage of the (documented) fact that
Path(...) / "/tmp/foo"
ignores the firstPath
since the second is absolute, resulting in justPath("/tmp/foo")
.Since the definition contents will never be emitted to disk to be loaded in the future, another thing we need to do is evaluate templates in the converted project definition immediately instead of returning a definition with tags in it.
In addition, since we're modifying the project definition in-memory, we also need to override the template context to be used for future template expansions in other files, so this ability was added to the CLI global context manager.