Skip to content

Commit

Permalink
updated readme and scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-tzayats committed Dec 10, 2024
1 parent 95c7229 commit d05b880
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ SELECT SYSTEM$BEHAVIOR_CHANGE_BUNDLE_STATUS('2024_08');
> For more information on this bundle please see our [BCR Documentation](https://docs.snowflake.com/en/release-notes/behavior-changes).
**UPDATED WITH EVAL INSTALL INSTRUCTION**

[Snowflake CLI](https://docs.snowflake.com/en/developer-guide/snowflake-cli-v2/index) is recommended for deploying the app in Streamlit in Snowflake. Please see Snowflake CLI [installation instructions](https://docs.snowflake.com/en/developer-guide/snowflake-cli-v2/installation/installation) to install. **Snowflake CLI version 3.0+ is recommended**. Follow the below instructions to install the Semantic Model Generator in Streamlit in Snowflake.

If you do not have Snowflake CLI installed, the setup can be replicated manually with the [VS Code Snowflake extension](https://docs.snowflake.com/en/user-guide/vscode-ext), Snowsight or [Snowflake Native Git Integration](https://docs.snowflake.com/en/developer-guide/git/git-overview):
- If using Snowsight, you may use the files upload wizard to upload files. Please pay close attention to maintain the directory structure referenced in `setup_sis/app_setup.sql`.
- If using the Native Git Integration, copy and paste the code from this [setup file](https://github.com/Snowflake-Labs/semantic-model-generator/blob/main/sis_setup/sissetup_snowsightgit.sql) and run in Snowsight.
- If using Snowsight, you may use the files upload wizard to upload files. Please pay close attention to maintain the directory structure referenced in `setup_sis/app_setup_eval_branch.sql`.
- If using the Native Git Integration, copy and paste the code from this [setup file](https://github.com/Snowflake-Labs/semantic-model-generator/blob/customer-eval/sis_setup/sissetup_snowsightgit_eval_branch.sql) and run in Snowsight.

### Snowflake CLI Installation

Expand Down
51 changes: 51 additions & 0 deletions sis_setup/app_setup_eval_branch.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
SET (streamlit_warehouse)=(SELECT CURRENT_WAREHOUSE());

CREATE DATABASE IF NOT EXISTS CORTEX_ANALYST_SEMANTICS_EVAL
COMMENT = '{"origin": "sf_sit",
"name": "skimantics",
"version": {"major": 2, "minor": 0},
"attributes": {"deployment": "sis"}}';

CREATE SCHEMA IF NOT EXISTS CORTEX_ANALYST_SEMANTICS_EVAL.SEMANTIC_MODEL_GENERATOR
COMMENT = '{"origin": "sf_sit",
"name": "skimantics",
"version": {"major": 2, "minor": 0},
"attributes": {"deployment": "sis"}}';

-- Create stage for App logic and 3rd party packages
CREATE OR REPLACE STAGE CORTEX_ANALYST_SEMANTICS_EVAL.SEMANTIC_MODEL_GENERATOR.STREAMLIT_STAGE
DIRECTORY = (ENABLE = true)
COMMENT = '{"origin": "sf_sit",
"name": "skimantics",
"version": {"major": 2, "minor": 0},
"attributes": {"deployment": "sis"}}';

-- Upload 3rd party packages
-- Run from sis_setup/ as paths are relative to this directory
PUT file://app_utils/*.zip @CORTEX_ANALYST_SEMANTICS_EVAL.SEMANTIC_MODEL_GENERATOR.STREAMLIT_STAGE OVERWRITE = TRUE AUTO_COMPRESS = FALSE;
-- Upload App logic
PUT file://app.py @CORTEX_ANALYST_SEMANTICS_EVAL.SEMANTIC_MODEL_GENERATOR.STREAMLIT_STAGE/semantic_model_generator/ OVERWRITE = TRUE AUTO_COMPRESS = FALSE;
PUT file://environment.yml @CORTEX_ANALYST_SEMANTICS_EVAL.SEMANTIC_MODEL_GENERATOR.STREAMLIT_STAGE/semantic_model_generator/ OVERWRITE = TRUE AUTO_COMPRESS = FALSE;
PUT file://semantic_model_generator/*.py @CORTEX_ANALYST_SEMANTICS_EVAL.SEMANTIC_MODEL_GENERATOR.STREAMLIT_STAGE/semantic_model_generator/semantic_model_generator/ OVERWRITE = TRUE AUTO_COMPRESS = FALSE;
PUT file://semantic_model_generator/data_processing/*.py @CORTEX_ANALYST_SEMANTICS_EVAL.SEMANTIC_MODEL_GENERATOR.STREAMLIT_STAGE/semantic_model_generator/semantic_model_generator/data_processing/ OVERWRITE = TRUE AUTO_COMPRESS = FALSE;
PUT file://semantic_model_generator/protos/*.p* @CORTEX_ANALYST_SEMANTICS_EVAL.SEMANTIC_MODEL_GENERATOR.STREAMLIT_STAGE/semantic_model_generator/semantic_model_generator/protos/ OVERWRITE = TRUE AUTO_COMPRESS = FALSE;
PUT file://semantic_model_generator/snowflake_utils/*.py @CORTEX_ANALYST_SEMANTICS_EVAL.SEMANTIC_MODEL_GENERATOR.STREAMLIT_STAGE/semantic_model_generator/semantic_model_generator/snowflake_utils/ OVERWRITE = TRUE AUTO_COMPRESS = FALSE;
PUT file://semantic_model_generator/validate/*.py @CORTEX_ANALYST_SEMANTICS_EVAL.SEMANTIC_MODEL_GENERATOR.STREAMLIT_STAGE/semantic_model_generator/semantic_model_generator/validate/ OVERWRITE = TRUE AUTO_COMPRESS = FALSE;
PUT file://images/*.png @CORTEX_ANALYST_SEMANTICS_EVAL.SEMANTIC_MODEL_GENERATOR.STREAMLIT_STAGE/semantic_model_generator/images/ OVERWRITE = TRUE AUTO_COMPRESS = FALSE;
PUT file://journeys/*.py @CORTEX_ANALYST_SEMANTICS_EVAL.SEMANTIC_MODEL_GENERATOR.STREAMLIT_STAGE/semantic_model_generator/journeys/ OVERWRITE = TRUE AUTO_COMPRESS = FALSE;
PUT file://partner/*.py @CORTEX_ANALYST_SEMANTICS_EVAL.SEMANTIC_MODEL_GENERATOR.STREAMLIT_STAGE/semantic_model_generator/partner/ OVERWRITE = TRUE AUTO_COMPRESS = FALSE;
PUT file://app_utils/*.py @CORTEX_ANALYST_SEMANTICS_EVAL.SEMANTIC_MODEL_GENERATOR.STREAMLIT_STAGE/semantic_model_generator/app_utils/ OVERWRITE = TRUE AUTO_COMPRESS = FALSE;
-- Create Streamlit
CREATE OR REPLACE STREAMLIT CORTEX_ANALYST_SEMANTICS_EVAL.SEMANTIC_MODEL_GENERATOR.SEMANTIC_MODEL_GENERATOR
ROOT_LOCATION = '@CORTEX_ANALYST_SEMANTICS_EVAL.SEMANTIC_MODEL_GENERATOR.STREAMLIT_STAGE/semantic_model_generator'
MAIN_FILE = 'app.py'
TITLE = "Semantic Model Generator (Eval)"
IMPORTS = ('@cortex_analyst_semantics_eval.semantic_model_generator.streamlit_stage/looker_sdk.zip',
'@cortex_analyst_semantics_eval.semantic_model_generator.streamlit_stage/strictyaml.zip')
QUERY_WAREHOUSE = $streamlit_warehouse
COMMENT = '{"origin": "sf_sit",
"name": "skimantics",
"version": {"major": 2, "minor": 0},
"attributes": {"deployment": "sis"}}';
85 changes: 85 additions & 0 deletions sis_setup/sissetup_snowsightgit_eval_branch.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
SET (streamlit_warehouse)=(SELECT CURRENT_WAREHOUSE());

CREATE DATABASE IF NOT EXISTS CORTEX_ANALYST_SEMANTICS_EVAL;
USE DATABASE CORTEX_ANALYST_SEMANTICS_EVAL;

-- Create API Integration for Git
CREATE OR REPLACE API INTEGRATION git_api_integration_snowflake_labs
API_PROVIDER = git_https_api
API_ALLOWED_PREFIXES = ('https://github.com/Snowflake-Labs')
ENABLED = TRUE;

-- Create Git Repository
CREATE OR REPLACE GIT REPOSITORY git_snowflake_semantic_model_generator
API_INTEGRATION = git_api_integration_snowflake_labs
ORIGIN = 'https://github.com/Snowflake-Labs/semantic-model-generator.git';

ALTER GIT REPOSITORY git_snowflake_semantic_model_generator FETCH;

-- Create Schema to host streamlit app
CREATE SCHEMA IF NOT EXISTS CORTEX_ANALYST_SEMANTICS_EVAL.SEMANTIC_MODEL_GENERATOR
COMMENT = '{"origin": "sf_sit",
"name": "skimantics",
"version": {"major": 2, "minor": 0},
"attributes": {"deployment": "sis"}}';


