(config)
| 74 | |
| 75 | |
| 76 | def function_trainable(config): |
| 77 | num_iters = int(config["num_iters"]) |
| 78 | sleep_time = config["sleep_time"] |
| 79 | score = config["score"] |
| 80 | |
| 81 | checkpoint_iters = config["checkpoint_iters"] |
| 82 | checkpoint_size_b = config["checkpoint_size_b"] |
| 83 | checkpoint_num_items = checkpoint_size_b // 8 # np.float64 |
| 84 | checkpoint_num_files = config["checkpoint_num_files"] |
| 85 | |
| 86 | for i in range(num_iters): |
| 87 | metrics = {"score": i + score} |
| 88 | if ( |
| 89 | checkpoint_iters >= 0 |
| 90 | and checkpoint_size_b > 0 |
| 91 | and i % checkpoint_iters == 0 |
| 92 | ): |
| 93 | with tempfile.TemporaryDirectory() as tmpdir: |
| 94 | for i in range(checkpoint_num_files): |
| 95 | checkpoint_file = os.path.join(tmpdir, f"bogus_{i}.ckpt") |
| 96 | checkpoint_data = np.random.uniform(0, 1, size=checkpoint_num_items) |
| 97 | with open(checkpoint_file, "wb") as fp: |
| 98 | pickle.dump(checkpoint_data, fp) |
| 99 | tune.report(metrics, checkpoint=Checkpoint.from_directory(tmpdir)) |
| 100 | else: |
| 101 | tune.report(metrics) |
| 102 | |
| 103 | time.sleep(sleep_time) |
| 104 | |
| 105 | |
| 106 | def timed_tune_run( |
nothing calls this directly
no test coverage detected
searching dependent graphs…