-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix streamlit new component and cli refractor
- Loading branch information
1 parent
dcd0eae
commit 18dcc5e
Showing
13 changed files
with
348 additions
and
202 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: Bug Report | ||
description: Report a bug in the project | ||
labels: [bug] | ||
|
||
body: | ||
- type: markdown | ||
attributes: | ||
value: | | ||
## Bug Report | ||
Thank you for reporting a bug. Please provide as much information as possible. | ||
- type: input | ||
id: python-version | ||
attributes: | ||
label: Python Version | ||
description: Are you python 3.10 and above? | ||
placeholder: e.g., 3.10.2 | ||
validations: | ||
required: true | ||
|
||
- type: input | ||
id: snowpark-version | ||
attributes: | ||
label: Snowflake Snowpark Python Version | ||
description: Are you using snowflake-snowpark-python 1.5.1? | ||
placeholder: e.g., 1.5.1 | ||
validations: | ||
required: true | ||
|
||
- type: textarea | ||
id: steps-to-reproduce | ||
attributes: | ||
label: Steps to reproduce | ||
description: Provide a step-by-step description of the bug. | ||
placeholder: Describe the steps to reproduce the bug. | ||
validations: | ||
required: true | ||
|
||
- type: textarea | ||
id: expected-behavior | ||
attributes: | ||
label: Expected behavior | ||
description: Describe what you expected to happen. | ||
placeholder: Describe the expected behavior. | ||
validations: | ||
required: true | ||
|
||
- type: textarea | ||
id: actual-behavior | ||
attributes: | ||
label: Actual behavior | ||
description: Describe what actually happened. | ||
placeholder: Describe the actual behavior. | ||
validations: | ||
required: true | ||
|
||
- type: textarea | ||
id: additional-info | ||
attributes: | ||
label: Additional information | ||
description: Provide any additional information or context. | ||
placeholder: Any other details? | ||
|
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Feature Request | ||
description: Suggest a new feature or enhancement for the project | ||
labels: [enhancement] | ||
|
||
body: | ||
- type: markdown | ||
attributes: | ||
value: | | ||
## Feature Request | ||
Thank you for suggesting a feature. Please provide as much information as possible. | ||
- type: input | ||
id: title | ||
attributes: | ||
label: Feature Title | ||
description: A short title for the feature. | ||
placeholder: e.g., New data visualization tool | ||
validations: | ||
required: true | ||
|
||
- type: textarea | ||
id: feature-description | ||
attributes: | ||
label: Feature Description | ||
description: Describe the feature in detail. | ||
placeholder: Describe the feature you'd like to see. | ||
validations: | ||
required: true | ||
|
||
- type: checkboxes | ||
id: compatibility | ||
attributes: | ||
label: Compatibility | ||
description: Which versions should this feature be compatible with? | ||
options: | ||
- label: Python 3.10 and above | ||
required: true | ||
- label: snowflake-snowpark-python 1.5.1 | ||
required: true | ||
|
||
- type: textarea | ||
id: additional-info | ||
attributes: | ||
label: Additional information | ||
description: Provide any additional information or context. | ||
placeholder: Any other details? |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "snowdev" | ||
version = "0.1.10" | ||
version = "0.1.11" | ||
description = "snowdev: DevOps toolkit for Snowflake, facilitating seamless deployment of UDFs, stored procedures, and Streamlit apps using Snowpark's capabilities right from your local environment." | ||
authors = ["kaarthik <[email protected]>"] | ||
readme = "README.md" | ||
|
@@ -21,15 +21,15 @@ snowflake-ml-python = "1.0.5" | |
pyyaml = "^6.0.1" | ||
toml = "^0.10.2" | ||
openai = "^0.27.8" | ||
langchain = "^0.0.265" | ||
langchain = "0.0.265" | ||
tiktoken = "0.4.0" | ||
unstructured = "0.9.3" | ||
|
||
[tool.poetry.dev-dependencies] | ||
black = "^22.10.0" | ||
tiktoken = "0.4.0" | ||
unstructured = "^0.9.3" | ||
|
||
[tool.poetry.scripts] | ||
snowdev = "snowdev.main:main" | ||
snowdev = "snowdev.cli.main:main" | ||
|
||
[build-system] | ||
requires = ["poetry-core>=1.0.0"] | ||
|
Empty file.
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 |
---|---|---|
@@ -0,0 +1,127 @@ | ||
import click | ||
from termcolor import colored | ||
|
||
from snowdev import SnowBot, SnowHelper | ||
from snowdev.deployment import DeploymentArguments, DeploymentManager | ||
|
||
|
||
@click.group() | ||
@click.pass_context | ||
def cli(ctx): | ||
"""Deploy Snowflake UDFs, Stored Procedures and Streamlit apps.""" | ||
ctx.ensure_object(dict) | ||
|
||
|
||
@cli.command() | ||
def init(): | ||
"""Initialize the project structure.""" | ||
DeploymentManager.create_directory_structure() | ||
|
||
|
||
@cli.command() | ||
@click.option("--udf", type=str, help="The name of the udf.") | ||
@click.option("--sproc", type=str, help="The name of the stored procedure.") | ||
@click.option("--streamlit", type=str, help="The name of the streamlit app.") | ||
def new(udf, sproc, streamlit): | ||
"""Create a new component.""" | ||
SnowHelper.create_new_component(udf, sproc, streamlit) | ||
|
||
|
||
@cli.command() | ||
@click.option("--udf", type=str, help="The name of the udf.") | ||
@click.option("--sproc", type=str, help="The name of the stored procedure.") | ||
def test(udf, sproc): | ||
"""Test the deployment.""" | ||
deployment_args = DeploymentArguments(udf=udf, sproc=sproc) | ||
manager = DeploymentManager(deployment_args) | ||
manager.test_locally() | ||
|
||
|
||
@cli.command() | ||
def upload(): | ||
"""Upload static content.""" | ||
manager = DeploymentManager() | ||
manager.upload_static() | ||
|
||
|
||
@cli.command() | ||
@click.option("--package", type=str, help="Name of the package to zip and upload.") | ||
def add(package): | ||
"""Add a package and optionally upload.""" | ||
manager = DeploymentManager() | ||
user_response = input( | ||
colored("🤔 Do you want to upload the zip to stage? (yes/no): ", "cyan") | ||
) | ||
|
||
if user_response.lower() in ["yes", "y"]: | ||
manager.deploy_package(package, upload=True) | ||
else: | ||
manager.deploy_package(package, upload=False) | ||
|
||
|
||
@cli.command() | ||
@click.option("--udf", type=str, help="The name of the udf.") | ||
@click.option("--sproc", type=str, help="The name of the stored procedure.") | ||
@click.option("--streamlit", type=str, help="The name of the streamlit app.") | ||
@click.option("--embed", is_flag=True, help="Run the embeddings.") | ||
def ai(udf, sproc, streamlit, embed): | ||
"""AI commands.""" | ||
|
||
if embed: | ||
print(colored("Initializing AI...\n", "cyan")) | ||
SnowBot.ai_embed() | ||
return | ||
|
||
component_type, prompt = None, None | ||
|
||
if udf: | ||
component_type = "udf" | ||
prompt = udf | ||
elif sproc: | ||
component_type = "sproc" | ||
prompt = sproc | ||
elif streamlit: | ||
component_type = "streamlit" | ||
prompt = streamlit | ||
|
||
if not component_type: | ||
print( | ||
colored( | ||
"⚠️ Please specify a type (--udf, --sproc, or --streamlit) along with the ai command.", | ||
"yellow", | ||
) | ||
) | ||
return | ||
|
||
component_name = input( | ||
colored(f"🤔 Enter the {component_type.upper()} name: ", "cyan") | ||
) | ||
|
||
if SnowBot.component_exists(component_name, component_type): | ||
print( | ||
colored( | ||
f"⚠️ Component named {component_name} already exists! Choose another name or check your directories.", | ||
"yellow", | ||
) | ||
) | ||
return | ||
|
||
SnowBot.create_new_ai_component( | ||
component_name, prompt, template_type=component_type | ||
) | ||
|
||
|
||
@cli.command() | ||
@click.option("--sproc", type=str, help="The name of the stored procedure.") | ||
@click.option("--udf", type=str, help="The name of the udf.") | ||
@click.option("--streamlit", type=str, help="The name of the streamlit app.") | ||
def deploy(sproc, udf, streamlit): | ||
"""Deploy components.""" | ||
arguments = {"sproc": sproc, "udf": udf, "streamlit": streamlit} | ||
args = DeploymentArguments(**arguments) | ||
manager = DeploymentManager(args) | ||
manager.main() | ||
|
||
|
||
if __name__ == "__main__": | ||
cli() |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from .commands import cli | ||
|
||
|
||
def main(): | ||
cli() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.