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

Function main

tensorflow/tools/dockerfiles/assembler.py:473–715  ·  view source on GitHub ↗
(argv)

Source from the content-addressed store, hash-verified

471
472
473def main(argv):
474 if len(argv) > 1:
475 raise app.UsageError('Too many command-line arguments.')
476
477 # Read the full spec file, used for everything
478 with open(FLAGS.spec_file, 'r') as spec_file:
479 tag_spec = yaml.safe_load(spec_file)
480
481 # Get existing partial contents
482 partials = gather_existing_partials(FLAGS.partial_dir)
483
484 # Abort if spec.yaml is invalid
485 schema = yaml.safe_load(SCHEMA_TEXT)
486 v = TfDockerTagValidator(schema, partials=partials)
487 if not v.validate(tag_spec):
488 eprint('> Error: {} is an invalid spec! The errors are:'.format(
489 FLAGS.spec_file))
490 eprint(yaml.dump(v.errors, indent=2))
491 exit(1)
492 tag_spec = v.normalized(tag_spec)
493
494 # Assemble tags and images used to build them
495 all_tags = assemble_tags(tag_spec, FLAGS.arg, FLAGS.release, partials)
496
497 # Empty Dockerfile directory if building new Dockerfiles
498 if FLAGS.construct_dockerfiles:
499 eprint('> Emptying Dockerfile dir "{}"'.format(FLAGS.dockerfile_dir))
500 shutil.rmtree(FLAGS.dockerfile_dir, ignore_errors=True)
501 mkdir_p(FLAGS.dockerfile_dir)
502
503 # Set up Docker helper
504 dock = docker.from_env()
505
506 # Login to Docker if uploading images
507 if FLAGS.upload_to_hub:
508 if not FLAGS.hub_username:
509 eprint('> Error: please set --hub_username when uploading to Dockerhub.')
510 exit(1)
511 if not FLAGS.hub_repository:
512 eprint(
513 '> Error: please set --hub_repository when uploading to Dockerhub.')
514 exit(1)
515 if not FLAGS.hub_password:
516 eprint('> Error: please set --hub_password when uploading to Dockerhub.')
517 exit(1)
518 dock.login(
519 username=FLAGS.hub_username,
520 password=FLAGS.hub_password,
521 )
522
523 # Each tag has a name ('tag') and a definition consisting of the contents
524 # of its Dockerfile, its build arg list, etc.
525 failed_tags = []
526 succeeded_tags = []
527 for tag, tag_defs in all_tags.items():
528 for tag_def in tag_defs:
529 eprint('> Working on {}'.format(tag))
530

Callers

nothing calls this directly

Calls 15

gather_existing_partialsFunction · 0.85
eprintFunction · 0.85
exitFunction · 0.85
assemble_tagsFunction · 0.85
mkdir_pFunction · 0.85
anyFunction · 0.85
stripMethod · 0.80
buildMethod · 0.65
validateMethod · 0.45
formatMethod · 0.45
dumpMethod · 0.45

Tested by

no test coverage detected