Skip to content

cli: update of funders fail due to missing datastream config variables #356

@zzacharo

Description

@zzacharo

Use case

The use case we have is to update the list of funders.

Current behaviour

In an instance e.g cds-rdm we hold a funder.yaml file with the following syntax:

- id: 00k4n6c32
  country: BE
  identifiers:
    - identifier: 00k4n6c32
      scheme: ror
  name: European Commission
  title:
    en: European Commission

If we add a new funder in the list and then we run the command invenio vocabularies update -v funders -f app_data/vocabularies.yaml then we get an error:

Traceback (most recent call last):
  File "/usr/local/bin/invenio", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/flask/cli.py", line 357, in decorator
    return __ctx.invoke(f, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/invenio_vocabularies/cli.py", line 103, in update
    for w_conf in config["writers"]:
KeyError: 'writers'

The update works if you update the app_data/vocabularies.yaml as below:

funders:
  pid-type: fun
  data-file: updated_funders.yaml
  readers:
    - type: yaml
  writers:
    - type: funders-service
      args:
        update: True

Expected solution

We should either fix the cli command to incorporate a more user friendly way of updating a vocabulary entry e.g identify if the data-file is a yaml and use the correct reader or indicate another way of updating or inserting entries in a vocabulary

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Backlog 😴

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions