async def worker(ctx: WorkContext, tasks):
        ctx.send_file(
            "./lens.py",
            "/golem/work/lens.py",
        )
        async for task in tasks:
            feed = task.data
            ctx.send_json(
                "/golem/work/params.json",
                feed,
            )
            commands = (
                "python3 /golem/work/lens.py >> /golem/output/task-log 2>&1;")
            ctx.run("/bin/sh", "-c", commands)
            frame_start = feed["start_frame"]
            frame_end = feed["start_frame"] + len(feed["points"])
            frames = range(frame_start, frame_end)
            ctx.log(f"Downloading frames {frame_start}-{frame_end}...")
            for frame in frames:
                ctx.download_file(f"/golem/output/{frame}.png",
                                  f"out/{frame + 100}.png")
            output = f"task-log"
            ctx.download_file(f"/golem/output/task-log", f"out/{output}")
            yield ctx.commit()
            # TODO: Check if job results are valid
            # and reject by: task.reject_task(reason = 'invalid file')
            task.accept_task(result=output)

        ctx.log("no more frames to render")
Beispiel #2
0
    async def worker(ctx: WorkContext, tasks):
        ctx.send_file("./scene.blend", "/golem/resource/scene.blend")
        async for task in tasks:
            frame = task.data
            ctx.begin()
            crops = [{
                "outfilebasename": "out",
                "borders_x": [0.0, 1.0],
                "borders_y": [0.0, 1.0]
            }]
            ctx.send_json(
                "/golem/work/params.json",
                {
                    "scene_file": "/golem/resource/scene.blend",
                    "resolution": (800, 600),
                    "use_compositing": False,
                    "crops": crops,
                    "samples": 100,
                    "frames": [frame],
                    "output_format": "PNG",
                    "RESOURCES_DIR": "/golem/resources",
                    "WORK_DIR": "/golem/work",
                    "OUTPUT_DIR": "/golem/output",
                },
            )
            ctx.run("/golem/entrypoints/run-blender.sh")
            ctx.download_file(f"/golem/output/out{frame:04d}.png",
                              f"output_{frame}.png")
            yield ctx.commit()
            # TODO: Check if job is valid
            # and reject by: task.reject_task(msg = 'invalid file')
            task.accept_task()

        ctx.log("no more frame to render")
Beispiel #3
0
    async def worker(ctx: WorkContext, tasks):
        async for task in tasks:
            ctx.send_file('make.sh', '/golem/work/make.sh')
            ctx.run('/bin/sh', '/golem/work/make.sh')
            output_file = 'vim'
            ctx.download_file('/golem/work/vim/src/vim', 'vim')
            ctx.download_file('/golem/work/out.txt', 'log')
            yield ctx.commit()
            task.accept_task(result=output_file)

        ctx.log(f'VIM compiled!')
Beispiel #4
0
    async def worker(ctx: WorkContext, tasks):
        async for task in tasks:
            ctx.send_file('fire.sh', '/golem/work/fire.sh')
            ctx.run('/bin/sh', '/golem/work/fire.sh')
            output_file = f"vim"
            ctx.download_file('/golem/work/vim/src/vim', 'vim')
            ctx.download_file('/golem/work/log.txt', 'log')
            yield ctx.commit()
            task.accept_task(result=output_file)

        ctx.log(f'done!')
Beispiel #5
0
    async def worker(ctx: WorkContext, tasks):
        ctx.send_file("./program.py", "/golem/work/program.py")
        async for task in tasks:
            ctx.begin()
            ctx.run("/golem/entrypoints/run.sh")
            ctx.download_file("/golem/output/results.txt", "results.txt")
            yield ctx.commit()
            # TODO: Check if job results are valid
            # and reject by: task.reject_task(msg = 'invalid file')
            task.accept_task()

        ctx.log("no more tasks!")
Beispiel #6
0
                async def worker(ctx: WorkContext, tasks):
                    async for task in tasks:
                        ctx.send_file(module_path, "/golem/input/func")
                        remote_args = []

                        for (i, arg_path) in enumerate(saved_args):
                            remote_arg = f"/golem/input/arg{i}"
                            ctx.send_file(arg_path, remote_arg)
                            remote_args.append(remote_arg)

                        ctx.run("python", "/golem/runner.py",
                                "/golem/input/func", *remote_args)
                        ctx.download_file("/golem/output/out", out_path)
                        yield ctx.commit()
                        task.accept_task(result=out_path)

                    ctx.log("done")
