Example #1
0
def test_put_file_atomic():
    client, repo_name = sandbox("put_file_atomic")
    commit = (repo_name, "master")

    with tempfile.NamedTemporaryFile() as f:
        with client.put_file_client() as pfc:
            pfc.put_file_from_fileobj(commit, 'file1.dat', BytesIO(b'DATA1'))
            pfc.put_file_from_bytes(commit, 'file2.dat', b'DATA1')
            pfc.put_file_from_url(
                commit, "index.html",
                "https://gist.githubusercontent.com/ysimonson/1986773831f6c4c292a7290c5a5d4405/raw/fb2b4d03d317816e36697a6864a9c27645baa6c0/wheel.html"
            )

            f.write(b'DATA3')
            f.flush()
            pfc.put_file_from_filepath(commit, "file3.dat", f.name)

    files = list(client.list_file(commit, '.'))
    assert len(files) == 4
    assert files[0].file.path == '/file1.dat'
    assert files[1].file.path == '/file2.dat'
    assert files[2].file.path == '/file3.dat'
    assert files[3].file.path == '/index.html'

    # atomic deletes are only supported in 1.11.0 onwards
    if util.test_pachyderm_version() >= (1, 11, 0):
        with client.put_file_client() as pfc:
            pfc.delete_file(commit, "/file1.dat")
            pfc.delete_file(commit, "/file2.dat")
            pfc.delete_file(commit, "/file3.dat")

        files = list(client.list_file(commit, '.'))
        assert len(files) == 1
        assert files[0].file.path == '/index.html'
Example #2
0
def test_inspect_pipeline():
    sandbox = Sandbox("inspect_pipeline")
    pipeline = sandbox.client.inspect_pipeline(sandbox.pipeline_repo_name)
    assert pipeline.pipeline.name == sandbox.pipeline_repo_name
    if util.test_pachyderm_version() >= (1, 9, 0):
        pipeline = sandbox.client.inspect_pipeline(sandbox.pipeline_repo_name,
                                                   history=-1)
        assert pipeline.pipeline.name == sandbox.pipeline_repo_name
Example #3
0
def test_subscribe_commit():
    client, repo_name = sandbox("subscribe_commit")
    commits = client.subscribe_commit(repo_name, "master")

    with client.commit(repo_name, 'master') as c:
        pass

    commit = next(commits)
    if util.test_pachyderm_version() >= (1, 9, 0):
        assert commit.branch.repo.name == repo_name
        assert commit.branch.name == "master"
Example #4
0
def test_inspect_commit():
    client, repo_name = sandbox("inspect_commit")

    with client.commit(repo_name, 'master') as c:
        client.put_file_bytes(c, 'input.json', b'hello world')

    commit = client.inspect_commit("{}/master".format(repo_name))
    if util.test_pachyderm_version() >= (1, 9, 0):
        assert commit.branch.name == "master"
    assert commit.finished
    assert commit.description == ""
    assert commit.size_bytes == 11
    assert len(commit.commit.id) == 32
    assert commit.commit.repo.name == repo_name
Example #5
0
def test_datums():
    sandbox = Sandbox("datums")
    job_id = sandbox.wait_for_job()

    # flush the job so it fully finishes
    list(
        sandbox.client.flush_commit([(sandbox.input_repo_name,
                                      sandbox.commit.id)]))

    datums = list(sandbox.client.list_datum(job_id))
    assert len(datums) == 1
    datum = sandbox.client.inspect_datum(job_id, datums[0].datum_info.datum.id)
    assert datum.state == python_pachyderm.DatumState.SUCCESS.value

    # Skip this check in >=1.11.0, due to a bug:
    # https://github.com/pachyderm/pachyderm/issues/5123
    # TODO: remove this check once the bug is fixed
    if util.test_pachyderm_version() < (1, 11, 0):
        # Just ensure this doesn't raise an exception
        sandbox.client.restart_datum(job_id)