Giter Site home page Giter Site logo

titan-systems / titan Goto Github PK

View Code? Open in Web Editor NEW
274.0 8.0 14.0 1.87 MB

Snowflake infrastructure-as-code. Provision environments, automate deploys, CI/CD. Manage RBAC, users, roles, and data access. Declarative Python Resource API. Change Management tool for the Snowflake data warehouse.

License: Apache License 2.0

Python 99.89% Makefile 0.11%
data-engineering data-warehouse snowflake data-governance dataops secops compliance-as-code devops rbac

titan's People

Contributors

jamesweakley avatar teej avatar titan-teej avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

titan's Issues

Incorrect behaviour in Jupyter notebooks due to caching

I've been experimenting with Titan in a Jupyter notebook, was seeing some strange behaviour where roles were attempting to be created again.
Realised that SHOW ROLES LIKE .... etc were not actually running and found the @cache attributes.

If the cache is cleared at the start of each plan(), I figure it will all work fine in Jupyter.

Support Other Dialects

Currently all the resources are for Snowflake. Are their plans to write resources for other backends?

UnboundLocalError in Install script

When following the install instructions and executing the below an exception is thrown.:

EXECUTE IMMEDIATE
  FROM @titan.public.titan_aws/install;

Response from Snowflake is shown below.
Currently the project seems to not to be installable.

Python Interpreter Error:
Traceback (most recent call last):
  File "/home/udf/501152416749/titan-0.1.1.zip/titan/spi.py", line 72, in install
    session_ctx = dp.fetch_session(conn)
  File "/home/udf/501152416749/titan-0.1.1.zip/titan/data_provider.py", line 160, in fetch_session
    session_obj = execute(
  File "/home/udf/501152416749/titan-0.1.1.zip/titan/client.py", line 72, in execute
    return _execute(session, sql, use_role)
  File "/home/udf/501152416749/titan-0.1.1.zip/titan/client.py", line 51, in _execute
    print(f"[{session.user}:{session.role}] >", sql_text, end="")
UnboundLocalError: local variable 'session' referenced before assignment
 in function INSTALL with handler titan.spi.install

Renaming resources isn't ordered correctly

Renaming resources in a plan that changes other

ALTER USER aaa RENAME TO bbb;
ALTER USER aaa SET LOGIN_NAME = 'bbb'; # fails

Either the rename should propagate to the other alters (hard) or it should be sequenced last (easier).

Using Grant resource returns a TypeError

I have the following code:

import os

import snowflake.connector
from titan import Blueprint
from titan.resources import Database, Grant, Role, RoleGrant, Warehouse

connection_params = {
    "account": os.environ["SNOWFLAKE_ACCOUNT"],
    "user": os.environ["SNOWFLAKE_USER"],
    "password": os.environ["SNOWFLAKE_PASSWORD"],
}

DEFAULT_WAREHOUSE_OPTIONS = {
    "warehouse_size": "XSMALL",
    "auto_suspend": 60,
    "min_cluster_count": 1,
    "max_cluster_count": 1,
}


def dbt():

    prod_db = Database(name="ANALYTICS")

    transforming_wh = Warehouse(
        name="TRANSFORMING_DPG_WH",
        comment="Warehouse used for transformation workloads.",
        **DEFAULT_WAREHOUSE_OPTIONS,
    )

    transformer_role = Role(
        name="TRANSFORMER_ROLE",
        comment=f"Able to read from and write to {prod_db.name} database.",
    )

    grants = [
        RoleGrant(role=transformer_role, to_role="SYSADMIN"),
        Grant(priv="USAGE", on=prod_db, to=transformer_role),
    ]

    return (
        prod_db,
        transforming_wh,
        transformer_role,
        *grants,
    )


if __name__ == "__main__":
    bp = Blueprint(name="setup-dbt", account=os.environ["SNOWFLAKE_ACCOUNT"])
    bp.add(*dbt())
    session = snowflake.connector.connect(**connection_params)
    plan = bp.plan(session)

    # Update snowflake to match blueprint
    bp.apply(session, plan)

When I run this script, I get back the following error:

  File "/Users/dpg/personal/snowflake-dbt-demo-new/.venv/lib/python3.9/site-packages/titan/identifiers.py", line 38, in <listcomp>
    params = "?" + "&".join([f"{k.lower()}={v}" for k, v in self.params.items()]) if self.params else ""
TypeError: __format__ must return a str, not FQN

When I remove the lone Grant resource within my grants variable, I don't have any issues. I may also just be doing something wrong, so apologize in advance if that's the case. Appreciate any help!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.