-- Create stage for App logic and 3rd party packages
CREATE OR REPLACE STAGE CORTEX_ANALYST_SEMANTICS_EVAL.SEMANTIC_MODEL_GENERATOR.STREAMLIT_STAGE
DIRECTORY = (ENABLE = true)
COMMENT = '{"origin": "sf_sit",
"name": "skimantics",
"version": {"major": 2, "minor": 0},
"attributes": {"deployment": "sis"}}';

-- Copy Files from Git Repository into App Stage
COPY FILES
INTO @CORTEX_ANALYST_SEMANTICS_EVAL.SEMANTIC_MODEL_GENERATOR.STREAMLIT_STAGE
FROM @CORTEX_ANALYST_SEMANTICS_EVAL.PUBLIC.git_snowflake_semantic_model_generator/branches/customer-eval/app_utils/
PATTERN='.*[.]zip';

COPY FILES
INTO @CORTEX_ANALYST_SEMANTICS_EVAL.SEMANTIC_MODEL_GENERATOR.STREAMLIT_STAGE/semantic_model_generator/
FROM @CORTEX_ANALYST_SEMANTICS_EVAL.PUBLIC.git_snowflake_semantic_model_generator/branches/customer-eval/
FILES = ('environment.yml', 'app.py');

COPY FILES
INTO @CORTEX_ANALYST_SEMANTICS_EVAL.SEMANTIC_MODEL_GENERATOR.STREAMLIT_STAGE/semantic_model_generator/semantic_model_generator/
FROM @CORTEX_ANALYST_SEMANTICS_EVAL.PUBLIC.git_snowflake_semantic_model_generator/branches/customer-eval/semantic_model_generator/
PATTERN='.*[.]py';

