Skip to content

Commit

Permalink
Adds a bit more structure, but still needs data (structures)
Browse files Browse the repository at this point in the history
  • Loading branch information
SKernchen committed Mar 4, 2024
1 parent 3961222 commit 156e918
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
18 changes: 13 additions & 5 deletions src/hermes/commands/deposit/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
import abc
import argparse

import click
from pydantic import BaseModel

from hermes.commands.base import HermesCommand, HermesPlugin
from hermes.model.context import CodeMetaContext


class BaseDepositPlugin(HermesPlugin):
Expand All @@ -21,8 +19,7 @@ class BaseDepositPlugin(HermesPlugin):
TODO: describe workflow... needs refactoring to be less stateful!
"""

def __init__(self, click_ctx: click.Context, ctx: CodeMetaContext) -> None:
self.click_ctx = click_ctx
def __init__(self, ctx):
self.ctx = ctx

def __call__(self, command: HermesCommand) -> None:
Expand Down Expand Up @@ -110,4 +107,15 @@ class HermesDepositCommand(HermesCommand):
settings_class = DepositSettings

def __call__(self, args: argparse.Namespace) -> None:
pass
self.args = args
plugin_name = self.settings.target
'''try:
plugin_func = self.plugins[plugin_name](ctx)
deposited_data = plugin_func(self)
except KeyError:
self.log.error("Plugin '%s' not found.", plugin_name)
except HermesValidationError as e:
self.log.error("Error while executing %s: %s", plugin_name, e)'''
10 changes: 5 additions & 5 deletions src/hermes/commands/deposit/invenio.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,14 @@ class InvenioDepositPlugin(BaseDepositPlugin):
invenio_resolver_class = InvenioResolver
settings_class = InvenioDepositSettings

def __init__(self, click_ctx: click.Context, ctx: CodeMetaContext, client=None, resolver=None) -> None:
super().__init__(click_ctx, ctx)
def __init__(self, ctx: CodeMetaContext, client=None, resolver=None) -> None:
super().__init__(ctx)

self.invenio_context_path = ContextPath.parse(f"deposit.{self.platform_name}")
self.invenio_ctx = None

if client is None:
auth_token = self.click_ctx.params.get("auth_token")
auth_token = self.ctx.params.get("auth_token")
if auth_token is None:
raise DepositionUnauthorizedError("No auth token given for deposition platform")
self.client = self.invenio_client_class(auth_token=auth_token, platform_name=self.platform_name)
Expand Down Expand Up @@ -334,7 +334,7 @@ def is_initial_publication(self) -> bool:
def create_initial_version(self) -> None:
"""Create an initial version of a publication."""

if not self.click_ctx.params['initial']:
if not self.ctx.params['initial']:
raise RuntimeError("Please use `--initial` to make an initial deposition.")

response = self.client.new_deposit()
Expand Down Expand Up @@ -412,7 +412,7 @@ def upload_artifacts(self) -> None:

bucket_url = self.links["bucket"]

files: list[click.Path] = self.click_ctx.params["file"]
files: list[click.Path] = self.ctx.params["file"]
for path_arg in files:
path = Path(path_arg)

Expand Down
11 changes: 10 additions & 1 deletion src/hermes/commands/process/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@

import argparse

from pydantic import BaseModel

from hermes.commands.base import HermesCommand, HermesPlugin
from hermes.model.errors import HermesValidationError
from hermes.model.context import HermesContext, CodeMetaContext


class HermesProcessPlugin(HermesPlugin):
Expand All @@ -17,6 +21,11 @@ class HermesProcessCommand(HermesCommand):
""" Process the collected metadata into a common dataset. """

command_name = "process"
settings_class = None

def __call__(self, args: argparse.Namespace) -> None:
pass
self.args = args
# TODO: get harvested data
# TODO: Merge Datasets


0 comments on commit 156e918

Please sign in to comment.