Skip to content

Commit

Permalink
[pre-commit.ci] Apply automatic pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Apr 14, 2024
1 parent 5ac779e commit 731053c
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 11 deletions.
2 changes: 1 addition & 1 deletion conda-store-server/conda_store_server/action/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def run_command(self, command, redirect_stderr=True, **kwargs):
stderr=subprocess.STDOUT if redirect_stderr else subprocess.PIPE,
bufsize=1,
universal_newlines=True,
**kwargs
**kwargs,
) as p:
for line in p.stdout:
self.stdout.write(line)
Expand Down
67 changes: 57 additions & 10 deletions conda-store-server/conda_store_server/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

class LoggedStream:
"""Allows writing to storage via logging.StreamHandler"""

def __init__(self, db, conda_store, build, prefix=None):
self.db = db
self.conda_store = conda_store
Expand Down Expand Up @@ -199,7 +200,12 @@ def build_conda_environment(db: Session, conda_store, build):
build.specification.spec
),
platforms=settings.conda_solve_platforms,
stdout=LoggedStream(db=db, conda_store=conda_store, build=build, prefix="action_solve_lockfile: "),
stdout=LoggedStream(
db=db,
conda_store=conda_store,
build=build,
prefix="action_solve_lockfile: ",
),
)

conda_store.storage.set(
Expand All @@ -216,13 +222,23 @@ def build_conda_environment(db: Session, conda_store, build):
context = action.action_fetch_and_extract_conda_packages(
conda_lock_spec=conda_lock_spec,
pkgs_dir=conda_utils.conda_root_package_dir(),
stdout=LoggedStream(db=db, conda_store=conda_store, build=build, prefix="action_fetch_and_extract_conda_packages: "),
stdout=LoggedStream(
db=db,
conda_store=conda_store,
build=build,
prefix="action_fetch_and_extract_conda_packages: ",
),
)

context = action.action_install_lockfile(
conda_lock_spec=conda_lock_spec,
conda_prefix=conda_prefix,
stdout=LoggedStream(db=db, conda_store=conda_store, build=build, prefix="action_install_lockfile: "),
stdout=LoggedStream(
db=db,
conda_store=conda_store,
build=build,
prefix="action_install_lockfile: ",
),
)

utils.symlink(conda_prefix, environment_prefix)
Expand All @@ -232,19 +248,34 @@ def build_conda_environment(db: Session, conda_store, build):
permissions=settings.default_permissions,
uid=settings.default_uid,
gid=settings.default_gid,
stdout=LoggedStream(db=db, conda_store=conda_store, build=build, prefix="action_set_conda_prefix_permissions: "),
stdout=LoggedStream(
db=db,
conda_store=conda_store,
build=build,
prefix="action_set_conda_prefix_permissions: ",
),
)

action.action_add_conda_prefix_packages(
db=db,
conda_prefix=conda_prefix,
build_id=build.id,
stdout=LoggedStream(db=db, conda_store=conda_store, build=build, prefix="action_add_conda_prefix_packages: "),
stdout=LoggedStream(
db=db,
conda_store=conda_store,
build=build,
prefix="action_add_conda_prefix_packages: ",
),
)

context = action.action_get_conda_prefix_stats(
conda_prefix,
stdout=LoggedStream(db=db, conda_store=conda_store, build=build, prefix="action_get_conda_prefix_stats: "),
stdout=LoggedStream(
db=db,
conda_store=conda_store,
build=build,
prefix="action_get_conda_prefix_stats: ",
),
)
build.size = context.result["disk_usage"]

Expand Down Expand Up @@ -304,7 +335,12 @@ def build_conda_env_export(db: Session, conda_store, build: orm.Build):
context = action.action_generate_conda_export(
conda_command=settings.conda_command,
conda_prefix=conda_prefix,
stdout=LoggedStream(db=db, conda_store=conda_store, build=build, prefix="action_generate_conda_export: "),
stdout=LoggedStream(
db=db,
conda_store=conda_store,
build=build,
prefix="action_generate_conda_export: ",
),
)

conda_prefix_export = yaml.dump(context.result).encode("utf-8")
Expand All @@ -328,8 +364,14 @@ def build_conda_pack(db: Session, conda_store, build: orm.Build):
with tempfile.TemporaryDirectory() as tmpdir:
output_filename = pathlib.Path(tmpdir) / "environment.tar.gz"
context = action.action_generate_conda_pack(
conda_prefix=conda_prefix, output_filename=output_filename,
stdout=LoggedStream(db=db, conda_store=conda_store, build=build, prefix="action_generate_conda_pack: "),
conda_prefix=conda_prefix,
output_filename=output_filename,
stdout=LoggedStream(
db=db,
conda_store=conda_store,
build=build,
prefix="action_generate_conda_pack: ",
),
)
conda_store.storage.fset(
db,
Expand Down Expand Up @@ -415,7 +457,12 @@ def build_constructor_installer(db: Session, conda_store, build: orm.Build):
),
installer_dir=pathlib.Path(tmpdir),
version=build.build_key,
stdout=LoggedStream(db=db, conda_store=conda_store, build=build, prefix="action_generate_constructor_installer: "),
stdout=LoggedStream(
db=db,
conda_store=conda_store,
build=build,
prefix="action_generate_constructor_installer: ",
),
)
output_filename = context.result
if output_filename is None:
Expand Down

0 comments on commit 731053c

Please sign in to comment.