alessandrolollo / prefect-transform Goto Github PK
View Code? Open in Web Editor NEWCollection of tasks to interact with Transform metrics catalog
Home Page: https://alessandrolollo.github.io/prefect-transform
License: Apache License 2.0
Collection of tasks to interact with Transform metrics catalog
Home Page: https://alessandrolollo.github.io/prefect-transform
License: Apache License 2.0
# 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):
...
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"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.