Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Enable Live logs and add option to disable #930

Merged
merged 6 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions bioconda_utils/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ def build(recipe: str, pkg_paths: List[str] = None,
mulled_conda_image: str = pkg_test.MULLED_CONDA_IMAGE,
record_build_failure: bool = False,
dag: Optional[nx.DiGraph] = None,
skiplist_leafs: bool = False) -> BuildResult:
skiplist_leafs: bool = False,
live_logs: bool = True) -> BuildResult:
"""
Build a single recipe for a single env

Expand All @@ -81,6 +82,7 @@ def build(recipe: str, pkg_paths: List[str] = None,
record_build_failure: If True, record build failures in a file next to the meta.yaml
dag: optional nx.DiGraph with dependency information
skiplist_leafs: If True, blacklist leaf packages that fail to build
live_logs: If True, enable live logging during the build process
"""
if record_build_failure and not dag:
raise ValueError("record_build_failure requires dag to be set")
Expand Down Expand Up @@ -137,7 +139,8 @@ def build(recipe: str, pkg_paths: List[str] = None,
docker_builder.build_recipe(recipe_dir=os.path.abspath(recipe),
build_args=' '.join(args),
env=whitelisted_env,
noarch=is_noarch)
noarch=is_noarch,
live_logs=live_logs)
# Use presence of expected packages to check for success
for pkg_path in pkg_paths:
if not os.path.exists(pkg_path):
Expand All @@ -156,7 +159,7 @@ def build(recipe: str, pkg_paths: List[str] = None,
cmd += [config_file.arg, config_file.path]
cmd += [os.path.join(recipe, 'meta.yaml')]
with utils.Progress():
utils.run(cmd, mask=False)
utils.run(cmd, mask=False, live=live_logs)

logger.info('BUILD SUCCESS %s',
' '.join(os.path.basename(p) for p in pkg_paths))
Expand Down Expand Up @@ -295,7 +298,8 @@ def build_recipes(recipe_folder: str, config_path: str, recipes: List[str],
keep_old_work: bool = False,
mulled_conda_image: str = pkg_test.MULLED_CONDA_IMAGE,
record_build_failures: bool = False,
skiplist_leafs: bool = False):
skiplist_leafs: bool = False,
live_logs: bool = True):
"""
Build one or many bioconda packages.

Expand All @@ -322,6 +326,8 @@ def build_recipes(recipe_folder: str, config_path: str, recipes: List[str],
worker_offset: If n_workers is >1, then every worker_offset within a given group of
sub-DAGs will be processed.
keep_old_work: Do not remove anything from environment, even after successful build and test.
skiplist_leafs: If True, blacklist leaf packages that fail to build
live_logs: If True, enable live logging during the build process
"""
if not recipes:
logger.info("Nothing to be done.")
Expand Down Expand Up @@ -421,7 +427,8 @@ def build_recipes(recipe_folder: str, config_path: str, recipes: List[str],
mulled_conda_image=mulled_conda_image,
dag=dag,
record_build_failure=record_build_failures,
skiplist_leafs=skiplist_leafs)
skiplist_leafs=skiplist_leafs,
live_logs=live_logs)

if not res.success:
failed.append(recipe)
Expand Down
7 changes: 5 additions & 2 deletions bioconda_utils/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ def do_lint(recipe_folder, config, packages="*", cache=None, list_checks=False,
Dockerfile template.''')
@arg("--record-build-failures", action="store_true", help="Record build failures in build_failure.yaml next to the recipe.")
@arg("--skiplist-leafs", action="store_true", help="Skiplist leaf recipes (i.e. ones that are not depended on by any other recipes) that fail to build.")
@arg('--disable-live-logs', action='store_true', help="Disable live logging during the build process")
@enable_logging()
def build(recipe_folder, config, packages="*", git_range=None, testonly=False,
force=False, docker=None, mulled_test=False, build_script_template=None,
Expand All @@ -443,7 +444,8 @@ def build(recipe_folder, config, packages="*", git_range=None, testonly=False,
mulled_conda_image=pkg_test.MULLED_CONDA_IMAGE,
docker_base_image=None,
record_build_failures=False,
skiplist_leafs=False):
skiplist_leafs=False,
disable_live_logs=False):
cfg = utils.load_config(config)
setup = cfg.get('setup', None)
if setup:
Expand Down Expand Up @@ -503,7 +505,8 @@ def build(recipe_folder, config, packages="*", git_range=None, testonly=False,
keep_old_work=keep_old_work,
mulled_conda_image=mulled_conda_image,
record_build_failures=record_build_failures,
skiplist_leafs=skiplist_leafs)
skiplist_leafs=skiplist_leafs,
live_logs=(not disable_live_logs))
exit(0 if success else 1)


Expand Down
4 changes: 2 additions & 2 deletions bioconda_utils/docker_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ def _build_image(self):
shutil.rmtree(build_dir)
return p

def build_recipe(self, recipe_dir, build_args, env, noarch=False):
def build_recipe(self, recipe_dir, build_args, env, noarch=False, live_logs=True):
"""
Build a single recipe.

Expand Down Expand Up @@ -474,7 +474,7 @@ def build_recipe(self, recipe_dir, build_args, env, noarch=False):

logger.debug('DOCKER: cmd: %s', cmd)
with utils.Progress():
p = utils.run(cmd, mask=False)
p = utils.run(cmd, mask=False, live=live_logs)
return p

def cleanup(self):
Expand Down