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 Nov 7, 2024
1 parent 1c076f0 commit 95d6738
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
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
from conda_store_server.plugins import plugin_context


class LoggedStream:
Expand Down Expand Up @@ -233,11 +233,9 @@ def build_conda_environment(db: Session, conda_store, build):
conda_store=conda_store,
build=build,
prefix="hook-lock_environment: ",
)
),
spec=schema.CondaSpecification.parse_obj(
build.specification.spec
),
),
spec=schema.CondaSpecification.parse_obj(build.specification.spec),
platforms=settings.conda_solve_platforms,
)

Expand Down
14 changes: 8 additions & 6 deletions conda-store-server/conda_store_server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import sys
from contextlib import contextmanager
from typing import Any, Dict
import pluggy

import pluggy
import pydantic
from celery import Celery, group
from sqlalchemy.orm import Session, sessionmaker
Expand All @@ -28,9 +28,9 @@
from traitlets.config import LoggingConfigurable

from conda_store_server import CONDA_STORE_DIR, BuildKey, api, registry, storage
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
from conda_store_server.exception import CondaStorePluginNotFoundError
from conda_store_server.plugins import hookspec, plugin_registry


def conda_store_validate_specification(
Expand Down Expand Up @@ -491,7 +491,7 @@ def plugin_manager(self):
self._plugin_manager = pluggy.PluginManager(hookspec.spec_name)
self._plugin_manager.add_hookspecs(hookspec.CondaStoreSpecs)

# Get settings - required to configure the lock plugin with the
# Get settings - required to configure the lock plugin with the
# correct conda command
with self.session_factory() as db:
settings = self.get_settings(db)
Expand All @@ -500,7 +500,7 @@ def plugin_manager(self):
self.load_plugin_by_name(
"lock-conda_lock",
conda_command=settings.conda_command,
conda_flags=self.conda_flags
conda_flags=self.conda_flags,
)

return self._plugin_manager
Expand All @@ -509,7 +509,9 @@ def load_plugin_by_name(self, name, *args, **kwargs):
"""Loads a plugin from the plugin registry into the plugin manager"""
target_plugin = self.plugin_registry.get_plugin(name)
if target_plugin is None:
raise CondaStorePluginNotFoundError(name, self.plugin_registry.list_plugin_names())
raise CondaStorePluginNotFoundError(
name, self.plugin_registry.list_plugin_names()
)
self.plugin_manager.register(target_plugin(*args, **kwargs))

def ensure_settings(self, db: Session):
Expand Down
5 changes: 1 addition & 4 deletions conda-store-server/conda_store_server/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,4 @@

from conda_store_server.plugins.lock import conda_lock


BUILTIN_PLUGINS = [
conda_lock.CondaLock
]
BUILTIN_PLUGINS = [conda_lock.CondaLock]
6 changes: 3 additions & 3 deletions conda-store-server/conda_store_server/plugins/hookspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

import pluggy
import typing

import pluggy

from conda_store_server._internal import conda_utils, schema
from conda_store_server.plugins import plugin_context


spec_name = "conda-store-server"

hookspec = pluggy.HookspecMarker(spec_name)
Expand All @@ -23,7 +23,7 @@ class CondaStoreSpecs:
def lock_environment(
self,
context: plugin_context.PluginContext,
spec: schema.CondaSpecification,
spec: schema.CondaSpecification,
platforms: typing.List[str] = [conda_utils.conda_platform()],
) -> str:
"""Lock spec"""
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,29 @@
import typing

import yaml

from conda_lock.conda_lock import run_lock

from conda_store_server._internal import conda_utils, schema
from conda_store_server.plugins import hookspec
from conda_store_server.plugins.plugin_context import PluginContext


class CondaLock():
class CondaLock:
@classmethod
def name(cls):
return "lock-conda_lock"

def __init__(self, conda_flags="--strict-channel-priority", conda_command="mamba", *kwargs):
def __init__(
self, conda_flags="--strict-channel-priority", conda_command="mamba", *kwargs
):
self.conda_command = conda_command
self.conda_flags = conda_flags

@hookspec.hookimpl
def lock_environment(
self,
context: PluginContext,
spec: schema.CondaSpecification,
spec: schema.CondaSpecification,
platforms: typing.List[str] = [conda_utils.conda_platform()],
) -> str:
context.log.info("lock_environment entrypoint for conda-lock")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,19 @@ class PluginContext:
* the variables: conda_store, log, stdout, stderr
* the functions: run_command, run
"""
def __init__(self, conda_store=None, stdout=None, stderr=None, log_level=logging.INFO):

def __init__(
self, conda_store=None, stdout=None, stderr=None, log_level=logging.INFO
):
if stdout is not None and stderr is None:
stderr = stdout

self.id = str(uuid.uuid4())
self.stdout = stdout if stdout is not None else io.StringIO()
self.stderr = stderr if stderr is not None else io.StringIO()
self.log = logging.getLogger(f"conda_store_server.plugins.plugin_context.{self.id}")
self.log = logging.getLogger(
f"conda_store_server.plugins.plugin_context.{self.id}"
)
self.log.propagate = False
self.log.addHandler(logging.StreamHandler(stream=self.stdout))
self.log.setLevel(log_level)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from conda_store_server.plugins import BUILTIN_PLUGINS


class PluginRegistry():
class PluginRegistry:
_instance = None

def __new__(cls):
Expand Down

0 comments on commit 95d6738

Please sign in to comment.