本文整理汇总了Python中libgiza.app.BuildApp类的典型用法代码示例。如果您正苦于以下问题:Python BuildApp类的具体用法?Python BuildApp怎么用?Python BuildApp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BuildApp类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_add_existing_app_object
def test_add_existing_app_object(self):
self.assertEqual(self.app.queue, [])
app = BuildApp()
app.pool_size = 2
self.app.add(app)
self.assertIs(app, self.app.queue[0])
self.assertIsNot(app, BuildApp())
self.assertIsNot(BuildApp(), self.app.queue[0])
示例2: mine
def mine(args):
conf = fetch_config(args)
app = BuildApp(conf)
app.pool_size = 4
gh = get_connection(conf)
pprint(mine_github_pulls(gh, app, conf))
示例3: TestBuildAppMinimalConfig
class TestBuildAppMinimalConfig(CommonAppSuite, TestCase):
@classmethod
def setUp(self):
self.app = BuildApp()
self.app.default_pool = random.choice(['serial', 'thread'])
self.app.pool_size = 2
self.c = None
def tearDown(self):
self.app.close_pool()
示例4: triage
def triage(args):
conf = fetch_config(args)
app = BuildApp(conf)
app.pool = 'thread'
j = JeerahClient(conf)
j.connect()
query_data = giza.jeerah.triage.query(j, app, conf)
pprint(giza.jeerah.triage.report(query_data, conf))
示例5: planning
def planning(args):
conf = fetch_config(args)
app = BuildApp(conf)
app.pool = 'thread'
j = JeerahClient(conf)
j.connect()
query_data = giza.jeerah.progress.query(j, app, conf)
pprint(giza.jeerah.planning.report(query_data, conf))
示例6: actions
def actions(args):
conf = fetch_config(args)
app = BuildApp(conf)
app.pool_size = 4
gh = get_connection(conf)
results = []
for pull in mine_github_pulls(gh, app, conf):
if pull['merge_safe'] is True:
results.append(pull)
pprint(results)
示例7: test_single_runner_app
def test_single_runner_app(self):
self.assertEqual(self.app.queue, [])
self.assertEqual(self.app.results, [])
app = BuildApp()
app.pool_size = 2
t = app.add('task')
t.job = sum
t.args = [[1, 2], 0]
t.description = 'test task'
self.app.add(app)
self.app.run()
self.assertEqual(self.app.results[0], 3)
示例8: api
def api(args):
c = fetch_config(args)
with BuildApp.new(pool_type=c.runstate.runner,
pool_size=c.runstate.pool_size,
force=c.runstate.force).context() as app:
app.extend_queue(apiarg_tasks(c))
示例9: build_translation_model
def build_translation_model(args):
conf = fetch_config(args)
if args.t_translate_config is None:
tconf = conf.system.files.data.translate
elif os.path.isfile(args.t_translate_config):
tconf = TranslateConfig(args.t_translate_config, conf)
else:
logger.error(args.t_translate_config + " doesn't exist")
return
if os.path.exists(tconf.paths.project) is False:
os.makedirs(tconf.paths.project)
elif os.path.isfile(tconf.paths.project):
logger.error(tconf.paths.project + " is a file")
sys.exit(1)
elif os.listdir(tconf.paths.project) != []:
logger.error(tconf.paths.project + " must be empty")
sys.exit(1)
with open(os.path.join(tconf.paths.project, "translate.yaml"), 'w') as f:
yaml.dump(tconf.dict(), f, default_flow_style=False)
tconf.conf.runstate.pool_size = tconf.settings.pool_size
run_args = get_run_args(tconf)
app = BuildApp.new(pool_type=conf.runstate.runner,
pool_size=conf.runstate.pool_size,
force=conf.runstate.force)
os.environ['IRSTLM'] = tconf.paths.irstlm
setup_train(tconf)
setup_tune(tconf)
setup_test(tconf)
for idx, parameter_set in enumerate(run_args):
parameter_set = list(parameter_set)
parameter_set.append(idx)
parameter_set.append(tconf)
t = app.add()
t.job = build_model
t.args = parameter_set
t.description = "model_" + str(parameter_set[9])
app.run()
aggregate_model_data(tconf.paths.project)
from_addr = "[email protected]"
to_addr = [tconf.settings.email]
with open(tconf.paths.project + "/data.csv") as data:
msg = MIMEText(data.read())
msg['Subject'] = "Model Complete"
msg['From'] = from_addr
msg['To'] = ", ".join(to_addr)
server = smtplib.SMTP("localhost")
server.sendmail(from_addr, to_addr, msg.as_string())
server.quit()
示例10: source
def source(args):
args.builder = 'html'
conf = fetch_config(args)
with BuildApp.new(pool_type=conf.runstate.runner,
pool_size=conf.runstate.pool_size,
force=conf.runstate.force).context() as app:
sphinx_content_preperation(app, conf)
示例11: robots
def robots(args):
c = fetch_config(args)
with BuildApp.new(pool_type=c.runstate.runner,
pool_size=c.runstate.pool_size,
force=c.runstate.force).context() as app:
app.pool = 'serial'
app.extend_queue(robots_txt_tasks(c))
示例12: main
def main(args):
"""
Removes build artifacts from ``build/`` directory.
"""
c = fetch_config(args)
app = BuildApp.new(pool_type=c.runstate.runner,
pool_size=c.runstate.pool_size,
force=c.runstate.force)
to_remove = set()
if c.runstate.git_branch is not None:
to_remove.add(os.path.join(c.paths.projectroot, c.paths.branch_output))
if c.runstate.builder != []:
for edition, language, builder in get_builder_jobs(c):
builder_path = resolve_builder_path(builder, edition, language, c)
builder_path = os.path.join(c.paths.projectroot, c.paths.branch_output, builder_path)
to_remove.add(builder_path)
dirpath, base = os.path.split(builder_path)
to_remove.add(os.path.join(dirpath, 'doctrees-' + base))
m = 'remove artifacts associated with the {0} builder in {1} ({2}, {3})'
logger.debug(m.format(builder, c.git.branches.current, edition, language))
if c.runstate.days_to_save is not None:
published_branches = ['docs-tools', 'archive', 'public', 'primer', c.git.branches.current]
published_branches.extend(c.git.branches.published)
for build in os.listdir(os.path.join(c.paths.projectroot, c.paths.output)):
build = os.path.join(c.paths.projectroot, c.paths.output, build)
branch = os.path.split(build)[1]
if branch in published_branches:
continue
elif not os.path.isdir(build):
continue
elif os.stat(build).st_mtime > c.runstate.days_to_save:
to_remove.add(build)
to_remove.add(os.path.join(c.paths.projectroot, c.paths.output, 'public', branch))
logger.debug('removed stale artifacts: "{0}" and "build/public/{0}"'.format(branch))
for fn in to_remove:
if os.path.isdir(fn):
job = shutil.rmtree
else:
job = os.remove
t = app.add('task')
t.job = job
t.args = fn
m = 'removing artifact: {0}'.format(fn)
t.description = m
logger.critical(m)
app.run()
示例13: test_single_runner_app_with_many_subtasks
def test_single_runner_app_with_many_subtasks(self):
self.assertEqual(self.app.queue, [])
self.assertEqual(self.app.results, [])
app = BuildApp()
app.pool_size = 2
for _ in range(10):
t = app.add('task')
t.job = sum
t.description = 'test task'
t.args = [[1, 2], 0]
self.app.add(app)
self.app.run()
self.assertEqual(len(self.app.results), 10)
self.assertEqual(self.app.results[0], 3)
self.assertEqual(sum(self.app.results), 30)
示例14: stats
def stats(args):
conf = fetch_config(args)
app = BuildApp(conf)
app.pool_size = 4
gh = get_connection(conf)
users = set()
result = {'merge_safe': 0, 'total': 0}
for pull in mine_github_pulls(gh, app, conf):
result['total'] += 1
if pull['merge_safe'] is True:
result['merge_safe'] += 1
users.add(pull['user'])
result['user_count'] = len(users)
result['users'] = list(users)
pprint(result)
示例15: steps
def steps(args):
c = fetch_config(args)
with BuildApp.new(pool_type=c.runstate.runner,
pool_size=c.runstate.pool_size,
force=c.runstate.force).context() as app:
if c.runstate.clean_generated is True:
app.extend_queue(step_clean(c))
else:
app.extend_queue(step_tasks(c))