def testOutputDirNoSubdirs(self): build = builder.Builder(self.toolchains, BASE_DIR, None, 1, 2, checkout=False, show_unknown=False, no_subdirs=True) build.commits = None build.commit_count = 0 self.CheckDirs(build, '')
def main(): model = mrcnn_model_init() print("--------model init success--------") while True: try: image = read_image() break except Exception as e: print("Exception: {}".format(e)) results = model.detect([image], verbose=0) instance_builder = builder.Builder() root = instance_builder.build(image, results)[0] while(True): cv.imshow("image", root.generate_image()) cv.waitKey(1) #cv.imwrite("temp.png", root.generate_image()) instruction = input("Please enter the instruction(effect/save): ") if (instruction == "effect"): print("All instances detected: ") print(root.list()) selectInstance(root) elif(instruction == "save"): save_image(root.generate_image()) break else: print("not such instruction") cv.destroyAllWindows()
def get_builder(self, task=None): """ Return bOS builder for current configuration """ builder = bos_builder.Builder(self._config, self._argv) if task: self._doit_prepare(builder, task) return builder
def testOutputDir(self): build = builder.Builder(self.toolchains, BASE_DIR, None, 1, 2, checkout=False, show_unknown=False) build.commits = self.commits build.commit_count = len(self.commits) subject = self.commits[1].subject.translate(builder.trans_valid_chars) dirname ='/%02d_of_%02d_g%s_%s' % (2, build.commit_count, commits[1][0], subject[:20]) self.CheckDirs(build, dirname)
def testOutputDirCurrent(self): build = builder.Builder(self.toolchains, BASE_DIR, None, 1, 2, checkout=False, show_unknown=False) build.commits = None build.commit_count = 0 self.CheckDirs(build, '/current')
def main(args: List[str]) -> None: """Run clang-tidy on the target provided.""" try: bazel = builder.Builder() if len(args) == 2: analyse(bazel, args[1]) else: analyse(bazel, "//c-toxcore/toxcore/...") except subprocess.CalledProcessError as exn: print(exn.stderr.decode("utf-8").strip()) logging.exception(exn)
def build(self, makefile, resultdir, stages=None, **kwargs): b = builder.Builder(self, makefile, resultdir, **kwargs) try: b.build(stages=stages) except Error: raise BuildError, _("Build command has failed.") else: # If the build was successful, cleanup all temporary files. b.cleanup()
def run_test(): example = False if example: puzzle = builder.Builder.example() else: random.seed(0) options = builder.Options(20, 20) b = builder.Builder(options) puzzle = b.run() solver = Solver(puzzle) start = timeit.default_timer() solver.run() stop = timeit.default_timer() print('Time: ', stop - start)
def process_image(source_path, output_path): image = cv.imread(source_path, -1) height, width, channels = image.shape results = model.detect([image], verbose=0) import builder import effect from instance import to_bgr instance_builder = builder.Builder() root = instance_builder.build(image, results)[0] # root.setEffect(effect.BlurFilter()) root.setEffect(effect.Move((100, 100))) result = root.generate_image() cv.imwrite(output_path, result)
def main(): env_list = [ 'GIT_CLONE_URL', 'GIT_REF', "_WORKFLOW_GIT_CLONE_URL", "_WORKFLOW_GIT_REF", 'FILES' ] envs = {} for env_name in env_list: envs[env_name] = os.environ.get(env_name) try: if builder.Builder(envs).run(): print("BUILD SUCCEED.", file=sys.stdout) else: print("BUILD FAILED.", file=sys.stdout) exit(1) except Exception as e: print("BUILD FAILED: %s" % str(e), file=sys.stderr) exit(1)
def doBuild(self, modifiers, instance=None, **kwargs): if not self.destination: raise ValueError('Link %s has no attachment' % self) logger.debug('Up-linking instance for %s with Given %s value of %s' % (self.clazz, self.destination, instance)) mods = [modifiers] if isinstance(self.destination, Collection): mods.append(modifiers_package.HavingIn(self.destination, instance)) else: mods.append(modifiers_package.Given(self.destination, instance)) if self.reuser: return self.reuser.doBuild(modifiers, **dict(instance=instance, **kwargs)) else: return builder.Builder(self.clazz).withA(*mods).build()
def main(): envs_list = [ 'GIT_CLONE_URL', 'GIT_REF', "_WORKFLOW_GIT_CLONE_URL", "_WORKFLOW_GIT_REF" ] envs = {} for env_name in envs_list: envs[env_name] = os.environ.get(env_name) try: if builder.Builder(envs).run(): print("build succeed", file=sys.stdout) else: print("build failed", file=sys.stdout) exit(1) except Exception as e: print("build failed: %s" % str(e), file=sys.stderr) exit(1)
def testPrepareOutputSpace(self): def _Touch(fname): tools.WriteFile(os.path.join(base_dir, fname), b'') base_dir = tempfile.mkdtemp() # Add various files that we want removed and left alone to_remove = ['01_of_22_g0982734987_title', '102_of_222_g92bf_title', '01_of_22_g2938abd8_title'] to_leave = ['something_else', '01-something.patch', '01_of_22_another'] for name in to_remove + to_leave: _Touch(name) build = builder.Builder(self.toolchains, base_dir, None, 1, 2) build.commits = self.commits build.commit_count = len(commits) result = set(build._GetOutputSpaceRemovals()) expected = set([os.path.join(base_dir, f) for f in to_remove]) self.assertEqual(expected, result)
def testBasic(self): """Test basic builder operation""" output_dir = tempfile.mkdtemp() if not os.path.isdir(output_dir): os.mkdir(output_dir) build = builder.Builder(self.toolchains, output_dir, None, 1, 2, checkout=False, show_unknown=False) build.do_make = self.Make board_selected = self.boards.GetSelectedDict() #build.BuildCommits(self.commits, board_selected, False) build.BuildBoards(self.commits, board_selected, False, False) build.ShowSummary(self.commits, board_selected, True, False, False, False)
def build_module(self): pyversion = "python{}.{}{}".format(sys.version_info.major, sys.version_info.minor, sys.abiflags) include_dir = sys.exec_prefix + "/include/" + pyversion lib_dir = sys.exec_prefix + "/lib" working_dir = os.path.dirname(__file__) source_file = "graphpathfinding.c" output_file = "graphpathfinding.so" exe = "gcc" params = ["-O2", "-shared", "-Wall", "-fPIC", "-o", output_file, "-I" + include_dir, "-L" + lib_dir, source_file, "-l" + pyversion] if sys.platform == "darwin" : params = ["-dynamiclib"] + params commands = [exe] + params bld = builder.Builder(source_file, output_file, commands, working_dir) bld.build()
def _SetupTest(self, echo_lines=False, **kwdisplay_args): """Set up the test by running a build and summary Args: echo_lines: True to echo lines to the terminal to aid test development kwdisplay_args: Dict of arguemnts to pass to Builder.SetDisplayOptions() Returns: Iterator containing the output lines, each a PrintLine() object """ build = builder.Builder(self.toolchains, self.base_dir, None, 1, 2, checkout=False, show_unknown=False) build.do_make = self.Make board_selected = self.boards.GetSelectedDict() # Build the boards for the pre-defined commits and warnings/errors # associated with each. This calls our Make() to inject the fake output. build.BuildBoards(self.commits, board_selected, keep_outputs=False, verbose=False) lines = terminal.GetPrintTestLines() count = 0 for line in lines: if line.text.strip(): count += 1 # We should get two starting messages, an update for every commit built # and a summary message self.assertEqual(count, len(commits) * len(boards) + 3) build.SetDisplayOptions(**kwdisplay_args) build.ShowSummary(self.commits, board_selected) if echo_lines: terminal.EchoPrintTestLines() return iter(terminal.GetPrintTestLines())
def Settings( language: str, filename: Optional[str] = None, client_data: Any = None, ) -> Dict[str, List[str]]: """Return flags for the file loaded into vim.""" del client_data if language != "cfamily" or not filename: return {} bazel = builder.Builder() # Determine the path relative to the toplevel workspace dir. filename = os.path.relpath(filename, bazel.source_root()) # Generate a compilation database with a single file in it. db = bazel.generate_compilation_database([filename]) if not db: raise Exception(filename) flags = builder.flags_for_clang(bazel.execution_root(), shlex.split(db[0]["command"])[1:]) return {"flags": flags}
def store(): """Webhook for notifications about a new commit on Github.""" validate_access_code() data = request.json if 'repository' in data: name = data['repository']['name'] repo_url = data['repository']['ssh_url'] commit = data['after'] if 'master' in data['ref']: b = builder.Builder(name, repo_url, commit) p = multiprocessing.Process(target=b.run) p.start() raise HTTPResponse('Started build process in background.\n', 202) else: raise HTTPResponse( 'Build process not started. I only build the master branch.') else: raise HTTPResponse('POST request did not contain a repo to build.\n', 400)
def testBasic(self): """Test basic builder operation""" output_dir = tempfile.mkdtemp() if not os.path.isdir(output_dir): os.mkdir(output_dir) build = builder.Builder(self.toolchains, output_dir, None, 1, 2, checkout=False, show_unknown=False) build.do_make = self.Make board_selected = self.boards.GetSelectedDict() build.BuildBoards(self.commits, board_selected, keep_outputs=False, verbose=False) build.SetDisplayOptions(show_errors=True) build.ShowSummary(self.commits, board_selected)
def __init__(self, state_machine_name, webserver_port, interbot_enabled=True): self.pic_control_channel = None self.pic_log_channel = None self.turret_channel = None self.interbot_channel = None self.interbot_server = None self.web_server = None self.robot = robot.Robot(self) self.fsms = [] self.state_machine_name = state_machine_name self.webserver_port = webserver_port self.stopping = False self.is_match_started = False self.map = graphmap.Map(self) self.timers = [] self.last_ka_date = datetime.datetime.now() self.start_date = None self.packet_queue = collections.deque() self.interbot_enabled = interbot_enabled self.exit_value = 0 if IS_HOST_DEVICE_ARM and IS_MAIN_ROBOT: folder = os.path.join(os.path.dirname(__file__), "colordetector") cmds = [ "g++", "-Wall", "-O2", "-o", "colordetector", "colordetector.cpp", "-l", "opencv_core", "-l", "opencv_highgui", "-l", "opencv_imgproc" ] builder.Builder("colordetector.cpp", "colordetector", cmds, folder).build() self.colordetector = ProcessChannel( self, "CAM", [os.path.join(folder, "colordetector"), "-q", "1"]) else: self.colordetector = None
def buildInstanceTree(mrcnnModel, image): results = mrcnnModel.detect([image], verbose=0) instanceBuilder = builder.Builder() return instanceBuilder.build(image, results)[0], results
if options.revision: params['checkout_revision'] = options.revision params['with_cycles'] = options.with_cycles params['with_cuda'] = options.with_cuda params['cuda_gpu'] = options.cuda_gpu params['with_osl'] = options.with_osl params['use_collada'] = options.collada params['use_env_msvc'] = options.use_env_msvc if options.user_user_config: params['user_user_config'] = options.user_user_config params['use_github_branch'] = options.use_github_branch params['add_branch_name'] = options.add_branch_name params['add_patches'] = False params['add_extra'] = False params['use_exp_branch'] = options.use_exp_branch params['vb30'] = options.vb30 params['vc2013'] = options.vc2013 params['export_only'] = options.export_only params['use_blender_hash'] = options.use_blender_hash builder = build_system.Builder(params) builder.build()
import torch import builder import trainer import os import time import argparse from opts import opts opts = opts().parse() torch.set_default_tensor_type( 'torch.DoubleTensor' if opts.usedouble else 'torch.FloatTensor') Builder = builder.Builder(opts) Model = Builder.Model() Optimizer = Builder.Optimizer(Model) Loss = Builder.Loss() Metrics = Builder.Metric() TrainDataLoader, ValDataLoader = Builder.DataLoaders() Epoch = Builder.Epoch() Model = Model.to(opts.gpuid) # opts.saveDir = os.path.join(opts.saveDir, os.path.join(opts.model, 'logs_{}'.format(datetime.datetime.now().isoformat()))) File = os.path.join(opts.saveDir + 'log.txt') Trainer = trainer.Trainer(Model, Optimizer, Loss, Metrics, File, None, opts) if opts.test: Trainer.test(ValDataLoader) exit()
def testOutput(self): """Test basic builder operation and output This does a line-by-line verification of the summary output. """ global base_dir base_dir = tempfile.mkdtemp() if not os.path.isdir(base_dir): os.mkdir(base_dir) build = builder.Builder(self.toolchains, base_dir, None, 1, 2, checkout=False, show_unknown=False) build.do_make = self.Make board_selected = self.boards.GetSelectedDict() build.BuildBoards(self.commits, board_selected, keep_outputs=False, verbose=False) lines = terminal.GetPrintTestLines() count = 0 for line in lines: if line.text.strip(): count += 1 # We should get one starting message, then an update for every commit # built. self.assertEqual(count, len(commits) * len(boards) + 1) build.SetDisplayOptions(show_errors=True) build.ShowSummary(self.commits, board_selected) #terminal.EchoPrintTestLines() lines = terminal.GetPrintTestLines() self.assertEqual(lines[0].text, '01: %s' % commits[0][1]) self.assertEqual(lines[1].text, '02: %s' % commits[1][1]) # We expect all archs to fail col = terminal.Color() self.assertSummary(lines[2].text, 'sandbox', '+', ['board4']) self.assertSummary(lines[3].text, 'arm', '+', ['board1']) self.assertSummary(lines[4].text, 'powerpc', '+', ['board2', 'board3']) # Now we should have the compiler warning self.assertEqual(lines[5].text, 'w+%s' % errors[0].rstrip().replace('\n', '\nw+')) self.assertEqual(lines[5].colour, col.MAGENTA) self.assertEqual(lines[6].text, '03: %s' % commits[2][1]) self.assertSummary(lines[7].text, 'sandbox', '+', ['board4']) self.assertSummary(lines[8].text, 'arm', '', ['board1'], ok=True) self.assertSummary(lines[9].text, 'powerpc', '+', ['board2', 'board3']) # Compiler error self.assertEqual(lines[10].text, '+%s' % errors[1].rstrip().replace('\n', '\n+')) self.assertEqual(lines[11].text, '04: %s' % commits[3][1]) self.assertSummary(lines[12].text, 'sandbox', '', ['board4'], ok=True) self.assertSummary(lines[13].text, 'powerpc', '', ['board2', 'board3'], ok=True) # Compile error fixed self.assertEqual(lines[14].text, '-%s' % errors[1].rstrip().replace('\n', '\n-')) self.assertEqual(lines[14].colour, col.GREEN) self.assertEqual(lines[15].text, 'w+%s' % errors[2].rstrip().replace('\n', '\nw+')) self.assertEqual(lines[15].colour, col.MAGENTA) self.assertEqual(lines[16].text, '05: %s' % commits[4][1]) self.assertSummary(lines[17].text, 'sandbox', '+', ['board4']) self.assertSummary(lines[18].text, 'powerpc', '', ['board3'], ok=True) # The second line of errors[3] is a duplicate, so buildman will drop it expect = errors[3].rstrip().split('\n') expect = [expect[0]] + expect[2:] self.assertEqual(lines[19].text, '+%s' % '\n'.join(expect).replace('\n', '\n+')) self.assertEqual(lines[20].text, 'w-%s' % errors[2].rstrip().replace('\n', '\nw-')) self.assertEqual(lines[21].text, '06: %s' % commits[5][1]) self.assertSummary(lines[22].text, 'sandbox', '', ['board4'], ok=True) # The second line of errors[3] is a duplicate, so buildman will drop it expect = errors[3].rstrip().split('\n') expect = [expect[0]] + expect[2:] self.assertEqual(lines[23].text, '-%s' % '\n'.join(expect).replace('\n', '\n-')) self.assertEqual(lines[24].text, 'w-%s' % errors[0].rstrip().replace('\n', '\nw-')) self.assertEqual(lines[25].text, '07: %s' % commits[6][1]) self.assertSummary(lines[26].text, 'sandbox', '+', ['board4']) # Pick out the correct error lines expect_str = errors[4].rstrip().replace('%(basedir)s', '').split('\n') expect = expect_str[3:8] + [expect_str[-1]] self.assertEqual(lines[27].text, '+%s' % '\n'.join(expect).replace('\n', '\n+')) # Now the warnings lines expect = [expect_str[0]] + expect_str[10:12] + [expect_str[9]] self.assertEqual(lines[28].text, 'w+%s' % '\n'.join(expect).replace('\n', '\nw+')) self.assertEqual(len(lines), 29) shutil.rmtree(base_dir)
def testOutput(self): """Test basic builder operation and output This does a line-by-line verification of the summary output. """ global base_dir base_dir = tempfile.mkdtemp() if not os.path.isdir(base_dir): os.mkdir(base_dir) build = builder.Builder(self.toolchains, base_dir, None, 1, 2, checkout=False, show_unknown=False) build.do_make = self.Make board_selected = self.boards.GetSelectedDict() # Build the boards for the pre-defined commits and warnings/errors # associated with each. This calls our Make() to inject the fake output. build.BuildBoards(self.commits, board_selected, keep_outputs=False, verbose=False) lines = terminal.GetPrintTestLines() count = 0 for line in lines: if line.text.strip(): count += 1 # We should get two starting messages, then an update for every commit # built. self.assertEqual(count, len(commits) * len(boards) + 2) build.SetDisplayOptions(show_errors=True) build.ShowSummary(self.commits, board_selected) #terminal.EchoPrintTestLines() lines = terminal.GetPrintTestLines() # Upstream commit: no errors self.assertEqual(lines[0].text, '01: %s' % commits[0][1]) # Second commit: all archs should fail with warnings self.assertEqual(lines[1].text, '02: %s' % commits[1][1]) col = terminal.Color() self.assertSummary(lines[2].text, 'arm', 'w+', ['board1'], outcome=OUTCOME_WARN) self.assertSummary(lines[3].text, 'powerpc', 'w+', ['board2', 'board3'], outcome=OUTCOME_WARN) self.assertSummary(lines[4].text, 'sandbox', 'w+', ['board4'], outcome=OUTCOME_WARN) # Second commit: The warnings should be listed self.assertEqual(lines[5].text, 'w+%s' % errors[0].rstrip().replace('\n', '\nw+')) self.assertEqual(lines[5].colour, col.MAGENTA) # Third commit: Still fails self.assertEqual(lines[6].text, '03: %s' % commits[2][1]) self.assertSummary(lines[7].text, 'arm', '', ['board1'], outcome=OUTCOME_OK) self.assertSummary(lines[8].text, 'powerpc', '+', ['board2', 'board3']) self.assertSummary(lines[9].text, 'sandbox', '+', ['board4']) # Expect a compiler error self.assertEqual(lines[10].text, '+%s' % errors[1].rstrip().replace('\n', '\n+')) # Fourth commit: Compile errors are fixed, just have warning for board3 self.assertEqual(lines[11].text, '04: %s' % commits[3][1]) expect = '%10s: ' % 'powerpc' expect += ' ' + col.Color(col.GREEN, '') expect += ' ' expect += col.Color(col.GREEN, ' %s' % 'board2') expect += ' ' + col.Color(col.YELLOW, 'w+') expect += ' ' expect += col.Color(col.YELLOW, ' %s' % 'board3') self.assertEqual(lines[12].text, expect) self.assertSummary(lines[13].text, 'sandbox', 'w+', ['board4'], outcome=OUTCOME_WARN) # Compile error fixed self.assertEqual(lines[14].text, '-%s' % errors[1].rstrip().replace('\n', '\n-')) self.assertEqual(lines[14].colour, col.GREEN) self.assertEqual(lines[15].text, 'w+%s' % errors[2].rstrip().replace('\n', '\nw+')) self.assertEqual(lines[15].colour, col.MAGENTA) # Fifth commit self.assertEqual(lines[16].text, '05: %s' % commits[4][1]) self.assertSummary(lines[17].text, 'powerpc', '', ['board3'], outcome=OUTCOME_OK) self.assertSummary(lines[18].text, 'sandbox', '+', ['board4']) # The second line of errors[3] is a duplicate, so buildman will drop it expect = errors[3].rstrip().split('\n') expect = [expect[0]] + expect[2:] self.assertEqual(lines[19].text, '+%s' % '\n'.join(expect).replace('\n', '\n+')) self.assertEqual(lines[20].text, 'w-%s' % errors[2].rstrip().replace('\n', '\nw-')) # Sixth commit self.assertEqual(lines[21].text, '06: %s' % commits[5][1]) self.assertSummary(lines[22].text, 'sandbox', '', ['board4'], outcome=OUTCOME_OK) # The second line of errors[3] is a duplicate, so buildman will drop it expect = errors[3].rstrip().split('\n') expect = [expect[0]] + expect[2:] self.assertEqual(lines[23].text, '-%s' % '\n'.join(expect).replace('\n', '\n-')) self.assertEqual(lines[24].text, 'w-%s' % errors[0].rstrip().replace('\n', '\nw-')) # Seventh commit self.assertEqual(lines[25].text, '07: %s' % commits[6][1]) self.assertSummary(lines[26].text, 'sandbox', '+', ['board4']) # Pick out the correct error lines expect_str = errors[4].rstrip().replace('%(basedir)s', '').split('\n') expect = expect_str[3:8] + [expect_str[-1]] self.assertEqual(lines[27].text, '+%s' % '\n'.join(expect).replace('\n', '\n+')) # Now the warnings lines expect = [expect_str[0]] + expect_str[10:12] + [expect_str[9]] self.assertEqual(lines[28].text, 'w+%s' % '\n'.join(expect).replace('\n', '\nw+')) self.assertEqual(len(lines), 29) shutil.rmtree(base_dir)
def main(): if len(sys.argv) < 2: print("Path to configuration file wasn't specified. Exiting") exit(1) config = c.Configuration(sys.argv[1]) repo = r.Repository(config.getRepo(), config) if repo.checkIfExists() == True: print("Updating repository " + repo.extractRepositoryName()) repo.Pull() else: print("Cloning repository: " + repo.extractRepositoryName()) repo.Clone() qaRepo = r.Repository(config.getQA(), config) if config.getRepo() != config.getQA(): if qaRepo.checkIfExists() == True: print("Updating repository " + qaRepo.extractRepositoryName()) qaRepo.Pull() else: print("Cloning repository: " + qaRepo.extractRepositoryName()) qaRepo.Clone() else: print("Skipping QA repository: it's the same as test repo") if not u.CheckRepoPathExists(config, repo, config.getPath()): print("Configured directory " + config.getPath() + " wasn't found in test repository. Aborting") exit(21) if not u.CheckRepoPathExists(config, qaRepo, config.getQAPath()): print("Configured directory " + config.getQAPath() + " wasn't found in test repository. Aborting") exit(22) # Workflow starts here gh = 0 try: gh = g.GitHub(config.getPrivateKey(), config.getAppID()) gh.Auth() except ValueError as err: print("GitHub auth failed: " + str(err)) exit(101) ghUser = '' ghOrg = '' ghType = '' installation_id = 0 for user in config.getUsers(): installation_id = gh.CheckUserInstallation(user) ghUser = user ghType = 'user' break for org in config.getOrgs(): installation_id = gh.CheckOrgInstallation(org) ghOrg = org ghType = 'org' break ghTitle = '' if ghType == 'user': ghTitle = ghUser else: ghTitle = ghOrg if installation_id == 0: print("Couldn't get installation for " + ghType + " " + ghTitle) exit(210) installation_id = gh.CheckRepoInstallation('crioto', 'qa-org') print("Found installation ID for " + ghTitle + ": " + str(installation_id)) gh.AuthInstallation(installation_id) print(gh.GetIssues('crioto', 'qa-org')) gh.CreateIssue('crioto', 'qa-org', 'Test Title', 'Test Text', '') print(gh.GetIssues('crioto', 'qa-org')) # gh = g.InitializeGithub(config.getToken()) # user = gh.get_user() # print(user) exit(0) builder = b.Builder( os.path.join(config.getLocalPath(), qaRepo.extractRepositoryName(), config.getQAPath())) builder.Run() issues = builder.Get() tags = [] for issue in issues: tags.append(issue.GetAbsoluteHandle()) analyzer = a.Analyzer( os.path.join(config.getLocalPath(), repo.extractRepositoryName(), config.getPath()), tags) analyzer.Run() covered = analyzer.GetMatches()
release_date = dateutil.parser.parse(release["created_at"]) if release_date >= date_to_compare: if releases.index(release) == 0: print(plugin["Name"] + " by " + organization + " latest release (" + release_date.isoformat() + ") not added") else: print(plugin["Name"] + " by " + organization + " release " + release["name"] + " (" + release_date.isoformat() + ") not added") to_add.append({"plugin": plugin, "release": release}) # for i in to_add: addRelease(i) # Start setting up builder here. builder = builder.Builder() failed = [] succeeded = [] errored = [] print(color(f"\nBuilding {len(to_build)} things").bold) for plugin in to_build: print(f"\nBuilding {color(plugin['plugin']['Name']).bold}") try: started = datetime.datetime.now() files = None files = builder.build(plugin["plugin"], commithash=plugin["commit"]["sha"]) except Exception as error: duration = datetime.datetime.now() - started
def doBuild(self, modifiers, **kwargs): return builder.Builder(self.type).withA(*modifiers).build()
def build(self, board, pkg, **kwargs): """Builds the package specified.""" import builder if self._builder is None: self._builder = builder.Builder() return self._builder.Build(board, pkg, kwargs)
def __init__(self, flow, spec, lstm_feature_embeddings, lr_lstm, rl_lstm): # Add blobs for the lexical resources. lexicon = flow.blob("lexicon") lexicon.type = "dict" lexicon.add_attr("delimiter", 10) lexicon.add_attr("oov", spec.words.oov_index) normalization = "" if spec.words.normalize_digits: normalization = "d" lexicon.add_attr("normalization", normalization) lexicon.data = str(spec.words) + "\n" self.lexicon_blob = lexicon def read_file(filename): fin = open(filename, "r") data = fin.read() fin.close() return data f = tempfile.NamedTemporaryFile(delete=False) fname = f.name spec.commons.save(fname, binary=True) f.close() commons = flow.blob("commons") commons.type = "frames" commons.data = read_file(fname) os.unlink(fname) self.commons_blob = commons suffix = flow.blob("suffixes") suffix.type = "affix" suffix.data = str(spec.write_suffix_table()) self.suffix_blob = suffix # Add feature extraction related ops. bldr = builder.Builder(flow, "features") self.feature_ids = [] concat_args = [] for f, e in zip(spec.lstm_features, lstm_feature_embeddings): shape = [f.vocab_size, f.dim] embedding = bldr.var(name=f.name + "_embeddings", shape=shape) embedding.data = e ids_input = bldr.var(name=f.name, dtype="int32", shape=[1, f.num]) self.feature_ids.append(ids_input) gather_op_type = "Gather" if f.num > 1: gather_op_type = "GatherSum" gather_op = bldr.rawop(gather_op_type) gather_op.dtype = "float32" gather_op.add_input(embedding) gather_op.add_input(ids_input) gather_output = bldr.var(gather_op.name + ":0", "float32", [1, f.dim]) gather_op.add_output(gather_output) concat_args.append(gather_output) self.feature_vector = bldr.concat(concat_args) bldr.rename(self.feature_vector, "feature_vector") self.feature_vector.ref = True # Add BiLSTM. lr = builder.Builder(flow, "lstm/lr") lr_input = lr.var(name="input", shape=[1, spec.lstm_input_dim]) lr_input.ref = True flow_lr_lstm = nn.LSTM(lr, input=lr_input, size=spec.lstm_hidden_dim) lr_lstm.copy_to_flow_lstm(flow_lr_lstm) self.lr_lstm = flow_lr_lstm rl = builder.Builder(flow, "lstm/rl") rl_input = rl.var(name="input", shape=[1, spec.lstm_input_dim]) rl_input.ref = True flow_rl_lstm = nn.LSTM(rl, input=rl_input, size=spec.lstm_hidden_dim) rl_lstm.copy_to_flow_lstm(flow_rl_lstm) self.rl_lstm = flow_rl_lstm cnxin = flow.cnx("features") cnxin.add(self.feature_vector) cnxin.add(lr_input) cnxin.add(rl_input)