GithubHelp home page GithubHelp logo

inveniosoftware / invenio-deposit Goto Github PK

View Code? Open in Web Editor NEW
10.0 90.0 46.0 1.3 MB

Invenio module for depositing metadata using workflows.

Home Page: https://invenio-deposit.readthedocs.io

License: MIT License

Python 90.91% HTML 8.43% Shell 0.29% JavaScript 0.36%

invenio-deposit's Introduction

Invenio-Deposit

image

image

image

Module for depositing record metadata and uploading files.

This is an experimental developer preview release.

invenio-deposit's People

Contributors

alizeepace avatar crepererum avatar drjova avatar egabancho avatar frankois avatar glignos avatar greut avatar hachreak avatar ioannistsanaktsidis avatar jalavik avatar javierdelgadofernandez avatar jirikuncar avatar jmartinm avatar jorikvankemenade avatar jstypka avatar kneczaj avatar konstantinoskostis avatar lnielsen avatar nharraud avatar nikofil avatar ntarocco avatar paulinalach avatar pedrogaudencio avatar pxke avatar samihiltunen avatar slint avatar tiborsimko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

invenio-deposit's Issues

global: naming consistency

Should we consider changing some of the names in the module while it's still easy:

  • invenio-deposit -> invenio-deposits (plus all instances of module name usage in directory structures, config).
  • _deposit -> _internal (deposit-specific stuff in JSON metadata)
  • pid_type='dep' -> pid_type='depid' (invenio_deposit/config.py)

Example does not work

Starting from a freshly created virtualenv. I had to add several packages in requirements.txt and some have to be installed from git:

