Skip to content

Commit

Permalink
Run lock from plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
soapy1 committed Nov 7, 2024
1 parent 2f85e67 commit 1c076f0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 23 deletions.
37 changes: 17 additions & 20 deletions conda-store-server/conda_store_server/_internal/worker/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from sqlalchemy.orm import Session

from conda_store_server import api
from conda_store_server.plugins import plugin_context
from conda_store_server._internal import action, conda_utils, orm, schema, utils


Expand Down Expand Up @@ -222,35 +223,35 @@ def build_conda_environment(db: Session, conda_store, build):
prefix="action_save_lockfile: ",
),
)
conda_lock_spec = context.result
else:
context = action.action_solve_lockfile(
settings.conda_command,
specification=schema.CondaSpecification.parse_obj(
conda_lock_spec = conda_store.plugin_manager.hook.lock_environment(
context=plugin_context.PluginContext(
conda_store=conda_store,
stdout=LoggedStream(
db=db,
conda_store=conda_store,
build=build,
prefix="hook-lock_environment: ",
)
),
spec=schema.CondaSpecification.parse_obj(
build.specification.spec
),
platforms=settings.conda_solve_platforms,
conda_flags=conda_store.conda_flags,
stdout=LoggedStream(
db=db,
conda_store=conda_store,
build=build,
prefix="action_solve_lockfile: ",
),
)

conda_store.storage.set(
db,
build.id,
build.conda_lock_key,
json.dumps(
context.result, indent=4, cls=utils.CustomJSONEncoder
conda_lock_spec, indent=4, cls=utils.CustomJSONEncoder
).encode("utf-8"),
content_type="application/json",
artifact_type=schema.BuildArtifactType.LOCKFILE,
)

conda_lock_spec = context.result

context = action.action_fetch_and_extract_conda_packages(
conda_lock_spec=conda_lock_spec,
pkgs_dir=conda_utils.conda_root_package_dir(),
Expand Down Expand Up @@ -335,18 +336,14 @@ def build_conda_environment(db: Session, conda_store, build):


def solve_conda_environment(db: Session, conda_store, solve: orm.Solve):
settings = conda_store.get_settings(db=db)

solve.started_on = datetime.datetime.utcnow()
db.commit()

context = action.action_solve_lockfile(
conda_command=settings.conda_command,
specification=schema.CondaSpecification.parse_obj(solve.specification.spec),
conda_lock_spec = conda_store.plugin_manager.hook.lock_environment(
context=plugin_context.PluginContext(),
spec=schema.CondaSpecification.parse_obj(solve.specification.spec),
platforms=[conda_utils.conda_platform()],
conda_flags=conda_store.conda_flags,
)
conda_lock_spec = context.result

action.action_add_lockfile_packages(
db=db,
Expand Down
4 changes: 2 additions & 2 deletions conda-store-server/conda_store_server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from traitlets.config import LoggingConfigurable

from conda_store_server import CONDA_STORE_DIR, BuildKey, api, registry, storage
from conda_store_server.plugins import hookspec, registry
from conda_store_server.plugins import hookspec, plugin_registry
from conda_store_server.exception import CondaStorePluginNotFoundError
from conda_store_server._internal import conda_utils, environment, orm, schema, utils

Expand Down Expand Up @@ -479,7 +479,7 @@ def plugin_registry(self):
if hasattr(self, "_plugin_registry"):
return self._plugin_registry

self._plugin_registry = registry.PluginRegistry()
self._plugin_registry = plugin_registry.PluginRegistry()
self._plugin_registry.collect_plugins()
return self._plugin_registry

Expand Down
2 changes: 1 addition & 1 deletion conda-store-server/conda_store_server/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@

BUILTIN_PLUGINS = [
conda_lock.CondaLock
]
]

0 comments on commit 1c076f0

Please sign in to comment.