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 3ce4a49 commit abd4737
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 18 deletions.
10 changes: 6 additions & 4 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, 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, registry


def conda_store_validate_specification(
Expand Down Expand Up @@ -500,7 +500,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
2 changes: 1 addition & 1 deletion conda-store-server/conda_store_server/plugins/registry.py
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 abd4737

Please sign in to comment.