コード例 #1
0
def jupyter_run(config,
                notebook=None,
                prepare_only=False,
                param=None,
                param_raw=None):
    """
    Executes the step in browserless mode using papermill

    Parameters
    ----------
    config : str
        path to the configuration file
    notebook : str
        name of node to run, if None, then run the first one
    parameters : list
        List of parameters and their values
    prepare_only : bool
        Indicates if papermill should replace the parameters of the
        notebook only or it should execute all the cells too

    Returns
    -------
    string
        the path to the output notebook resulting from the execution
        of this step
    """
    # TODO implements parameters passing
    if notebook:
        app_config = AiscalatorConfig(config=config, step_selection=notebook)
    else:
        app_config = AiscalatorConfig(config=config)
    return command.jupyter_run(app_config,
                               prepare_only=prepare_only,
                               param=param,
                               param_raw=param_raw)
コード例 #2
0
def push(conf, notebook):
    """Push a job into the DAGS folder to schedule in Airflow."""
    if notebook:
        for note in notebook:
            app_config = AiscalatorConfig(config=conf,
                                          dag_selection=note)
            click.echo(command.airflow_push(app_config))
    else:
        app_config = AiscalatorConfig(config=conf)
        click.echo(command.airflow_push(app_config))
コード例 #3
0
ファイル: cli.py プロジェクト: elishowk/aiscalator
def run(conf, notebook, param, param_raw):
    """Run the notebook from an aiscalate config without GUI."""
    if notebook:
        for note in notebook:
            app_config = AiscalatorConfig(config=conf, step_selection=note)
            click.echo(
                command.jupyter_run(app_config,
                                    param=param,
                                    param_raw=param_raw))
    else:
        app_config = AiscalatorConfig(config=conf)
        click.echo(
            command.jupyter_run(app_config, param=param, param_raw=param_raw))
コード例 #4
0
def start():
    """Start docker images to bring airflow services up."""
    click.echo(command.airflow_up(AiscalatorConfig()))
    click.echo("""
Airflow: http://localhost:8080
Flower: http://localhost:5555
               """)
コード例 #5
0
def edit(conf, notebook):
    """Edit DAG job"""
    if len(notebook) < 2:
        notebook = notebook[0] if notebook else None
        app_config = AiscalatorConfig(config=conf,
                                      dag_selection=notebook)
        click.echo(command.airflow_edit(app_config))
    else:
        raise click.BadArgumentUsage("Expecting one or less notebook names")
コード例 #6
0
ファイル: cli.py プロジェクト: elishowk/aiscalator
def edit(conf, notebook, param, param_raw):
    """Edit the notebook from an aiscalate config with JupyterLab."""
    if len(notebook) < 2:
        notebook = notebook[0] if notebook else None
        app_config = AiscalatorConfig(config=conf, step_selection=notebook)
        click.echo(
            command.jupyter_edit(app_config, param=param, param_raw=param_raw))
    else:
        raise click.BadArgumentUsage("Expecting one or less notebook names")
コード例 #7
0
ファイル: cli.py プロジェクト: elishowk/aiscalator
def prompt_edit(file):
    """
    When creating a new step, if it is already defined,
    ask to edit instead

    Parameters
    ----------
    file : str
        existing configuration file

    """
    msg = file + ' already exists. Did you mean to run:\n'
    for i in sys.argv:
        if i != "new":
            msg += i + ' '
        else:
            break
    msg += "edit " + file + " instead?"
    if click.confirm(msg, abort=True):
        conf = AiscalatorConfig(config=file)
        click.echo(command.jupyter_edit(conf))
コード例 #8
0
def jupyter_new(name, path, output_format="hocon"):
    """
    Starts a Jupyter Lab environment configured to edit a brand new step

    Parameters
    ----------
    name : str
        name of the new step
    path : str
        path to where the new step files should be created
    output_format : str
        the format of the new configuration file to produce
    Returns
    -------
    string
        Url of the running jupyter lab
    """
    step_file = os.path.join(path, name, name) + '.conf'
    if os.path.dirname(step_file):
        makedirs(os.path.dirname(step_file), exist_ok=True)
    copy_replace(data_file("../config/template/step.conf"),
                 step_file,
                 pattern="Untitled",
                 replace_value=name)
    if output_format != 'hocon':
        file = os.path.join(path, name, name) + '.' + output_format
        step_file = convert_to_format(step_file,
                                      output=file,
                                      output_format=output_format)

    notebook = os.path.join(path, name, 'notebook', name) + '.ipynb'
    if os.path.dirname(notebook):
        makedirs(os.path.dirname(notebook), exist_ok=True)
    copy_replace(data_file("../config/template/notebook.json"), notebook)

    open(os.path.join(path, name, "apt_repository.txt"), 'a').close()
    open(os.path.join(path, name, "apt_packages.txt"), 'a').close()
    open(os.path.join(path, name, "requirements.txt"), 'a').close()
    open(os.path.join(path, name, "lab_extensions.txt"), 'a').close()
    jupyter_edit(AiscalatorConfig(config=step_file, step_selection=name))
コード例 #9
0
def test_prepare_docker_image_env_extra_options():
    """Test the _prepare_docker_image_env."""
    options_list = command._prepare_docker_image_env(
        AiscalatorConfig("tests/jupyter/sample_pyhocon.conf"))
    'bridge' == options_list[-1]
    '--network' == options_list[-2]
コード例 #10
0
def run(service, subcommand):
    """Run sub-command in a running docker service."""
    if not subcommand:
        subcommand = None
    click.echo(command.airflow_cmd(AiscalatorConfig(),
                                   service=service, cmd=subcommand))
コード例 #11
0
def stop():
    """Stop docker images to bring airflow services down."""
    click.echo(command.airflow_down(AiscalatorConfig()))
コード例 #12
0
def setup(config_home, append, workspace):
    """Setup interactively the Airflow home folder and configurations."""
    click.echo(command.airflow_setup(AiscalatorConfig(),
                                     config_home, workspace,
                                     append=append))