Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@task("any-task-name")
@description("any-description")
def task_with_description():
pass
@task
def task1():
pass
@task
@description("Run a negative test that will fail due to exception.")
def negative_test(project, logger):
print("Running a -ve test")
command = ExternalCommandBuilder('hydra', project)
command.use_argument('negative-test-exception')
result = command.run_on_production_source_files(logger)
if result.exit_code:
raise BuildFailedException("Exit code is set")
return result.exit_code
@task
@description("Installs all runtime dependencies specified in the build descriptor")
def install_runtime_dependencies(logger, project):
logger.info("Installing runtime dependencies")
install_dependency(logger, project, project.dependencies)
@task("install")
def install_distribution(project, logger):
logger.info("Installing project %s-%s", project.name, project.version)
_prepare_reports_dir(project)
outfile_name = project.expand_path("$dir_reports", "distutils",
"pip_install_%s" % datetime.utcnow().strftime("%Y%m%d%H%M%S"))
pip_utils.pip_install(
install_targets=project.expand_path("$dir_dist"),
index_url=project.get_property("install_dependencies_index_url"),
extra_index_url=project.get_property("install_dependencies_extra_index_url"),
force_reinstall=True,
logger=logger,
verbose=project.get_property("verbose"),
cwd=".",
outfile_name=outfile_name,
error_file_name=outfile_name)
@task
@description("Installs all build dependencies specified in the build descriptor")
def install_build_dependencies(logger, project):
logger.info("Installing build dependencies")
install_dependency(logger, project, project.build_dependencies)
@task
def train_squad(project):
create_dir('squad')
if project.get_property('idle_train') == 'True':
val_time = '600'
time_limit = '900'
else:
val_time = '1800'
time_limit = '86400'
metrics = bu.model(['-t', 'squad',
'-m', 'deeppavlov.agents.squad.squad:SquadAgent',
'--batchsize', '64',
'--display-examples', 'False',
'--num-epochs', '-1',
'--max-train-time', time_limit,
'--log-every-n-secs', '60',
'--log-every-n-epochs', '-1',
@task
def package(project, logger):
run_command('package', project, logger)
@task
def run_unit_tests(project, logger):
run_command('run_unit_tests', project, logger)
@task("analyze")
def execute_pymetrics(project, logger):
logger.info("Executing pymetrics on project sources")
source_dir = project.expand_path("$dir_source_main_python")
files_to_scan = []
for root, _, files in os.walk(source_dir):
for file_name in files:
if file_name.endswith(".py"):
files_to_scan.append(os.path.join(root, file_name))
csv_file = project.expand_path("$dir_reports/pymetrics.csv")
command = ["pymetrics", "--nosql", "-c", csv_file] + files_to_scan
report_file = project.expand_path("$dir_reports/pymetrics")