Beispiel #7
0
    async def worker(ctx: WorkContext, tasks):
        sent_file = "/golem/resource/input.file"
        ctx.send_file(input_file, sent_file)

        async for task in tasks:
            preset = task.data

            if "MKV" in preset or preset == "Roku 2160p60 4K HEVC Surround":
                output_ext = ".mkv"
            else:
                output_ext = ".mp4"

            subjob = f"{job}_{preset_list.index(preset)+1}"

            update_status(subjob, "starting")

            output_file = f"{subjob}{output_ext}"

            ctx.log(f"job: {subjob}")

            update_status(subjob, "job sent")

            commands = (
                'cd /golem/output; '
                f'echo preset:{preset} > log.txt; '
                f'echo output_file:{output_file} >> log.txt; '
                f"HandBrakeCLI -i {sent_file} -o {output_file} --preset '{preset}' >> log.txt 2>&1; "
                'ls -lah >> log.txt')

            ctx.run("/bin/sh", "-c", commands)

            #ctx.download_file(f"/golem/output/log.txt", "log.txt")
            ctx.download_file(f"/golem/output/{output_file}",
                              f"./downloads/{output_file}")

            yield ctx.commit()

            update_status(subjob, "done")

            # TODO: Check if job results are valid
            # and reject by: task.reject_task(reason = 'invalid file')
            task.accept_task(result=output_file)

        ctx.log("no more videos to convert!")
Beispiel #8
0
    async def worker(ctx: WorkContext, tasks):
        async for task in tasks:
            node_no = task.data
            ctx.send_file("lorenz.py", "/golem/work/task.py")
            cmd = f"python3 /golem/work/task.py -d {duration} -n {node_no}/{num_nodes} -m {num_trajectories} -l {time_delta} "
            print(f"\033[36;1mRunning {cmd}\033[0m")
            ctx.run("sh", "-c", f"{cmd} >> /golem/output/log.txt 2>&1")
            ctx.download_file(f"/golem/output/log.txt", "log.txt")
            task_duration = duration / num_nodes
            # frame start stop index
            t0 = int(task_duration / time_delta) * (node_no - 1)
            t1 = t0 + int(task_duration / time_delta)
            for t in range(t0, t1):
                ctx.download_file(f"/golem/output/frame_{t:04d}.png",
                                  f"output/frame_{t:04d}.png")
            yield ctx.commit()
            task.accept_task()

        ctx.log("no more task to run")
Beispiel #9
0
async def worker(ctx: WorkContext, tasks):
    data_path = Path(DATA_PATH)
    num_files = len(list(data_path.glob("*")))

    async for task in tasks:
        partition = task.data

        start_index = partition * PARTITION_SLICES

        # if it's the final partition, iterate all the way to the end
        if partition == math.floor(num_files / PARTITION_SLICES):
            end_index = num_files
        else:
            end_index = start_index + PARTITION_SLICES

        tar_path = f"tmp/dicom_{partition}.tar.gz"

        with tarfile.open(tar_path, mode="w:gz") as dicom_tar:
            for i, dicom_path in enumerate(data_path.rglob("*.dcm")):
                if start_index <= i < end_index:
                    dicom_tar.add(str(dicom_path))

        ctx.send_file(tar_path, "/golem/resource/dicom.tar.gz")

        ctx.begin()
        # TODO send config info to container
        ctx.run("/golem/entrypoints/run")
        ctx.download_file(f"/golem/output/log.out",
                          f"output/log_{partition}.out")

        # TODO download .npy file instead of .png
        ctx.download_file(f"/golem/output/3d_clusters.png",
                          f"output/3d_clusters_{partition}.png")
        yield ctx.commit()

        # TODO: Check if job results are valid
        # and reject by: task.reject_task(msg = 'invalid file')
        task.accept_task()

    ctx.log("no more partitions to search")
Beispiel #10
0
    async def worker(ctx: WorkContext, tasks):
        async for task in tasks:
            output_file = f"out_{str(task.data['node'])}.txt"
            ctx.run("/golem/entrypoints/crack.sh", str(task.data['node']), str(task.data['nodes']), str(timeout_seconds), password)
            ctx.log("task data is:")
            ctx.log(task.data)
            ctx.download_file("/golem/output/result.txt", output_file)
            yield ctx.commit()
            # TODO: Check if job results are valid
            # and reject by: task.reject_task(reason = 'invalid file')
            task.accept_task(result=output_file)

        ctx.log("no more frames to render")
Beispiel #11
0
    async def ripper(ctx: WorkContext, tasks):
        async for task in tasks:
            output_file = f"out_{str(task.data['node'])}.txt"
            #ctx.send_file('ripper.sh', '/golem/entrypoints/ripper.sh') #in case you want to send your modify it bash uncomment
            ctx.run('bin/sh', '/golem/entrypoints/ripper.sh',
                    str(task.data['node']), str(task.data['nodes']),
                    str(timeout_seconds), password)
            ctx.log("task data is:")
            ctx.log(task.data)
            ctx.download_file("/golem/output/result.txt", output_file)
            yield ctx.commit()
            task.accept_task(result=output_file)

        ctx.log("hmm.. it looks like we got some passwords")