Esempio n. 1
0
def output(context, args):
    result = job.list_jobstates(context, id=args.id, sort="created_at")
    jobstates = result.json()["jobstates"]

    res = []
    for js in jobstates:
        f_l = job.list_files(context,
                             id=args.id,
                             where="jobstate_id:" + js["id"],
                             sort="created_at")
        for f in f_l.json()["files"]:
            res.append(dci_file.content(context, id=f["id"]).text)
    return res
Esempio n. 2
0
def test_iter(dci_context, job_id):
    f_names = ["file_%d" % i for i in range(100)]
    for name in f_names:
        dci_file.create(
            dci_context,
            name=name,
            content="some content",
            mime="plain/text",
            job_id=job_id,
        )
    cpt = 0
    seen_names = []
    for f in job.list_files_iter(dci_context, id=job_id):
        seen_names.append(f["name"])
        cpt += 1
    # job already comes with 2 files
    all_files = len(job.list_files(dci_context, id=job_id).json()["files"])
    assert all_files == 100 + 2
    assert cpt == 100 + 2
    assert len(set(seen_names) - set(f_names)) == 2
Esempio n. 3
0
def file_id(dci_context, job_id):
    return api_job.list_files(dci_context, id=job_id).json()["files"][-1]["id"]
Esempio n. 4
0
def file_list(context, args):
    params = {
        k: getattr(args, k)
        for k in ["sort", "limit", "offset", "id", "where"]
    }
    return job.list_files(context, **params)