Example #1
0
def unflag(output_id: str = "", all: bool = False, address: str = ""):
    """
    Command to set flag property of an output_id or all output_ids to false.
    """
    # Check if set --all and --output_id
    if all and output_id:
        raise click.ClickException(
            "Can set either --all=True or specify an "
            "--output_id. Cannot set both."
        )

    if not all and not output_id:
        raise click.ClickException(
            "Need to either set --all=True or specify "
            "an --output_id to unflag."
        )

    # Set address
    if address and len(address) > 0:
        set_address(address)

    if all:
        unflag_all()

    elif not all and output_id:
        unflag_output_id(output_id)
Example #2
0
def flag(output_id: str, address: str = ""):
    """
    Command to set the flag property of an output_id to true.
    """
    # Set address
    if address and len(address) > 0:
        set_address(address)
    flag_output_id(output_id)
Example #3
0
def clear(address: str = ""):
    """
    Command to delete all elements in the db.
    """
    # Set address
    if address and len(address) > 0:
        set_address(address)

    clean_db()
Example #4
0
def inspect(component_run_id, address: str = ""):
    """
    CLI to inspect a specific component run id.
    """
    # Set address
    if address and len(address) > 0:
        set_address(address)

    show_info_card(component_run_id)
Example #5
0
def history(component_name: str, limit: int, address: str = ""):
    """
    CLI for history of ComponentName.
    """
    # Set address
    if address and len(address) > 0:
        set_address(address)
    history = (get_history(component_name, limit)
               if limit else get_history(component_name))
    show_history(history)
Example #6
0
def labels(address: str = ""):
    """
    Command to list all labels.
    """
    # Set address
    if address and len(address) > 0:
        set_address(address)

    labels = get_labels()
    for label in labels:
        click.echo(f"{label}")
Example #7
0
def recent(limit: int, address: str = ""):
    """
    CLI for recent objects.
    """
    # Set address
    if address and len(address) > 0:
        set_address(address)
    # Get the recent ids
    component_run_ids = get_recent_run_ids()
    for id in component_run_ids[:limit]:
        show_info_card(id)
Example #8
0
def retract(label_id: str, delete: bool = False, address: str = ""):
    """
    Command to retract a label.
    """
    # Set address
    if address and len(address) > 0:
        set_address(address)

    # TODO (shreyashankar): if delete is true, delete all artifacts
    # that correspond to the label

    retract_label(label_id)
Example #9
0
def tags(address: str = ""):
    """
    Command to list all the tags currently used.
    """
    # Set address
    if address and len(address) > 0:
        set_address(address)

    # Get all tags, automatically unique
    all_tags = get_tags()

    for tag in all_tags:
        click.echo(f"{tag}")
Example #10
0
def trace(output_id: str, address: str = ""):
    """
    CLI for trace.
    """
    # Set address
    if address and len(address) > 0:
        set_address(address)
    res = web_trace(output_id)
    click.echo(res[0]["label"])
    if "childNodes" in res[0].keys():
        show_res(
            res=res[0]["childNodes"], indent=1, count=0, pos=0, need_stick=0
        )
Example #11
0
def list_retracted(address: str = ""):
    """
    Command to list retracted labels.
    """
    # Set address
    if address and len(address) > 0:
        set_address(address)

    labels = retrieve_retracted_labels()
    for label in labels:
        lname, ddate = label
        click.echo(f"Name: {lname}")
        click.echo(f"└─Deleted: {ddate}")
        click.echo()
Example #12
0
def retrieve(label_id: str, address: str = ""):
    """
    Command to retrieve artifacts for a label.
    """
    # Set address
    if address and len(address) > 0:
        set_address(address)

    io_pointers = retrieve_io_pointers_for_label(label_id)
    click.echo(f"Name: {label_id}")
    click.echo("└─IOPointers:")
    for idx, iop in enumerate(io_pointers):
        if idx == len(io_pointers) - 1:
            click.echo(f"   └─{iop.name}")
        else:
            click.echo(f"   ├─{iop.name}")
Example #13
0
def components(owner: str = "", tag: str = "", address: str = ""):
    """
    Command to list the components with options to filter by tag or owner.
    """
    if address and len(address) > 0:
        set_address(address)

    # Make return result
    try:
        result = get_components(tag, owner)
    except RuntimeError:
        raise click.ClickException(
            "No components could be found with the " "flags passed."
        )

    # Display components, one per line
    for comp in result:
        click.echo(f"{comp.name}")
Example #14
0
def review(limit: int = 5, address: str = ""):
    """Command to find common component runs in a set of flagged outputs."""
    if address and len(address) > 0:
        set_address(address)
    outputs, component_counts = review_flagged_outputs()

    # Print output ids
    click.echo("Flagged outputs:")
    for idx, out in enumerate(outputs):
        if idx == len(outputs) - 1:
            click.echo(f"└─{out}")
        else:
            click.echo(f"├─{out}")
    click.echo()

    # Print component runs
    for component, count in component_counts[:limit]:
        show_info_card(component.id, count, len(outputs))
Example #15
0

@register(
    component_name="research_model_development",
    input_vars=["lr", "num_epochs", "hidden_size"],
    output_vars=["model_metric"],
)
def train_and_evaluate_model(lr, num_epochs, hidden_size):
    # Grab some random accuracy
    model_metric = f"{random.uniform(0, 1)}_accuracy"
    return model_metric


if __name__ == "__main__":
    # Set server
    set_address("localhost")

    # Create component
    create_component(
        name="research_model_development",
        description="Example of training a model for research.",
        owner="neurips_queen",
        tags=["example"],
    )

    lr_candidates = [0.001, 0.01, 0.1]
    num_epochs_candidates = [10, 50, 100]
    hidden_size_candidates = [64, 128, 256]

    candidates = itertools.product(lr_candidates, num_epochs_candidates,
                                   hidden_size_candidates)