MCPcopy Create free account
hub / github.com/apache/arrow / from_rev_or_path

Method from_rev_or_path

dev/archery/archery/benchmark/runner.py:333–365  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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)

Callers

nothing calls this directly

Calls 10

JavaMavenDefinitionClass · 0.85
JavaBenchmarkRunnerClass · 0.85
_rev_or_path_dirnameFunction · 0.85
ArrowSourcesClass · 0.85
is_json_resultMethod · 0.80
at_revisionMethod · 0.80
from_jsonMethod · 0.45
is_build_dirMethod · 0.45
buildMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected