Returns a BenchmarkRunner from a path or a git revision. First, it checks if `rev_or_path` is a valid path (or string) of a json object that can deserialize to a BenchmarkRunner. If so, it initialize a StaticBenchmarkRunner from it. This allows memoizing the result of a
(src, root, rev_or_path, maven_conf, **kwargs)
| 331 | |
| 332 | @staticmethod |
| 333 | def from_rev_or_path(src, root, rev_or_path, maven_conf, **kwargs): |
| 334 | """ Returns a BenchmarkRunner from a path or a git revision. |
| 335 | |
| 336 | First, it checks if `rev_or_path` is a valid path (or string) of a json |
| 337 | object that can deserialize to a BenchmarkRunner. If so, it initialize |
| 338 | a StaticBenchmarkRunner from it. This allows memoizing the result of a |
| 339 | run in a file or a string. |
| 340 | |
| 341 | Second, it checks if `rev_or_path` points to a valid Maven build |
| 342 | directory. If so, it creates a JavaBenchmarkRunner with this existing |
| 343 | MavenBuild. |
| 344 | |
| 345 | Otherwise, it assumes `rev_or_path` is a revision and clone/checkout |
| 346 | the given revision and create a fresh MavenBuild. |
| 347 | """ |
| 348 | if StaticBenchmarkRunner.is_json_result(rev_or_path): |
| 349 | return StaticBenchmarkRunner.from_json(rev_or_path, **kwargs) |
| 350 | elif MavenBuild.is_build_dir(rev_or_path): |
| 351 | maven_def = JavaMavenDefinition(rev_or_path, maven_conf) |
| 352 | return JavaBenchmarkRunner(maven_def.build(rev_or_path), **kwargs) |
| 353 | else: |
| 354 | path_rev = _rev_or_path_dirname(src, rev_or_path) |
| 355 | root_rev = os.path.join(root, path_rev) |
| 356 | os.makedirs(root_rev, exist_ok=True) |
| 357 | |
| 358 | clone_dir = os.path.join(root_rev, "arrow") |
| 359 | if os.path.isdir(clone_dir): |
| 360 | src_rev = ArrowSources(clone_dir) |
| 361 | else: |
| 362 | src_rev, _ = src.at_revision(rev_or_path, clone_dir) |
| 363 | maven_def = JavaMavenDefinition(src_rev.java, maven_conf) |
| 364 | build_dir = os.path.join(root_rev, "arrow/java") |
| 365 | return JavaBenchmarkRunner(maven_def.build(build_dir), **kwargs) |
nothing calls this directly
no test coverage detected