Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a NoteableCredentials block for Prefect #88

Open
ahuang11 opened this issue Dec 8, 2022 · 0 comments
Open

Create a NoteableCredentials block for Prefect #88

ahuang11 opened this issue Dec 8, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@ahuang11
Copy link

ahuang11 commented Dec 8, 2022

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Was taking a look at https://docs.noteable.io/product-docs/work-with-notebooks/scheduling-and-orchestration/prefect.

Perhaps rather than having users add this to their flow:

    # This can be skipped if you are already setting the env variable externally
    token_block = Secret.load('noteable-token')
    os.environ['NOTEABLE_TOKEN'] = token_block.get()
    # Use this domain block if using a custom domain name for your Noteable deployment
    #domain_block = Secret.load('noteable-domain')
    #os.environ['NOTEABLE_DOMAIN'] = token_block.get()

I imagine a NoteableCredentials block

class NoteableCredentials(Block):
    _block_type_logo = ""  # noqa

    token: SecretStr = Field(default=..., description="Token to authenticate with Noteable.")
    domain: Optional[str] = Field(default=None, description="Noteable's notebook domain.")

    def apply(self):
        os.environ['NOTEABLE_TOKEN'] = self.token.get_secret_value()
        if self.domain:
            os.environ['NOTEABLE_DOMAIN'] = self.domain

Then an execute_notebook task:

from prefect import task
from prefect_jupyter import execute_notebook as execute

@task
def execute_notebook(noteable_credentials: NoteableCredentials, url: str, parameters: Dict[str, Any] = None, **execute_kwargs):
    noteable_credentials.apply()
    return execute(
        path=url
        parameters={"end_time": "12-15-22"},
        engine_name="noteable",
        **execute_kwargs
    )
@ahuang11 ahuang11 added the enhancement New feature or request label Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant