Beispiel #1
0
def test_update_rdf_using_dicts_in_place(unet2d_nuclei_broad_latest):
    from bioimageio.spec.commands import update_rdf

    source = unet2d_nuclei_broad_latest
    update = dict(name="updated",
                  outputs=[{
                      "name": "updated",
                      "halo": ["KEEP", "DROP", 0, 9, 9]
                  }])
    update_rdf(source, update, output=source)
    actual = source
    assert actual["name"] == "updated"
    assert actual["outputs"][0]["name"] == "updated"
    assert actual["outputs"][0]["halo"] == [0, 0, 9, 9]
Beispiel #2
0
def update_rdf(
    source: str = typer.Argument(
        ..., help="relative file path or URI to RDF source"),
    update: str = typer.Argument(
        ..., help="relative file path or URI to (partial) RDF as update"),
    output: Path = typer.Argument(..., help="Path to save the updated RDF to"),
    validate: bool = typer.Option(
        True, help="Whether or not to validate the updated RDF"),
):
    """Update a given RDF with a (partial) RDF-like update"""
    try:
        commands.update_rdf(source, update, output, validate)
        ret_code = 0
    except Exception as e:
        print(f"update-rdf failed with {e}")
        ret_code = 1
    sys.exit(ret_code)
Beispiel #3
0
def test_update_rdf_using_paths(unet2d_nuclei_broad_base_path, tmp_path):
    from bioimageio.spec.commands import update_rdf

    in_path = unet2d_nuclei_broad_base_path / "rdf.yaml"
    assert in_path.exists()
    update_path = tmp_path / "update.yaml"
    yaml.dump(
        dict(name="updated",
             outputs=[{
                 "name": "updated",
                 "halo": ["KEEP", "DROP", 0, 9, 9]
             }]), update_path)
    out_path = tmp_path / "output.yaml"
    update_rdf(in_path, update_path, out_path)
    actual = yaml.load(out_path)
    assert actual["name"] == "updated"
    assert actual["outputs"][0]["name"] == "updated"
    assert actual["outputs"][0]["halo"] == [0, 0, 9, 9]
Beispiel #4
0
def test_update_rdf_using_rd(unet2d_nuclei_broad_latest):
    from bioimageio.spec.commands import update_rdf

    source = load_raw_resource_description(unet2d_nuclei_broad_latest)
    update = dict(name="updated",
                  outputs=[{
                      "name": "updated",
                      "halo": ["KEEP", "DROP", 0, 9, 9]
                  }])
    actual = update_rdf(source, update)
    assert isinstance(actual, raw_nodes.Model)
    assert actual.name == "updated"
    assert actual.outputs[0].name == "updated"
    assert actual.outputs[0].halo == [0, 0, 9, 9]