-
Notifications
You must be signed in to change notification settings - Fork 57
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
Mock snowpark entities #1957
Mock snowpark entities #1957
Conversation
pass | ||
# WARNING: The Function/Procedure entities are not implemented yet. The logic below is only for demonstrating the | ||
# required interfaces for composability (used by ApplicationPackageEntity behind a feature flag). | ||
class SnowparkEntity(EntityBase[Generic[T]], ApplicationPackageChildInterface): |
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.
Is there a way to simplify the inheritence here, maybe by using aggregation instead?
You don't have to change it if required, but I am just wondering about the reason we have it this way?
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'm using inheritance as an "implements interface", there is no real inheritance here. But I'm open for suggestions for a more elegant way -- can you give an example how it can be simplified?
object_name = f"{schema}.{entity_id}" if schema else entity_id | ||
return f"{object_name}({signature})" | ||
|
||
def get_deploy_sql( |
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.
can we add docstring on public methods?
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.
The docstrings are on the interface class instead of on each entity
return "\n".join(query) | ||
|
||
def get_usage_grant_sql(self, app_role: str, schema: Optional[str] = None): | ||
entity_type = self._entity_model.get_type().upper() |
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 think we should have a mapping instead. It's a bit coincidental that the internal entity type matches SQL type.
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.
Yes I agree, but the entire logic of these methods is just a placeholder until CLI team will replace it with the real entity implementation very soon. It's not intended to be production ready, as many other features are missing. The main goal of this PR is to add the contract between snowpark/application-package for the children integration.
] | ||
return "\n".join(query) | ||
|
||
def get_usage_grant_sql(self, app_role: str, schema: Optional[str] = None): |
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 use to_identifier() to be safe:
app_role = to_identifier(app_role)
schema = to_identifier(schema)
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.
These args are already called with to_identifier()
when get_usage_grant_sql()
is called from - link
], | ||
) | ||
|
||
def _get_identifier_for_sql( |
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 need lots of comments for this one.
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.
It's a simplified version of identifier_for_sql()
-- again, just as a placeholder logic that will be replaced soon
This duplicates #1959 - so my proposition is to copy from this PR anything that is missing in the other and close this one. |
@sfc-gh-jsikorski Oh I wasn't aware of the other PR! Closing this PR, feel free to use it as a reference. |
Pre-review checklist
Changes description
Same as #1856, adding mock snowpark entities as well to be used as children of
ApplicationPackageEntity
.Manual test
Cloned the mail-order native app example, converted
snowflake.yml
to v2 and extracted a single sproc to an entity:Running
snow app bundle
created the correct bundle structure:And the correct setup script section:
Running
snow app run
deployed the app successfully, and the streamlit was able to use the sproc.