MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / gather_existing_partials

Function gather_existing_partials

tensorflow/tools/dockerfiles/assembler.py:447–470  ·  view source on GitHub ↗

Find and read all available partials. Args: partial_path (string): read partials from this directory. Returns: Dict[string, string] of partial short names (like "ubuntu/python" or "bazel") to the full contents of that partial.

(partial_path)

Source from the content-addressed store, hash-verified

445
446
447def gather_existing_partials(partial_path):
448 """Find and read all available partials.
449
450 Args:
451 partial_path (string): read partials from this directory.
452
453 Returns:
454 Dict[string, string] of partial short names (like "ubuntu/python" or
455 "bazel") to the full contents of that partial.
456 """
457 partials = {}
458 for path, _, files in os.walk(partial_path):
459 for name in files:
460 fullpath = os.path.join(path, name)
461 if '.partial.Dockerfile' not in fullpath:
462 eprint(('> Probably not a problem: skipping {}, which is not a '
463 'partial.').format(fullpath))
464 continue
465 # partial_dir/foo/bar.partial.Dockerfile -> foo/bar
466 simple_name = fullpath[len(partial_path) + 1:-len('.partial.dockerfile')]
467 with open(fullpath, 'r') as f:
468 partial_contents = f.read()
469 partials[simple_name] = partial_contents
470 return partials
471
472
473def main(argv):

Callers 1

mainFunction · 0.85

Calls 4

eprintFunction · 0.85
joinMethod · 0.45
formatMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected