-
Notifications
You must be signed in to change notification settings - Fork 56
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
Add optional subdirectory for stage in application package #1916
Open
sfc-gh-pjafari
wants to merge
41
commits into
main
Choose a base branch
from
pj-subartifacts-subdirs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,451
−232
Open
Changes from 37 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
8617252
teardown with comments
sfc-gh-pjafari 5a3e154
make version work
sfc-gh-pjafari 8db7a40
update path for version create
sfc-gh-pjafari d9eb5f4
catch tempalte processor file read error
sfc-gh-pjafari 71108d0
make diff an entity action
sfc-gh-pjafari a7e3a20
remove teardown with all apps logic
sfc-gh-pjafari 99abebf
ws change
sfc-gh-pjafari ce71ebf
add schema to StagePathParts
sfc-gh-pjafari 855b413
use DefaultStagePathParts for stage in NA
sfc-gh-pjafari 68904aa
remmove comments
sfc-gh-pjafari 5fc642e
clean up
sfc-gh-pjafari 49275b9
clean up
sfc-gh-pjafari 04d807e
update comment
sfc-gh-pjafari be0402b
merge main
sfc-gh-pjafari ff369e7
rename stage
sfc-gh-pjafari 31e1f70
remove trailing slash when no directory
sfc-gh-pjafari f52c6cb
update unit tests
sfc-gh-pjafari e95ab86
update docstring
sfc-gh-pjafari b663798
add unit tests for DefaultStagePathParts
sfc-gh-pjafari 3412b3c
Merge branch 'pj-schema-in-stagepathparts' into pj-subartifacts-subdirs
sfc-gh-pjafari 08a4110
update stage diff command and message wording
sfc-gh-pjafari c7a0a88
update snapshot for test_deploy
sfc-gh-pjafari 8153807
Merge branch 'main' into pj-subartifacts-subdirs
sfc-gh-pjafari 504f692
add integration tests
sfc-gh-pjafari 5cbf941
Merge branch 'main' into pj-subartifacts-subdirs
sfc-gh-pjafari 56fc4f6
iMerge branch 'pj-subartifacts-subdirs' of https://github.com/snowfla…
sfc-gh-pjafari b81670c
add unit tests
sfc-gh-pjafari 889c77e
update release notes
sfc-gh-pjafari 44263ce
remove template processor change
sfc-gh-pjafari 70e3d38
make stage paths work for quoted ids
sfc-gh-pjafari c0b0826
address comments
sfc-gh-pjafari 4ec1071
make for quoted identifiers in diff
sfc-gh-pjafari 00db5a8
merge main
sfc-gh-pjafari 7f30fea
make diff work with all identifiers, update docstrings
sfc-gh-pjafari 1921805
update tests
sfc-gh-pjafari 3f9ed94
merge main
sfc-gh-pjafari d84a59c
fix tests
sfc-gh-pjafari d865ac8
update commands
sfc-gh-pjafari dfb4373
merge main
sfc-gh-pjafari aa80ac4
replace test data with factory
sfc-gh-pjafari a225d44
import fixture
sfc-gh-pjafari File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,11 +40,6 @@ | |
force_project_definition_v2, | ||
) | ||
from snowflake.cli._plugins.nativeapp.version.commands import app as versions_app | ||
from snowflake.cli._plugins.stage.diff import ( | ||
DiffResult, | ||
compute_stage_diff, | ||
) | ||
from snowflake.cli._plugins.stage.utils import print_diff_to_console | ||
from snowflake.cli._plugins.workspace.manager import WorkspaceManager | ||
from snowflake.cli.api.cli_global_context import get_cli_context | ||
from snowflake.cli.api.commands.decorators import ( | ||
|
@@ -63,6 +58,7 @@ | |
ObjectResult, | ||
StreamResult, | ||
) | ||
from snowflake.cli.api.project.util import same_identifiers | ||
from typing_extensions import Annotated | ||
|
||
app = SnowTyperFactory( | ||
|
@@ -113,20 +109,15 @@ def app_diff( | |
project_root=cli_context.project_root, | ||
) | ||
package_id = options["package_entity_id"] | ||
package = cli_context.project_definition.entities[package_id] | ||
bundle_map = ws.perform_action( | ||
diff = ws.perform_action( | ||
package_id, | ||
EntityActions.BUNDLE, | ||
) | ||
stage_fqn = f"{package.fqn.name}.{package.stage}" | ||
diff: DiffResult = compute_stage_diff( | ||
local_root=Path(package.deploy_root), stage_fqn=stage_fqn | ||
EntityActions.DIFF, | ||
print_to_console=cli_context.output_format != OutputFormat.JSON, | ||
) | ||
if cli_context.output_format == OutputFormat.JSON: | ||
return ObjectResult(diff.to_dict()) | ||
else: | ||
print_diff_to_console(diff, bundle_map) | ||
return None # don't print any output | ||
|
||
return None | ||
|
||
|
||
@app.command("run", requires_connection=True) | ||
|
@@ -258,11 +249,22 @@ def app_teardown( | |
project_definition=cli_context.project_definition, | ||
project_root=cli_context.project_root, | ||
) | ||
|
||
# TODO: get all apps created from this application package from snowflake, compare, confirm and drop. | ||
# TODO: add messaging/confirmation here for extra apps found as part of above | ||
Comment on lines
+257
to
+258
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Kept current teardown functionality. Next PR, we will get and drop all app objects created from this package, not just what's listed in pdf. |
||
all_packages_with_id = [ | ||
package_entity.entity_id | ||
for package_entity in project.get_entities_by_type( | ||
ApplicationPackageEntityModel.get_type() | ||
).values() | ||
if same_identifiers(package_entity.identifier, app_package_entity.identifier) | ||
sfc-gh-pjafari marked this conversation as resolved.
Show resolved
Hide resolved
|
||
] | ||
|
||
for app_entity in project.get_entities_by_type( | ||
ApplicationEntityModel.get_type() | ||
).values(): | ||
# Drop each app | ||
if app_entity.from_.target == app_package_entity.entity_id: | ||
if app_entity.from_.target in all_packages_with_id: | ||
ws.perform_action( | ||
app_entity.entity_id, | ||
EntityActions.DROP, | ||
|
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Made
diff
its own entity action.action_diff