-
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 streamlit entities #1934
base: main
Are you sure you want to change the base?
Add streamlit entities #1934
Conversation
015c955
to
3d36227
Compare
33999ec
to
6bdb1af
Compare
…ntities # Conflicts: # tests/streamlit/__snapshots__/test_commands.ambr # tests/test_data/projects/example_streamlit_v2/snowflake.yml
from snowflake.cli.api.entities.common import EntityBase | ||
from snowflake.cli._plugins.workspace.context import ActionContext | ||
from snowflake.cli.api.entities.common import EntityBase, get_sql_executor | ||
from snowflake.connector.cursor import SnowflakeCursor | ||
|
||
|
||
class StreamlitEntity(EntityBase[StreamlitEntityModel]): |
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 added a temporary mock implementation of StreamlitEntity
for composability with Native Apps in #1856.
The fake logic will be replaced by your PR, but please take a look at the proposed ApplicationPackageChildInterface
contract.
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.
Renamed some methods to allign it with your interface.
Bundle and deploy actions are left intact, as they will have to be heavily remodeled, after introducing project-wide bundle map and other changes to output files management
255ec61
to
6ccfdc8
Compare
…ntities # Conflicts: # src/snowflake/cli/_plugins/streamlit/streamlit_entity.py
07ccf39
to
c6fe394
Compare
@@ -833,6 +833,7 @@ def _bundle_children(self, action_ctx: ActionContext) -> List[str]: | |||
child_entity.get_deploy_sql( | |||
artifacts_dir=child_artifacts_dir.relative_to(self.deploy_root), | |||
schema=child_schema, | |||
replace=True, |
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.
Will this be relevant for other entity types, or only Streamlit?
Should the user be able to control it?
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.
For snowpark entities- for shure. We want user to be able to ensure, if the deploy operation is allowed to overwrite any data.
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.
We should probably pass the replace
value as it exists on the base entity, and then allow to override it for a specific child when used in an app. How will users control replace
in a standalone Streamlit entity?
It doesn't have to block this PR though. Just please add a TODO comment here to address this issue, since it will now be True
for all app children without being able to control it.
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.
You got me a bit lost here. I would assume, that users will control replace
just like they do now- by passing replace
flag to command/action.
Assuming by the expected query in your test, it was done implicitly, without user control, as CREATE OR REPLACE
was a default value.
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.
A --replace
flag works when we're deploying a single entity. But here we will have multiple child entities deployed as part of the native app, and the user might want to replace
only some of them.
For now we can keep replace=True
to be the implied behavior, but eventually we need to enable a way to override it.
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.
Oh right, so, we should think of- in your PoC, or while implementing depends_on
of a way, in which user can specify which mode should be used for each dependency/child
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.
Yep. We will figure out the exact syntax later on. I was thinking about something like this:
entities:
pkg:
type: application package
children:
- target: my_sproc
replace: false
9de1ca8
to
83af4d1
Compare
83af4d1
to
46f4447
Compare
@@ -833,6 +833,7 @@ def _bundle_children(self, action_ctx: ActionContext) -> List[str]: | |||
child_entity.get_deploy_sql( | |||
artifacts_dir=child_artifacts_dir.relative_to(self.deploy_root), | |||
schema=child_schema, | |||
replace=True, |
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.
We should probably pass the replace
value as it exists on the base entity, and then allow to override it for a specific child when used in an app. How will users control replace
in a standalone Streamlit entity?
It doesn't have to block this PR though. Just please add a TODO comment here to address this issue, since it will now be True
for all app children without being able to control it.
def action_deploy(self, action_ctx: ActionContext, *args, **kwargs): | ||
# After adding bundle map- we should use it's mapping here | ||
|
||
query = self.get_deploy_sql() | ||
result = self._sql_executor.execute_query(query) | ||
return result |
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.
def action_deploy(self, action_ctx: ActionContext, *args, **kwargs): | |
# After adding bundle map- we should use it's mapping here | |
query = self.get_deploy_sql() | |
result = self._sql_executor.execute_query(query) | |
return result | |
def action_deploy(self, action_ctx: ActionContext, *args, **kwargs): | |
# After adding bundle map- we should use it's mapping here | |
return self._sql_executor.execute_query(self.get_deploy_sql()) |
To be consistent with the rest of the functions :)
PathMapping(src=str(artifact)) | ||
for artifact in self._entity_model.artifacts | ||
], | ||
def action_deploy(self, action_ctx: ActionContext, *args, **kwargs): |
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.
Should deploy action also copy the artifacts to the stage (after resolving --replace
conflicts)?
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.
(or could you add a comment that this will be resolved in bundle map PR if thats a case)?
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.
Done
Co-authored-by: Patryk Czajka <[email protected]>
cb2d9fe
to
423eff7
Compare
Pre-review checklist
Changes description
Added streamlit entity outline for introducing composability in PRDF v2