Skip to content
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

[POC] spcs project #1727

Draft
wants to merge 1,048 commits into
base: main
Choose a base branch
from
Draft

[POC] spcs project #1727

wants to merge 1,048 commits into from

Conversation

sfc-gh-sichen
Copy link
Collaborator

Pre-review checklist

  • I've confirmed that instructions included in README.md are still correct after my changes in the codebase.
  • I've added or updated automated unit tests to verify correctness of my new code.
  • I've added or updated integration tests to verify correctness of my new code.
  • I've confirmed that my changes are working by executing CLI's commands manually on MacOS.
  • I've confirmed that my changes are working by executing CLI's commands manually on Windows.
  • I've confirmed that my changes are up-to-date with the target branch.
  • I've described my changes in the release notes.
  • I've described my changes in the section below.

Changes description

...

dependabot bot and others added 30 commits July 16, 2024 10:40
Bumps [tomlkit](https://github.com/sdispater/tomlkit) from 0.12.5 to 0.13.0.
- [Release notes](https://github.com/sdispater/tomlkit/releases)
- [Changelog](https://github.com/python-poetry/tomlkit/blob/master/CHANGELOG.md)
- [Commits](python-poetry/tomlkit@0.12.5...0.13.0)

---
updated-dependencies:
- dependency-name: tomlkit
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [setuptools](https://github.com/pypa/setuptools) from 70.2.0 to 70.3.0.
- [Release notes](https://github.com/pypa/setuptools/releases)
- [Changelog](https://github.com/pypa/setuptools/blob/main/NEWS.rst)
- [Commits](pypa/setuptools@v70.2.0...v70.3.0)

---
updated-dependencies:
- dependency-name: setuptools
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
)

* add integration tests

* nice error message if template does not exist

* remove multiple cases for default URL
* Temporarily skip failing test due to server side issue

* Add issue number to description
* create decorator

* unit tests

* add "app open" integration tests

* teardown with v1

* add tests
 Add error events to telemetry
* add v2 decorator to "app teardown" command

* util to enable v2 feature flag

* v2 coverage for teardown cascade integration test
…e, deploy (#1332)

* support v2 in "snow app bundle"

* refactor deploy_root

* update unit test

* Support project definition v2 in "app validate" and "app deploy" (#1339)

support v2 in validate and deploy

* remove pushd
* Refactor VariableOption flag

* update snapshot
* Show snow init command

* update release notes
Add hidden `snow app events` command that will be used to fetch events for the app from the account's event table in the future. For now, this command just validates that the account has an event table set up or prints instructions linking to the docs if it's not set up.
* run tests

* version tests

* add unit tests

* project name tests
* Add test for Task

* Add test warehouse

* refactor of imports
Bumps [pytest](https://github.com/pytest-dev/pytest) from 8.2.2 to 8.3.1.
- [Release notes](https://github.com/pytest-dev/pytest/releases)
- [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst)
- [Commits](pytest-dev/pytest@8.2.2...8.3.1)

---
updated-dependencies:
- dependency-name: pytest
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* Solution + unit tests

* Integration tests

* test fix

* test fix
As part of implementing `snow app events -f`, we want to be able to stream messages indefinitely. This PR allows commands return a StreamResult, which wraps a generator of `CommandResult` objects. When we print a `StreamResult`, we iterate over all of its values and pass them individually through the same printing process.
Fetches events from the account event table (See #1337). This does not implement filtering, timeboxing, or limiting output (these will come in a followup).
Revert "SNOW-1544013 Fetch events for app (#1352)"

This reverts commit 8c1ea7f.
* Revert "Revert "SNOW-1544013 Fetch events for app" (#1361)"

This reverts commit 03a972e.
* Deprecation warning

* Update readme

* fix
sfc-gh-fcampbell and others added 25 commits September 26, 2024 14:34
Stop alphabetizing dict keys in `snow helpers v1-to-v2`, to keep the converted PDFs to an opinionated order.
* SNOW-1055755: scripts and resources required for building binary packages
…rectly (#1621)

Now that `ApplicationPackageEntity` has a static `deploy()` method, we can just call that instead of having to pass a callback from the `NativeAppManager` to deploy the app files to the scratch stage when doing setup script validation. There's a bit of a an explosion in required params, but it's temporary and it'll be cleaned up when the v1 commands are made to operate on v2 entities directly.
We have some commands, like `snow app bundle`/`snow ws bundle` that don't even need a connection, so let's defer connecting to Snowflake until it's actually needed by the particular action being run.

For now, all `snow ws` commands are still marked as requiring a connection, that will be fixed separately.
…it (#1636)

Fixes bug with `snow helpers v1-to-v2` if a `snowflake.local.yml` is present. Currently, the local file isn't renamed, so a v1 local can be overlaid onto a v2 main definition file after migration, which breaks subsequent commands. Since local overrides are no longer a desired feature in PDFv2, we don't convert them unless `--migrate-local-overrides` is used.
Fixes the manifest not being found if it isn't explicitly mentioned as an artifact or as part of a glob when running `snow helpers v1-to-v2`.
…en (#1655)

* mraba/help-version-info: add version to tool description on help screen
Quick `snow ws dump` internal command to show what a snowflake.yml file will render to after defaults, templates, and mixins.
Renames `snowflake.cli._plugins.nativeapp.v2_conversions.v2_to_v1_decorator` to `snowflake.cli._plugins.nativeapp.v2_conversions.compat` since we're going to put more stuff in there.
When running `snow object create` (a command that shouldn't load `snowflake.yml`), a Pydantic validation error was still raised because the file is loaded by telemetry code to get the definition version. We shouldn't let telemetry code break the app, so let's just ignore the error in the case of an invalid project definition.
* SNOW-1694005: use pyinstaller for composing pkg content
…w WorkspaceContext (#1652)

Entity classes current have lots of static methods, which were added to support the v1 to v2 migration, but they have way too many parameters, so we want to allow calling these methods on entity instances. 

Right now, the only instance methods are `EntityAction` implementations, which represent the top-level actions that can be performed by these entities, but the static methods we want to convert to instance methods don't need to be `EntityAction` implementations (since they don't represent top-level operations). However, it would be useful for these methods to have access to utilities in the `ActionContext`, like `ctx.default_role` for example. Since these utilities are not really part of the action, let's extract them from `ActionContext` into a new `WorkspaceContext` that gets set as a field of the entity when instantiated by the `WorkspaceManager`.
No material changes, just extracting the entity finding logic into `_find_app_and_package_entities` and the Typer options into `APP_AND_PACKAGE_OPTIONS` slim the diff in #1635.
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.
… PDFv2 (#1667)

We eventually want to remove `NativeAppManager` and `NativeAppProjectModel` since they're only thin wrappers around the v2 entities right now. Since the `snow app` commands can only operate on a single package or app at a time, we need to adapt the definition that the user gives us if it doesn't conform. This PR adds `@single_app_and_package()` decorator to be used on `snow app` commands to perform this conversion.

If the user gives us a v1 definition, it is implicitly converted to a v2 definition with `app` and `pkg` entities using the same conversion as `snow helpers v1-to-v2`. If the user gives us a v2 definition, it is searched for a single package entity and up to one app entity using the same logic as the current `@nativeapp_definition_v2_to_v1()` decorator, including disambiguating using `--package-entity-id` and `--app-entity-id` options if necessary.

With this decorator, the `snow app` commands can operate natively on v2 entities instead of having to rely on `NativeAppManager` and `NativeAppProjectModel`, which only support v1 (In this PR, we demonstrate the usage of the decorator by applying it to `snow app bundle`).
Converts `snow app diff` to operate natively on v2 models
@sfc-gh-sichen sfc-gh-sichen force-pushed the sichen-spcs-project branch 3 times, most recently from 11bf9d9 to c7c3a58 Compare October 17, 2024 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.