Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion avalanche/initialize_system/initialize_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def create_all_schema_objects(snowflake_conn: snowflake_connector_connection.Sno


def get_avalanche_schema(config:dict) -> str:
"""reads the config and gets the avalanche_schema valye"""
"""reads the config and gets the avalanche_schema value"""
avalanche_schema = config.get("avalanche_schema", None)
if not avalanche_schema :
raise KeyError("avalanche_schema key is missing in the config - check the `init_config.yaml` and config that entry exists and has valid schema name value")
Expand Down Expand Up @@ -257,6 +257,14 @@ def parse_command_line_args():
"role": args.role
}


def set_environment_variables_based_on_config(avalanche_db: str, avalanche_schema: str):
""" Since the next step is going to emulate an actual avalanche setup - it needs some environment variables to be
set or it will use defaults . To avoid potential confusion we will set it based on the init_configs value"""
os.environ[ConnectionManager.AVALANCHE_SNOWFLAKE_DB_DATABASE] = avalanche_db
os.environ[ConnectionManager.AVALANCHE_SNOWFLAKE_DB_SCHEMA] = avalanche_schema


def main():

command_line_args = parse_command_line_args()
Expand All @@ -281,6 +289,7 @@ def main():
load_data_to_snowflake(df, conn, "DATATYPE_MAPPING_CONFIG")
insert_default_datatype_mapping_group_config(snowflake_conn=conn)

set_environment_variables_based_on_config(avalanche_db=config["database"], avalanche_schema=avalanche_schema)
initialize_sample_data(snowflake_conn=conn,avalanche_executor_role=config.get("avalanche_executor_role"))


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@


create role if not exists {{avalanche_executor_role}};
grant usage on database {{database}} to role {{avalanche_executor_role}};
grant usage on schema {{avalanche_schema}} to role {{avalanche_executor_role}};
grant create function on schema {{avalanche_schema}} to role {{avalanche_executor_role}};
grant create procedure on schema {{avalanche_schema}} to role {{avalanche_executor_role}};
Expand Down