Skip to content

Commit

Permalink
Fix streamlit new component and cli refractor
Browse files Browse the repository at this point in the history
  • Loading branch information
kaarthik108 committed Aug 23, 2023
1 parent dcd0eae commit 18dcc5e
Show file tree
Hide file tree
Showing 13 changed files with 348 additions and 202 deletions.
64 changes: 64 additions & 0 deletions .github/ISSUE_TEMPLATE/bugs.yml
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?

47 changes: 47 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-request.yml
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?
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SnowDev - Snowpark Devops

[![Documentation](https://img.shields.io/badge/documentation-view-blue)](docs/quickstart.md) ![PyPI Downloads](https://img.shields.io/pypi/dm/snowdev)
[![Documentation](https://img.shields.io/badge/documentation-view-blue)](docs/quickstart.md) [![Downloads](https://static.pepy.tech/badge/snowdev)](https://pepy.tech/project/snowdev)

SnowDev is a command-line utility designed for deploying various components related to Snowflake such as UDFs, stored procedures, and Streamlit applications using **Snowpark**. This tool streamlines tasks like initializing directories, local testing, uploading, and auto create components code using AI.

Expand Down
10 changes: 5 additions & 5 deletions pyproject.toml
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"
Expand All @@ -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"]
Expand Down
Empty file added snowdev/cli/__init__.py
Empty file.
127 changes: 127 additions & 0 deletions snowdev/cli/commands.py
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()
9 changes: 9 additions & 0 deletions snowdev/cli/main.py
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()
Loading

0 comments on commit 18dcc5e

Please sign in to comment.