RM @CORTEX_ANALYST_SEMANTICS_EVAL.SEMANTIC_MODEL_GENERATOR.STREAMLIT_STAGE/semantic_model_generator/semantic_model_generator/tests;
RM @CORTEX_ANALYST_SEMANTICS_EVAL.SEMANTIC_MODEL_GENERATOR.STREAMLIT_STAGE/semantic_model_generator/semantic_model_generator/output_models;

COPY FILES
INTO @CORTEX_ANALYST_SEMANTICS_EVAL.SEMANTIC_MODEL_GENERATOR.STREAMLIT_STAGE/semantic_model_generator/images/
FROM @CORTEX_ANALYST_SEMANTICS_EVAL.PUBLIC.git_snowflake_semantic_model_generator/branches/customer-eval/images/
PATTERN='.*[.]png';

COPY FILES
INTO @CORTEX_ANALYST_SEMANTICS_EVAL.SEMANTIC_MODEL_GENERATOR.STREAMLIT_STAGE/semantic_model_generator/journeys/
FROM @CORTEX_ANALYST_SEMANTICS_EVAL.PUBLIC.git_snowflake_semantic_model_generator/branches/customer-eval/journeys/
PATTERN='.*[.]py';

COPY FILES
INTO @CORTEX_ANALYST_SEMANTICS_EVAL.SEMANTIC_MODEL_GENERATOR.STREAMLIT_STAGE/semantic_model_generator/partner/
FROM @CORTEX_ANALYST_SEMANTICS_EVAL.PUBLIC.git_snowflake_semantic_model_generator/branches/customer-eval/partner/
PATTERN='.*[.]py';

COPY FILES
INTO @CORTEX_ANALYST_SEMANTICS_EVAL.SEMANTIC_MODEL_GENERATOR.STREAMLIT_STAGE/semantic_model_generator/app_utils/
FROM @CORTEX_ANALYST_SEMANTICS_EVAL.PUBLIC.git_snowflake_semantic_model_generator/branches/customer-eval/app_utils/
PATTERN='.*[.]py';

-- Create Streamlit App
CREATE OR REPLACE STREAMLIT CORTEX_ANALYST_SEMANTICS_EVAL.SEMANTIC_MODEL_GENERATOR.SEMANTIC_MODEL_GENERATOR
ROOT_LOCATION = '@CORTEX_ANALYST_SEMANTICS_EVAL.SEMANTIC_MODEL_GENERATOR.STREAMLIT_STAGE/semantic_model_generator'
MAIN_FILE = 'app.py'
TITLE = "Semantic Model Generator (with Eval)"
IMPORTS = ('@cortex_analyst_semantics_eval.semantic_model_generator.streamlit_stage/looker_sdk.zip',
'@cortex_analyst_semantics_eval.semantic_model_generator.streamlit_stage/strictyaml.zip')
QUERY_WAREHOUSE = $streamlit_warehouse
COMMENT = '{"origin": "sf_sit",
"name": "skimantics",
"version": {"major": 2, "minor": 0},
"attributes": {"deployment": "sis"}}';

0 comments on commit d05b880

Please sign in to comment.