def test_artifact_incremental_internal(
    mocked_run,
    mock_server,
    internal_sender,
    internal_sm,
    start_backend,
    stop_backend,
    parse_ctx,
):
    artifact = wandb.Artifact("incremental_test_PENDING", "dataset", incremental=True)
    start_backend()

    proto_run = internal_sender._make_run(mocked_run)
    r = internal_sm.send_run(internal_sender._make_record(run=proto_run))

    proto_artifact = internal_sender._make_artifact(artifact)
    proto_artifact.run_id = proto_run.run_id
    proto_artifact.project = proto_run.project
    proto_artifact.entity = proto_run.entity
    proto_artifact.user_created = False
    proto_artifact.use_after_commit = False
    proto_artifact.finalize = True
    for alias in ["latest"]:
        proto_artifact.aliases.append(alias)
    log_artifact = pb.LogArtifactRequest()
    log_artifact.artifact.CopyFrom(proto_artifact)

    art = internal_sm.send_artifact(log_artifact)
    stop_backend()

    manifests_created = parse_ctx(mock_server.ctx).manifests_created
    assert manifests_created[0]["type"] == "INCREMENTAL"
예제 #2
0
def test_communicate_artifact(mocked_run, mock_server, internal_sender,
                              internal_sm, start_backend, stop_backend):
    artifact = wandb.Artifact("comms_test_PENDING", "dataset")
    start_backend()

    proto_run = internal_sender._make_run(mocked_run)
    r = internal_sm.send_run(internal_sender._make_record(run=proto_run))

    proto_artifact = internal_sender._make_artifact(artifact)
    proto_artifact.run_id = proto_run.run_id
    proto_artifact.project = proto_run.project
    proto_artifact.entity = proto_run.entity
    proto_artifact.user_created = False
    proto_artifact.use_after_commit = False
    proto_artifact.finalize = True
    for alias in ["latest"]:
        proto_artifact.aliases.append(alias)
    log_artifact = pb.LogArtifactRequest()
    log_artifact.artifact.CopyFrom(proto_artifact)

    art = internal_sm.send_artifact(log_artifact)
    stop_backend()
예제 #3
0
def test_artifact_references_internal(
    runner,
    mocked_run,
    mock_server,
    internal_sm,
    backend_interface,
    parse_ctx,
    test_settings,
):
    with runner.isolated_filesystem():
        mock_server.set_context("max_cli_version", "0.11.0")
        run = wandb.init(settings=test_settings)
        t1 = wandb.Table(columns=[], data=[])
        art = wandb.Artifact("A", "dataset")
        art.add(t1, "t1")
        run.log_artifact(art)
        run.finish()

        art = wandb.Artifact("A_PENDING", "dataset")
        art.add(t1, "t1")

        with backend_interface() as interface:
            proto_run = interface._make_run(mocked_run)
            r = internal_sm.send_run(interface._make_record(run=proto_run))

            proto_artifact = interface._make_artifact(art)
            proto_artifact.run_id = proto_run.run_id
            proto_artifact.project = proto_run.project
            proto_artifact.entity = proto_run.entity
            proto_artifact.user_created = False
            proto_artifact.use_after_commit = False
            proto_artifact.finalize = True
            for alias in ["latest"]:
                proto_artifact.aliases.append(alias)
            log_artifact = pb.LogArtifactRequest()
            log_artifact.artifact.CopyFrom(proto_artifact)

            internal_sm.send_artifact(log_artifact)
예제 #4
0
    def communicate_artifact(
        self,
        run: "Run",
        artifact: Artifact,
        aliases: Iterable[str],
        is_user_created: bool = False,
        use_after_commit: bool = False,
        finalize: bool = True,
    ) -> _Future:
        proto_run = self._make_run(run)
        proto_artifact = self._make_artifact(artifact)
        proto_artifact.run_id = proto_run.run_id
        proto_artifact.project = proto_run.project
        proto_artifact.entity = proto_run.entity
        proto_artifact.user_created = is_user_created
        proto_artifact.use_after_commit = use_after_commit
        proto_artifact.finalize = finalize
        for alias in aliases:
            proto_artifact.aliases.append(alias)

        log_artifact = pb.LogArtifactRequest()
        log_artifact.artifact.CopyFrom(proto_artifact)
        rec = self._make_request(log_artifact=log_artifact)
        return self._communicate_async(rec)