Coder Social home page Coder Social logo

alessandrolollo / prefect-transform Goto Github PK

View Code? Open in Web Editor NEW
7.0 7.0 0.0 670 KB

Collection of tasks to interact with Transform metrics catalog

Home Page: https://alessandrolollo.github.io/prefect-transform

License: Apache License 2.0

Python 100.00%

prefect-transform's People

Contributors

alessandrolollo avatar alollo-ca avatar dependabot[bot] avatar desertaxle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

prefect-transform's Issues

Moving user auth kwargs in create_materialization to credentials.py

    # Raise error if both api_key and api_key_env_var are missing
    if not (api_key or api_key_env_var):
        msg = "Both `api_key` and `api_key_env_var` are missing."
        raise TransformConfigurationException(msg)

    # Raise error if api_key is missing and env var is not found
    if not api_key and api_key_env_var not in os.environ.keys():
        msg = "`api_key` is missing and `api_key_env_var` not found in env vars."
        raise TransformConfigurationException(msg)

    # Raise error if both mql_server_url and mql_server_url_env_var are missing
    if not (mql_server_url or mql_server_url_env_var):
        msg = "Both `mql_server_url` and `mql_server_url_env_var` are missing."
        raise TransformConfigurationException(msg)

    # Raise error if mql_server_url is missing and env var is not found
    if not mql_server_url and mql_server_url_env_var not in os.environ.keys():
        msg = """
        `mql_server_url` is missing and `mql_server_url_env_var` not found in env vars.
        """
        raise TransformConfigurationException(msg)

    if not materialization_name:
        msg = "`materialization_name` is missing."
        raise TransformConfigurationException(msg)

    mql_api_key = api_key or os.environ[api_key_env_var]
    mql_url = mql_server_url or os.environ[mql_server_url_env_var]
    use_async = not wait_for_creation

    try:
        mql_client = MQLClient(
            api_key=mql_api_key, mql_server_url=mql_url, use_async=use_async
        )
    except (AuthException, URLException) as e:
        msg = f"Cannot connect to Transform server! Error is: {e.msg}"
        raise TransformAuthException(msg)

I think this would be well suited in a credentials.py file so you can take advantage of blocks.

I imagine something like

class TransformCredentials(Block):

    api_key: Optional[str] = None
    api_key_env_var: Optional[str] = None
    mql_server_url: Optional[str] = None
    mql_server_url_env_var: Optional[str] = None

    # some validator like https://github.com/PrefectHQ/prefect-aws/blob/main/prefect_aws/s3.py#L266-L302

    def get_client(self):
        ...

Updating the default README Example

Thanks for expanding the Prefect ecosystem!

I noticed the example on the README is still the default example. Perhaps that can be updated to reflect how to use "create_materialization"

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.