Moreover the default schema does not work with angular schema form: []should be removed foritems`:

        "name": "owners",
          "owners": {
          "title": "Owners",
          "description": "Owners of the deposit (a list of user's IDs).",
          "type": "array",
          "name": "owners",
          "items": {
              "type": "integer"
            }
        },

Note: I'm note sure that $ref works with angular schema form for _files.

At the end I still got errors:

  • glyphicons
  • http://localhost:5000/deposit/undefined/toto.pdf 404 not found during the file uploads

As this module is quite complex and the doc is not yet completely written, it would be great to have a working example.

Thanks in advance.

tests: fix missing assets

A. Do not render templates in tests
B. Install bower dependencies, collect files, and build assets

api: stabilise and document

  • check existing API functionality
    • deposit: multiple deposits per site #108
  • add missing important API functionality
  • check API function signatures and parameters
  • enhance API docstrings (param, returns, raises, versionadded)
  • plug API functions to existing docs

tests: simplify doctest execution

The following cookiecutter change:

inveniosoftware/cookiecutter-invenio-module#98

should be propagated to this Invenio module.

Namely, in run-tests.sh, the sphinx for doctests is invoked after pytest run:

$ tail -3 ./\{\{\ cookiecutter.project_shortname\ \}\}/run-tests.sh
sphinx-build -qnNW docs docs/_build/html && python setup.py test && sphinx-build -qnNW -b doctest docs docs/_build/doctest

This sometimes led to problems on Travis CI with the second sphinx-build run due
to "disappearing" dependencies after the example application was tested.

A solution that worked for invenio-marc21 (see
inveniosoftware/invenio-marc21#49 (comment))
and that was integrated in cookiecutter (see
inveniosoftware/cookiecutter-invenio-module#98) was to
run doctest execution in pytest, removing the second sphinx-build invocation.

This both solved Travis CI build failures and simplified test suite execution.

Note that this change may necessitate to amend the code tests etc so that things
would be executed with the Flask application context (see
inveniosoftware/invenio-marc21@09e98fc).

api: empty _files field added in deposit but not in record

Problem:
When publishing a deposit for the first time. If the deposit has no files, it will still get an _files field added automatically and this field won't be added in the published record.

Why this happens:
Deposit._publish_new calls Deposit. _process_files which calls self.files which calls invenio_records_files. FilesIterator which modifies the deposit itself by adding an _files field.
As Deposit._publish_new had already made a copy of the deposit data, this new field is not added to the published record.

The impact is low but this is still a discrepancy as the published record should be an exact copy of the deposit when published.

Now the question is:

  • do we remove the creation of the _files field from self.files? This in my opinion is the best design as an iterator should not modify anything. (This is similar to invenio-records-files/issues#21 where a getter creates the bucket)
  • or do we add by default an empty _files field to the published record data? Simpler solution but kind of ugly as one has to dig in invenio-records-files to understand why it is needed. This might create bugs later when code is refactored (as it always is one day or the other).

travis: [docutils 0.13.1] assert not self.context

In Travis, tests with minimal requirements are failing:

Exception occurred: File "/home/plach/.pyenv/versions/3.5.2/envs/inv-dep-3.5.2/lib/python3.5/site-packages/docutils/writers/_html_base.py", line 671, in depart_document
assert not self.context, 'len(context) = %s' % len(self.context)
AssertionError: len(context) = 5

It has already been raised in this issue.

It can be fixed by upgrading Shinx to 1.5.1 in setup.py.

api: enable overlays to replace the Deposit API class with a custom subclass

Why:
The current recommended way to customise any Record API is to create a sublcass. However there are still places in invenio-deposit with explicit references to the Deposit or Record API classes instead of using configuration variables.

Who needs it:
B2Share uses JSON Schemas generated on the fly. The current implementation of the Deposit API class uses invenio-jsonschemas. We need to create a subclass of Deposit in order to override this behavior.

deposit: multiple deposits per site

Given the current configuration options for a deposit is not possible to have several/different deposit in one site.

I think options like DEPOSIT_DEFAULT_SCHEMAFORM or DEPOSIT_DEFAULT_JSONSCHEMA should go together with the rest of the deposit configuration inside DEPOSIT_REST_ENDPOINTS.

I am not sure about other things, like templates.

deposit: autocompletion of from ORCID (author name when entering ORCID)

@Kennethhole commented on Sun Sep 21 2014

It happens that authors submit new work with different variations of their name. This could be resolved by letting them enter their ORCID and have Invenio auto complete their name.

I think integrating GET orcid_id API could be helpful?
http://support.orcid.org/knowledgebase/articles/116874-orcid-api-guide

Is this desired by more people?


@lnielsen commented on Mon Sep 22 2014

WebSubmit has been superseded by the new deposit module so since this is a feature request I've tagged it under the deposit module.

Autocompletion from ORCID is definitely something we are interested in. I however don't know which would be the best way. The method you suggest starts with the ORCID, then retrieves the name. Alternatively, you could start with the name and auto-complete using the ORCID public profiles data file (https://orcid.org/content/orcid-public-data-file-2013).

rest: invalid deposit class detection when missing pid_value view argument causes missing action "links"

On POST calls, since request.view_args['pid_value'] is not part of the url (/api/deposit/depositions), the detected deposit class always falls back to invenio_deposit.api.Deposit, causing any additional action links added using the invenio_deposit.urils.mark_as_action decorator to be skipped.

Perhaps adding a pid_type -> deposit_class mapping as part of a current_records_rest.default_pid_classes might help to determine the desired default:

deposit_cls = current_records_rest.default_pid_classes.get(pid.pid_type, Deposit)
if 'pid_value' in request.view_args:
    deposit_cls = request.view_args['pid_value'].data[1].__class__

Update: This issue leads to incorrect links generation which is extremely problematic when there are additional actions implemented in a deposit class, and responses have to be consumed by a Javascript UI application. Example:

  1. (assume we have a custom deposit class with a MyDeposit.custom_action)
  2. Client does POST /api/deposit/depositions, gets back depid: 1234 and links with missing custom_action link.
  3. Client wants to perform custom_action, but link is missing...
  4. Client "reloads" the page (i.e. refetches /api/deposit/depositions/1234), which now contains the missing custom_action link.

sherpa_romeo: complete or remove

In invenio-utils, the Sherpa/Romeo client was recently removed:

In invenio-deposit, it is still used:

invenio_deposit/autocomplete_utils.py:23:from invenio_utils.sherpa_romeo import SherpaRomeoSearch
invenio_deposit/autocomplete_utils.py:54:def sherpa_romeo_publishers(dummy_form, dummy_field, term, limit=50):
invenio_deposit/autocomplete_utils.py:57:        sherpa_romeo = SherpaRomeoSearch()
invenio_deposit/autocomplete_utils.py:58:        publishers = sherpa_romeo.search_publisher(term)
invenio_deposit/autocomplete_utils.py:65:def sherpa_romeo_journals(dummy_form, dummy_field, term, limit=50):
invenio_deposit/fields/issn.py:26:# from ..processor_utils import sherpa_romeo_issn_validate
invenio_deposit/fields/issn.py:43:            # validators=[sherpa_romeo_issn_validate]  # FIXME
invenio_deposit/fields/keywords.py:40:            # validators=[sherpa_romeo_journal_validate], #FIXME
invenio_deposit/fields/keywords.py:41:            # autocomplete=sherpa_romeo_journals,
invenio_deposit/processor_utils.py:26:from invenio_utils.sherpa_romeo import SherpaRomeoSearch
invenio_deposit/processor_utils.py:150:def sherpa_romeo_issn_process(form, field, submit=False):
invenio_deposit/processor_utils.py:179:def sherpa_romeo_publisher_process(form, field, submit=False, fields=None):
invenio_deposit/processor_utils.py:247:def sherpa_romeo_journal_process(form, field, submit=False, fields=None):

We'd need to either add the missing bits or else to remove this functionality completely.

(P.S. No other Invenio component depends on invenio_utils.sherpa_romeo.)

examples: fix rm options in app-teardown.sh

Problem:
examples/app-teardown.sh calls rm <dir> -Rf which does not work on MacOS.

rm: ./instance: is a directory
rm: -Rf: No such file or directory
...

Solution:
Just put the options before the file name.

cli: Remove empty functions

Since we don't support cli commands for deposit, we should remove the empty functions from the cli.py file as they look confusing.

errors: exception InvalidOperationError not correctly handled by Flask

Problem

Because of this change now all files exceptions are subclasses of RESTException.

RESTException are managed in a different way from invenio-rest create_api_errorhandler().

Because of InvalidOperationError doesn't have a specific code set on the class, it inherits 500 from FilesException.
It means that is raised the 500 error instead of the 403 set here.

Solutions

Which solution make more sense in this case?

  1. Set a default code 403 for the exception InvalidOperationError
  2. Modify the create_api_errorhandler() to force the status code if 'status' in kwargs? (as done for HTTPException)

ping @lnielsen @jirikuncar

release: can we release a first alpha?

I just saw that there is no alpha released of invenio-deposit. Would it be possible to release one so that we can install B2Share with pip install without using the devel requirements?

I can make the PR if it is ok.

Thanks.

global: fix current_records_rest.default_endpoint_prefixes update

Problem:
In ext.py we have this code:

A       @blueprint.record_once
        def extend_default_endpoint_prefixes(_):
             ...
B            current_records_rest = app.extensions['invenio-records-rest']
             ...

C       app.register_blueprint(blueprint)

c calls A right away. B depends on invenio-records-rest being already loaded.

Temporary Solution:
We cannot load the blueprint out of ext.py as create_blueprint needs the config.
Thus the simplest fix for now is to use @app.before_first_request.

Problem with this solution:
This however means that one cannot use default_endpoint_prefixes before the first request.

deposit-rest: remove `index` decorator

Considering all the changes that have been applied in recent versions of invenio-records-rest regarding indexing after POST/PUT/DELETE requests, the dreaded @index decorator should be removed.

The most common issue with the @index decorator has been the following scenario:

  1. User does a POST/PUT/DELETE request on the REST API
  2. The relevant Deposit.X method is called and finishes successfully. Note that the RecordMetadata.version_id of the deposit has been bumped to N + 1
  3. @index kicks in (because e.g. Deposit.commit was called as well), and directly indexes the modified record (as version N + 1)
  4. db.session.commit() fails, effecitvely rolling back the transaction and setting RecordMetadata.version_id back to N)
  5. ES has already indexed the record with Deposit.X's changes and version N + 1. DB record is still in version N and has the old metadata... ๐Ÿ˜ก

Since this change probably affects a lot of services that might be (unknowingly) relying on this functionality, some joint efforts should be put in order to address the removal and replacement steps.

api: record merging

Add support in deposit record API for merging changes into record. The merging
deals with the following situation:

  1. Deposit (record v1) fetches record (record v1)
  2. Deposit is updated (deposit v2 )
  3. Record is updated (record v2)
  4. Deposit is published (conflict!)

Since the record was updated after the it was loaded into the deposit, the
deposit will be missing the updates from record v2.

Basic algorithm:

  • Patch from diff of deposit v2 against record v1 (i.e. which changes did the user make)
  • Try to apply patch on record v2. If unsuccesful, bail out (i.e. let user resovle conflicts).

Implementation:

views: SSE integration

Add the ability to publish SSE events, which correspond to a particular deposit.

One possible solution is to register an endpoint to each deposit (i.e. /deposits/<depid>/sse), where a GET request would return an established connection with an SSE channel (having the same name as the deposit URL). Therefore, all handling of access rights concerning the SSE subscriptions will be provided by the read_permission_factory on the deposit.

RFC deposit: authors field in article submission form

@invenio-developers commented on Sun Jun 08 2014

Issue by kneczaj
Friday Jun 06, 2014 at 16:03 GMT
Originally opened as jirikuncar/invenio#302


Hello,

I just saw that the design of the author field which I introduced in bootstrap migration commit was reverted. In my opinion the previous version (first screenshot) is not ideal because of two things:

  • move/remove buttons are really small
  • there is much space wasted between the inline fields

My design moves also 'move' button to the left to separate it from 'remove' button as the functionality differs much, and misclicking is not welcome here ;) although this is a minor issue, and for sure will get much discussion so I don't insist on it.

I attach both screenshots to discuss on them. Your opinions and other designs are welcome! :)

Design 1 "small buttons" (original):
authors2

Design 2 "large buttons" (mine):
authors

Design no. 2 is a fast revert and just presents the general idea, it may need tuning the fields sizes and removing some css glitches.


@lnielsen commented on Thu Jun 12 2014

Here's a better screenshot of design 1 (it's a bug that the buttons are on top of each other):

zenodo 2014-06-12 10-50-58

The reason for the revert was it was the early days of PU-branch and the change to Design 2 was not discussed with me as the initial author and the only production user of it (Design 2 broke functionality on Zenodo). Additionally we were on a tight deadline so I didn't get to discussed the revert with you as it ought to have been.

It's a bit more calm so I'm happy to start a discussion on how we can create an ideal author/affiliation field. I see the button placement only as a minor part of this.

The goal of the author/affiliation field is to make it as easy as possible for a submitter to enter high quality metadata. To that end I believe we need:

  • Auto-complete as much as possible (name and affiliation) from appropriate sources.
  • Assisted formatting of name if it's not formatted in the pattern Family name, First name.
  • Obtain author/organization identifiers (such as ORCID) in a easy assisted manner.
  • Support copy/paste of authors from PDF/HTML pages via parsing clipboard content.

I suggest making a survey of other systems to get ideas for how we can best create the author/affiliation field.

Button placement

Re. design 2: I don't like the having the buttons as bootstrap input groups (it makes the visually to impactful for me), and I don't like that there's no whitespace in-between the fields.

Re. design 1: I agree that you are more likely to accidentally hit the close button. In my experience it has however not been an issue. Also, I believe having both buttons together, make it easier for the user to identify the possible features of the author field (ordering/removal).


@greut commented on Thu Jun 12 2014

Things to consider:

  • accessibility: not everyone can perform a drag and drop operation
  • touch screen:
    • a big finger cannot click on a small arrow
    • no :hover state or title to help the user understanding the UI

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.