Skip to content

Create a NoteableCredentials block for Prefect #88

Description

@ahuang11

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
    )

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions