def _call_objs(self, contextualized): # Setup pre_body, post_body = Mock(), Mock() t1 = Task(pre_body, contextualized=contextualized) t2 = Task(post_body, contextualized=contextualized) t3 = Task( Mock(), pre=[call(t1, 5, foo='bar')], post=[call(t2, 7, biz='baz')], ) c = Collection(t1=t1, t2=t2, t3=t3) e = Executor(collection=c) e.execute('t3') # Pre-task asserts args, kwargs = pre_body.call_args eq_(kwargs, {'foo': 'bar'}) if contextualized: assert isinstance(args[0], Context) eq_(args[1], 5) else: eq_(args, (5, )) # Post-task asserts args, kwargs = post_body.call_args eq_(kwargs, {'biz': 'baz'}) if contextualized: assert isinstance(args[0], Context) eq_(args[1], 7) else: eq_(args, (7, ))
def _call_objs(self, contextualized): # Setup pre_body, post_body = Mock(), Mock() t1 = Task(pre_body, contextualized=contextualized) t2 = Task(post_body, contextualized=contextualized) t3 = Task(Mock(), pre=[call(t1, 5, foo='bar')], post=[call(t2, 7, biz='baz')], ) c = Collection(t1=t1, t2=t2, t3=t3) e = Executor(collection=c) e.execute('t3') # Pre-task asserts args, kwargs = pre_body.call_args eq_(kwargs, {'foo': 'bar'}) if contextualized: assert isinstance(args[0], Context) eq_(args[1], 5) else: eq_(args, (5,)) # Post-task asserts args, kwargs = post_body.call_args eq_(kwargs, {'biz': 'baz'}) if contextualized: assert isinstance(args[0], Context) eq_(args[1], 7) else: eq_(args, (7,))
def deduping_treats_different_calls_to_same_task_differently(self): body = Mock() t1 = Task(body) pre = [call(t1, 5), call(t1, 7), call(t1, 5)] t2 = Task(Mock(), pre=pre) c = Collection(t1=t1, t2=t2) e = Executor(collection=c) e.execute('t2') # Does not call the second t1(5) body.assert_has_calls([mock_call(5), mock_call(7)])
def debug(ctx, env=None, cfg=None, auth=None, network=None): env, cfg, auth, network = get_config(ctx, env, cfg, auth, network) call( run, create_options='-ti --rm', start_options='-i', env=env, cfg=cfg, auth=auth, network=network, )
@task def test(ctx, name=None, coverage=False): if name is not None: apps = name else: apps = '' if coverage: ignored = ['*{0}*'.format(ignored_pkg) for ignored_pkg in env['coverage_omit_patterns']] coverage_cmd = "coverage run --source='catalog' --omit=" + ','.join(ignored) else: coverage_cmd = env['python'] ctx.run('{coverage_cmd} manage.py test {apps}'.format(apps=apps, coverage_cmd=coverage_cmd)) @task(pre=[call(test, coverage=True)]) def coverage(ctx): ctx.run('coverage html') @task def server(ctx, ip="0.0.0.0", port=8000): dj('runserver {ip}:{port}'.format(ip=ip, port=port), capture=False) @task(aliases=['cd']) def clean_data(ctx, creator=None): if creator is None: creator = 'cpritch3' """ one-off to clean degenerate data in Sponsor, Platform, ModelDocumentation """ print("Splitting")
'bundle exec jekyll serve ' '--incremental ' '--host 0.0.0.0 ' '--drafts ' f'--destination {_destination} ' f'--baseurl {_base_url} ' f'--config={",".join(_configs)}' ) with console.status('[bold green] Serving the content...') as status: ctx.run(cmd, shell='/bin/sh') @task(pre=[ clean, call(build, destination='_public'), call(build, destination=f'_public', lecturer=True) ]) def deploy(ctx, destination='_public'): """ Deploys course to the web. """ token = os.getenv('DEPLOY_TOKEN') course = os.getenv('COURSE') with console.status('[bold green] Packaging...') as status: # zip # from pathlib import Path with ctx.cd(destination):
f'cd {ROOT_DIR}/gem5/ && scons -j$(nproc) ./build/GCN3_X86/gem5.opt') if archive: _run(c, f'tar -czf gem5-build.tar gem5/build/') @task def build_tests(c, archive=False): """Build all tests""" for test_path in TEST_PATHS: _run(c, f'cd {test_path} && make') if archive: for i, test_paths in enumerate(TEST_PATHS): _run(c, f'tar -czf bin-{i}.tar {test_path}/bin/') @task(pre=[call(build_gem5, archive=True), call(build_tests, archive=True)]) def build(c): """Runs all build sub-tasks""" @task def test(c, index=0): """Run a specific test, please specify index""" exec_path = f'{ROOT_DIR}/gem5/build/GCN3_X86/gem5.opt' conf_path = f'{ROOT_DIR}/gem5/configs/example/apu_se.py' test_dir = TEST_PATHS[index] print(f'Testing {test_dir}...') # Try to find executable try_paths = [os.path.basename(test_dir), os.path.basename(test_dir) + '.o'] try_paths = [[ex, os.path.join('bin', ex)] for ex in try_paths]
c.run(command) # Remove the protobuf now we've generated the source moved_protobuf_spec.unlink() @task(pre=[proto], help={'wheel': "Build a wheel distribution"}) def dist(c, wheel=False): """ Build source and wheel packages """ c.run("python setup.py sdist") if wheel: c.run("python setup.py bdist_wheel") @task(pre=[clean, tasks.call(dist, wheel=True)]) def release(c): """ Make a release of the python package to pypi """ c.run("twine upload dist/*") @task def docker(c, tag="latest"): """ Build docker image for project """ parent_dockerignore = ROOT_DIR.parent.joinpath(".dockerignore") shutil.copy(ROOT_DIR.joinpath(".dockerignore"), parent_dockerignore) c.run("docker build -t {}:{} -f Dockerfile ..".format(DOCKER_IMAGE, tag))
--[no-]sourcemaps: Build source maps (defaults to true). """ args = [] if minify: args.append('--minify') if not sourcemaps: args.append('--skip-source-maps') run('jspm bundle-sfx %s %s' % (os.path.join('src', 'main'), ' '.join(args))) @task(call(build_bundle, sourcemaps=False)) def build_python(): """ Build everything needed to install python package. """ run('python setup.py build') @task(build_python) def build(): """ Perform a production build of the javascript code, its dependencies and the python package. """