Skip to content

Commit

Permalink
Fix pydantic version (#598)
Browse files Browse the repository at this point in the history
* Fix pydantic version
  • Loading branch information
rymurr authored Mar 28, 2024
1 parent 2628d69 commit 3cd8711
Show file tree
Hide file tree
Showing 15 changed files with 60 additions and 58 deletions.
Binary file added app/ui/crud.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion app/ui/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ dependencies:
- snowflake-native-apps-permission
- snowflake-telemetry-python
- streamlit=1.22.0
- pydantic
- pydantic=1.*
- pytz
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import streamlit as st
import sthelp

sthelp.chrome("Probes")
sthelp.chrome("Query Monitor")
st.sidebar.title("Sundeck OpsCenter")

# Load custom OpsCenter python modules
Expand Down
34 changes: 18 additions & 16 deletions app/ui/probes.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def list_probes(self):
"probes",
"list",
)
st.title("Query Probes")
st.title("Query Monitors")
st.markdown(
"""
#### Alert or cancel suspect query patterns
Expand All @@ -48,9 +48,9 @@ def list_probes(self):
with st.sidebar.container():
st.markdown(
"""
#### Probe Details
#### Query Monitors Details
##### Execution Frequency
Probes are executed by default every 1 minute.
Query Monitors are executed by default every 1 minute.
##### Alert Behavior
To enable email alerting behavior, you must first configure the email settings in the Settings page.
Expand All @@ -62,7 +62,7 @@ def list_probes(self):

if len(data) == 0:
st.write(
"No probes defined. Probes help you categorize alert and cancel running queries."
"No probes defined. Query Monitors help you categorize alert and cancel running queries."
)
st.button(
"New", key="create", on_click=self.session.do_create, args=[dict()]
Expand Down Expand Up @@ -165,9 +165,9 @@ def on_create_click(
return

except pydantic.ValidationError as ve:
outcome = error_to_markdown("Error validating Probe.", ve)
outcome = error_to_markdown("Error validating Query Monitor.", ve)
except AssertionError as ae:
outcome = f"Error validating Probe. \n\n{str(ae)}"
outcome = f"Error validating Query Monitor. \n\n{str(ae)}"

self.status.error(outcome)

Expand Down Expand Up @@ -209,13 +209,13 @@ def on_update_click(
outcome = old_probe.update(txn, new_probe)

if outcome is None:
self.session.set_toast("Probe updated.")
self.session.set_toast("Query Monitor updated.")
self.session.do_list()
return
except pydantic.ValidationError as ve:
outcome = error_to_markdown("Error validating Probe.", ve)
outcome = error_to_markdown("Error validating Query Monitor.", ve)
except AssertionError as ae:
outcome = f"Error validating Probe. \n\n{str(ae)}"
outcome = f"Error validating Query Monitor. \n\n{str(ae)}"

self.status.error(outcome)

Expand All @@ -231,15 +231,15 @@ def on_delete_click(self, name):
del_probe = ModelProbe.construct(name=name)
del_probe.delete(txn)

self.session.set_toast("Probe deleted.")
self.session.set_toast("Query Monitor deleted.")
self.session.do_list()

def create_probe(self):
st.title("New Probe")
st.title("New Query Monitor")

name = st.text_input(key="NAME", label="Probe Name")
name = st.text_input(key="NAME", label="Query Monitor Name")
condition = st.text_area(key="CONDITION", label="Condition")
with st.expander("When Probe Matches:", expanded=True):
with st.expander("When Query Monitor Matches:", expanded=True):
notify_writer = st.checkbox(key="NOTIFY_WRITER", label="Notify the author")
notify_writer_method = st.radio(
key="NOTIFY_WRITER_METHOD",
Expand Down Expand Up @@ -273,12 +273,14 @@ def create_probe(self):
st.button("Cancel", on_click=self.session.do_list)

def edit_probe(self, update: dict):
st.title("Edit Probe")
name = st.text_input(key="NAME", label="Probe Name", value=update["name"])
st.title("Edit Query Monitor")
name = st.text_input(
key="NAME", label="Query Monitor Name", value=update["name"]
)
condition = st.text_area(
key="CONDITION", label="Condition", value=update["condition"]
)
with st.expander("When Probe Matches:", expanded=True):
with st.expander("When Query Monitor Matches:", expanded=True):
notify_writer = st.checkbox(
key="NOTIFY_WRITER",
label="Notify the author",
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/0035_python_tools.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CREATE OR REPLACE PROCEDURE INTERNAL_PYTHON.CREATE_TABLE(name text)
language python
runtime_version = "3.10"
handler = 'create_table'
packages = ('snowflake-snowpark-python', 'pydantic', 'snowflake-telemetry-python')
packages = ('snowflake-snowpark-python', 'pydantic==1.*', 'snowflake-telemetry-python')
imports = ('{{stage}}/python/crud.zip')
EXECUTE AS OWNER
AS
Expand Down
14 changes: 7 additions & 7 deletions bootstrap/004_labels.sql
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ CREATE OR REPLACE PROCEDURE ADMIN.CREATE_LABEL(name text, grp text, rank number,
language python
runtime_version = "3.10"
handler = 'create_label'
packages = ('snowflake-snowpark-python', 'pydantic', 'snowflake-telemetry-python')
packages = ('snowflake-snowpark-python', 'pydantic==1.*', 'snowflake-telemetry-python')
imports = ('{{stage}}/python/crud.zip')
EXECUTE AS OWNER
AS
Expand All @@ -136,7 +136,7 @@ CREATE OR REPLACE PROCEDURE ADMIN.CREATE_LABEL(name text, grp text, rank number,
language python
runtime_version = "3.10"
handler = 'create_label'
packages = ('snowflake-snowpark-python', 'pydantic', 'snowflake-telemetry-python')
packages = ('snowflake-snowpark-python', 'pydantic==1.*', 'snowflake-telemetry-python')
imports = ('{{stage}}/python/crud.zip')
EXECUTE AS OWNER
AS
Expand Down Expand Up @@ -178,7 +178,7 @@ CREATE OR REPLACE PROCEDURE ADMIN.DELETE_LABEL(name text)
language python
runtime_version = "3.10"
handler = 'delete_label'
packages = ('snowflake-snowpark-python', 'pydantic', 'snowflake-telemetry-python')
packages = ('snowflake-snowpark-python', 'pydantic==1.*', 'snowflake-telemetry-python')
imports = ('{{stage}}/python/crud.zip')
EXECUTE AS OWNER
AS
Expand All @@ -194,7 +194,7 @@ CREATE OR REPLACE PROCEDURE ADMIN.DELETE_DYNAMIC_LABEL(name text)
language python
runtime_version = "3.10"
handler = 'delete_label'
packages = ('snowflake-snowpark-python', 'pydantic', 'snowflake-telemetry-python')
packages = ('snowflake-snowpark-python', 'pydantic==1.*', 'snowflake-telemetry-python')
imports = ('{{stage}}/python/crud.zip')
EXECUTE AS OWNER
AS
Expand All @@ -209,7 +209,7 @@ CREATE OR REPLACE PROCEDURE ADMIN.UPDATE_LABEL(oldname text, name text, grp text
language python
runtime_version = "3.10"
handler = 'update_label'
packages = ('snowflake-snowpark-python', 'pydantic', 'snowflake-telemetry-python')
packages = ('snowflake-snowpark-python', 'pydantic==1.*', 'snowflake-telemetry-python')
imports = ('{{stage}}/python/crud.zip')
EXECUTE AS OWNER
AS
Expand All @@ -226,7 +226,7 @@ CREATE OR REPLACE PROCEDURE ADMIN.UPDATE_LABEL(oldname text, name text, grp text
language python
runtime_version = "3.10"
handler = 'update_label'
packages = ('snowflake-snowpark-python', 'pydantic', 'snowflake-telemetry-python')
packages = ('snowflake-snowpark-python', 'pydantic==1.*', 'snowflake-telemetry-python')
imports = ('{{stage}}/python/crud.zip')
EXECUTE AS OWNER
AS
Expand Down Expand Up @@ -303,7 +303,7 @@ CREATE OR REPLACE PROCEDURE INTERNAL_PYTHON.VALIDATE_PREDEFINED_LABELS()
LANGUAGE PYTHON
runtime_version = "3.10"
handler = 'validate_predefined_labels'
packages = ('snowflake-snowpark-python', 'pydantic', 'snowflake-telemetry-python')
packages = ('snowflake-snowpark-python', 'pydantic==1.*', 'snowflake-telemetry-python')
imports = ('{{stage}}/python/crud.zip')
EXECUTE AS OWNER
AS
Expand Down
6 changes: 3 additions & 3 deletions bootstrap/007_probes.sql
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ CREATE OR REPLACE PROCEDURE ADMIN.CREATE_QUERY_MONITOR(name text, condition text
LANGUAGE PYTHON
runtime_version = "3.10"
handler = 'create_probe'
packages = ('snowflake-snowpark-python', 'pydantic', 'snowflake-telemetry-python')
packages = ('snowflake-snowpark-python', 'pydantic==1.*', 'snowflake-telemetry-python')
imports = ('{{stage}}/python/crud.zip')
EXECUTE AS OWNER
AS
Expand All @@ -220,7 +220,7 @@ CREATE OR REPLACE PROCEDURE ADMIN.DELETE_QUERY_MONITOR(name text)
LANGUAGE PYTHON
runtime_version = "3.10"
handler = 'delete_probe'
packages = ('snowflake-snowpark-python', 'pydantic', 'snowflake-telemetry-python')
packages = ('snowflake-snowpark-python', 'pydantic==1.*', 'snowflake-telemetry-python')
imports = ('{{stage}}/python/crud.zip')
EXECUTE AS OWNER
AS
Expand All @@ -236,7 +236,7 @@ CREATE OR REPLACE PROCEDURE ADMIN.UPDATE_QUERY_MONITOR(oldname text, name text,
LANGUAGE PYTHON
runtime_version = "3.10"
handler = 'update_probe'
packages = ('snowflake-snowpark-python', 'pydantic', 'snowflake-telemetry-python')
packages = ('snowflake-snowpark-python', 'pydantic==1.*', 'snowflake-telemetry-python')
imports = ('{{stage}}/python/crud.zip')
EXECUTE AS OWNER
AS
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/009_register.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ CREATE OR REPLACE PROCEDURE ADMIN.REGISTER()
LANGUAGE python
runtime_version="3.10"
handler='run'
packages = ('snowflake-snowpark-python', 'pydantic', 'snowflake-telemetry-python')
packages = ('snowflake-snowpark-python', 'pydantic==1.*', 'snowflake-telemetry-python')
imports = ('{{stage}}/python/crud.zip')
as
$$
Expand Down
14 changes: 7 additions & 7 deletions bootstrap/011_warehouse_schedules.sql
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ CREATE OR REPLACE PROCEDURE ADMIN.CREATE_WAREHOUSE_SCHEDULE(warehouse_name text,
LANGUAGE PYTHON
runtime_version = "3.10"
handler = 'create_warehouse_schedule'
packages = ('snowflake-snowpark-python', 'pydantic', 'snowflake-telemetry-python')
packages = ('snowflake-snowpark-python', 'pydantic==1.*', 'snowflake-telemetry-python')
imports = ('{{stage}}/python/crud.zip')
EXECUTE AS OWNER
AS
Expand Down Expand Up @@ -222,7 +222,7 @@ CREATE OR REPLACE PROCEDURE ADMIN.DELETE_WAREHOUSE_SCHEDULE(name text, start_at
LANGUAGE PYTHON
runtime_version = "3.10"
handler = 'run_delete'
packages = ('snowflake-snowpark-python', 'pydantic', 'snowflake-telemetry-python')
packages = ('snowflake-snowpark-python', 'pydantic==1.*', 'snowflake-telemetry-python')
imports = ('{{stage}}/python/crud.zip')
EXECUTE AS OWNER
AS
Expand Down Expand Up @@ -257,7 +257,7 @@ CREATE OR REPLACE PROCEDURE ADMIN.UPDATE_WAREHOUSE_SCHEDULE(warehouse_name text,
LANGUAGE PYTHON
runtime_version = "3.10"
handler = 'update_warehouse_schedule'
packages = ('snowflake-snowpark-python', 'pydantic', 'snowflake-telemetry-python')
packages = ('snowflake-snowpark-python', 'pydantic==1.*', 'snowflake-telemetry-python')
imports = ('{{stage}}/python/crud.zip')
EXECUTE AS OWNER
AS
Expand Down Expand Up @@ -311,7 +311,7 @@ CREATE OR REPLACE PROCEDURE ADMIN.ENABLE_WAREHOUSE_SCHEDULING(warehouse_name tex
LANGUAGE PYTHON
runtime_version = "3.10"
handler = 'run'
packages = ('snowflake-snowpark-python', 'pydantic', 'snowflake-telemetry-python')
packages = ('snowflake-snowpark-python', 'pydantic==1.*', 'snowflake-telemetry-python')
imports = ('{{stage}}/python/crud.zip')
EXECUTE AS OWNER
AS
Expand All @@ -330,7 +330,7 @@ CREATE OR REPLACE PROCEDURE ADMIN.DISABLE_WAREHOUSE_SCHEDULING(warehouse_name te
LANGUAGE PYTHON
runtime_version = "3.10"
handler = 'run'
packages = ('snowflake-snowpark-python', 'pydantic', 'snowflake-telemetry-python')
packages = ('snowflake-snowpark-python', 'pydantic==1.*', 'snowflake-telemetry-python')
imports = ('{{stage}}/python/crud.zip')
EXECUTE AS OWNER
AS
Expand All @@ -348,7 +348,7 @@ CREATE OR REPLACE PROCEDURE ADMIN.CREATE_DEFAULT_SCHEDULES(warehouse_name text)
LANGUAGE PYTHON
runtime_version = "3.10"
handler = 'run'
packages = ('snowflake-snowpark-python', 'pydantic', 'snowflake-telemetry-python')
packages = ('snowflake-snowpark-python', 'pydantic==1.*', 'snowflake-telemetry-python')
imports = ('{{stage}}/python/crud.zip')
EXECUTE AS OWNER
AS
Expand Down Expand Up @@ -383,7 +383,7 @@ CREATE OR REPLACE PROCEDURE ADMIN.RESET_WAREHOUSE_SCHEDULE(warehouse_name text)
LANGUAGE PYTHON
runtime_version = "3.10"
handler = 'run'
packages = ('snowflake-snowpark-python', 'pydantic', 'snowflake-telemetry-python')
packages = ('snowflake-snowpark-python', 'pydantic==1.*', 'snowflake-telemetry-python')
imports = ('{{stage}}/python/crud.zip')
EXECUTE AS OWNER
AS
Expand Down
6 changes: 3 additions & 3 deletions bootstrap/050_settings.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ CREATE OR REPLACE PROCEDURE ADMIN.UPDATE_SETTING(name TEXT, value TEXT)
LANGUAGE PYTHON
RUNTIME_VERSION = "3.10"
HANDLER = 'run'
PACKAGES = ('snowflake-snowpark-python', 'pydantic')
PACKAGES = ('snowflake-snowpark-python', 'pydantic==1.*')
IMPORTS = ('{{stage}}/python/crud.zip')
EXECUTE AS OWNER
AS
Expand All @@ -38,7 +38,7 @@ CREATE OR REPLACE PROCEDURE ADMIN.ENABLE_TASK(name TEXT)
LANGUAGE PYTHON
RUNTIME_VERSION = "3.10"
HANDLER = 'run'
PACKAGES = ('snowflake-snowpark-python', 'pydantic')
PACKAGES = ('snowflake-snowpark-python', 'pydantic==1.*')
IMPORTS = ('{{stage}}/python/crud.zip')
EXECUTE AS OWNER
AS
Expand All @@ -59,7 +59,7 @@ CREATE OR REPLACE PROCEDURE ADMIN.DISABLE_TASK(name TEXT)
LANGUAGE PYTHON
RUNTIME_VERSION = "3.10"
HANDLER = 'run'
PACKAGES = ('snowflake-snowpark-python', 'pydantic')
PACKAGES = ('snowflake-snowpark-python', 'pydantic==1.*')
IMPORTS = ('{{stage}}/python/crud.zip')
EXECUTE AS OWNER
AS
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/Probes/probes.spec.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe("Probes section", () => {
});

beforeEach(() => {
cy.visit("/Probes");
cy.visit("/Query_Monitors");

checkInitialLoading();
checkNoErrorOnThePage();
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/Probes/tests/probesPageTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const ProbesCRUDTests = () => {
notifyOthers: PROBE_EMAIL_OTHERS,
});
buttonClick(BUTTON_TEXT.CREATE);
checkOnCorrectPage({ headerText: "Query Probes" });
checkOnCorrectPage({ headerText: "Query Monitors" });
checkProbeAndValuesExistInProbesList({
doesExist: true,
probeName: probe_1,
Expand Down Expand Up @@ -62,7 +62,7 @@ export const ProbesCRUDTests = () => {
notifyOthers: PROBE_SLACK_OTHERS,
});
buttonClick(BUTTON_TEXT.UPDATE);
checkOnCorrectPage({ headerText: "Query Probes" });
checkOnCorrectPage({ headerText: "Query Monitors" });
checkProbeAndValuesExistInProbesList({
doesExist: true,
probeName: probe_2,
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/Probes/utils/probeTestConstants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const PROBE_FORM_FIELDS = {
PROBE_NAME: "Probe Name",
PROBE_NAME: "Query Monitor Name",
CONDITION: "Condition",
NOTIFY_AUTHOR: "Notify the author",
EMAIL: "Email",
Expand All @@ -13,4 +13,4 @@ export const PROBE_CONDITION_TEXT_2 = "query_text='%tpch_sf50%'";
export const PROBE_EMAIL_OTHERS = "vicky@sundeck.io, jinfeng@sundeck.io";
export const PROBE_SLACK_OTHERS = "susannah";

export const PROBE_DELETED_NOTIFICATION_TEXT = "Probe deleted";
export const PROBE_DELETED_NOTIFICATION_TEXT = "Query Monitor deleted";
8 changes: 4 additions & 4 deletions cypress/support/testConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const MENU_TEXT = {
SETTINGS: "Settings",
WAREHOUSES: "Warehouses",
QUERIES: "Queries",
PROBES: "Probes",
PROBES: "Query Monitors",
LABS: "Labs",
};

Expand All @@ -22,7 +22,7 @@ export const HEADER_TEXT = {
HOME: "Welcome To Sundeck OpsCenter",
CREATE_LABEL: "New Label",
UPDATE_LABEL: "Edit Label",
PROBES: "Query Probes",
CREATE_PROBE: "New Probe",
UPDATE_PROBE: "Edit Probe",
PROBES: "Query Monitors",
CREATE_PROBE: "New Query Monitor",
UPDATE_PROBE: "Edit Query Monitor",
};
18 changes: 9 additions & 9 deletions test/unit/test_materialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ def test_query_history_migration(conn):
# Verify that the columns are in the correct order after running MIGRATE_QUERIES
query = (
"select column_name, data_type from information_schema.columns where table_schema = "
+ "'INTERNAL_REPORTING_MV' and table_name = 'QUERY_HISTORY_COMPLETE_AND_DAILY' order by ordinal_position desc limit 4;"
+ "'INTERNAL_REPORTING_MV' and table_name = 'QUERY_HISTORY_COMPLETE_AND_DAILY' order by ordinal_position desc limit 9;"
)
rows = cur.execute(query).fetchall()
assert rows[0][0] == "QUERY_PARAMETERIZED_HASH_VERSION"
assert rows[0][1] == "NUMBER"
assert rows[-4][0] == "QUERY_PARAMETERIZED_HASH_VERSION"
assert rows[-4][1] == "NUMBER"

assert rows[1][0] == "QUERY_PARAMETERIZED_HASH"
assert rows[1][1] == "TEXT"
assert rows[-3][0] == "QUERY_PARAMETERIZED_HASH"
assert rows[-3][1] == "TEXT"

assert rows[2][0] == "QUERY_HASH_VERSION"
assert rows[2][1] == "NUMBER"
assert rows[-2][0] == "QUERY_HASH_VERSION"
assert rows[-2][1] == "NUMBER"

assert rows[3][0] == "QUERY_HASH"
assert rows[3][1] == "TEXT"
assert rows[-1][0] == "QUERY_HASH"
assert rows[-1][1] == "TEXT"

0 comments on commit 3cd8711

Please sign in to comment.