(args)
| 121 | |
| 122 | |
| 123 | def plot_log(args): |
| 124 | |
| 125 | if args.experiment_config: |
| 126 | # config argument given; load runs from experiments config |
| 127 | |
| 128 | # load experiments.toml |
| 129 | config = load_experiments_config(args.config, args) |
| 130 | |
| 131 | # if requested, list expriments and exit |
| 132 | if args.list_experiment_names: |
| 133 | for spec in sorted(config.experiments, key=lambda s: s.name): |
| 134 | print(spec.name) |
| 135 | return |
| 136 | |
| 137 | # turn list of sequences (using shell-style (fnmatch) patterns) to regex to pass to get_log_dirs |
| 138 | filter_regex = None |
| 139 | if args.sequences: |
| 140 | filter_regex = "|".join(["({})".format(fnmatch.translate(s)) for s in args.sequences]) |
| 141 | |
| 142 | # interpret paths as patterns to match experiment names |
| 143 | added_exps = set() |
| 144 | logs = dict() |
| 145 | for p in args.path: |
| 146 | matched = [] |
| 147 | for spec in config.experiments: |
| 148 | if fnmatch.fnmatch(spec.name, p): |
| 149 | matched.append(spec) |
| 150 | if not matched: |
| 151 | print("Didn't find any experiment for '{}'".format(p)) |
| 152 | sys.exit(1) |
| 153 | else: |
| 154 | for spec in sorted(matched, key=lambda x: x.name): |
| 155 | if spec.name not in added_exps: |
| 156 | exp = Experiment.load_spec(spec, |
| 157 | config.options.base_path, |
| 158 | cache_dir=None, |
| 159 | extra_filter_regex=filter_regex, |
| 160 | other_specs=config.experiments) |
| 161 | extract_logs_from_experiment(exp, logs) |
| 162 | added_exps.add(spec.name) |
| 163 | else: |
| 164 | # no experiments config, just search path for log files |
| 165 | paths = args.path |
| 166 | logs = dict() |
| 167 | for path in paths: |
| 168 | load_all_in(path, logs, sequences=args.sequences) |
| 169 | |
| 170 | if not logs: |
| 171 | print("Nothing found") |
| 172 | return |
| 173 | |
| 174 | do_plot(logs, args) |
| 175 | figs = [(plt.gcf(), '')] |
| 176 | |
| 177 | plt.tight_layout() |
| 178 | |
| 179 | if args.save: |
| 180 | save_dir = os.path.dirname(args.save) |
no test coverage detected