Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies and README #3

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ jsonschema = "*"
[dev-packages]

[requires]
python_version = "3.8"
python_version = "3.9"
143 changes: 136 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,48 @@
Invenio module for custom Ultraviolet commands

## Prerequisites

- [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
- [Pyenv](https://github.com/pyenv/pyenv#installation)
- [OpenSSL >= 1.1](https://www.openssl.org/source/)


## Install and run locally

- Please make sure OpenSSL >= 1.1.0 on your machine. Install/Update of OpenSSL varies from one machine to another.
- Clone the repository
``` sh
```sh
git clone [email protected]:nyudlts/ultraviolet-cli.git && cd ultraviolet-cli
```
- Install & use specified python version
``` sh
```sh
pyenv install --skip-existing
```
- Install python requirements in a project pip environment (pipenv)
``` sh
- Install python requirements in a project pip environment (pipenv) based on setup.py
```sh
pip install --upgrade -U pip pipenv
pipenv install
pipenv run pip install -e .
pipenv lock
```
- Set up db uri
```sh
export SQLALCHEMY_DATABASE_URI="postgresql+psycopg2://ultraviolet:ultraviolet@localhost/ultraviolet”
```
- Invoke the `ultraviolet-cli` root command via `pipenv`
``` sh
```sh
pipenv run ultraviolet-cli
```

## Testing

- Set up testing db
```sh
export SQLALCHEMY_DATABASE_URI=postgresql+psycopg2://invenio-app-rdm:invenio-app-rdm@localhost/invenio-app-rdm
```
- Run tests
```sh
bash run-tests.sh
```

## Create Communities

### Usage
Expand Down Expand Up @@ -63,11 +79,13 @@ Options:
```sh
pipenv run ultraviolet-cli create-communities -d "Community for NYU students" -g "nyustudents" -o "[email protected]" "NYU Students Community"
```

The code assumes owner and the group are valid within Invenio, otherwise, they have to be created for the code to complete successfully.

## Delete Records

### Usage

```sh
Usage: ultraviolet-cli delete-record [OPTIONS] PID

Expand All @@ -83,9 +101,12 @@ Options:
pipenv run ultraviolet-cli delete-record pid1-sample
```

The code delete a published record, not a draft one.

## Upload Files

### Usage

```sh
Usage: ultraviolet-cli upload-files [OPTIONS] PID

Expand All @@ -106,3 +127,111 @@ pipenv run ultraviolet-cli upload-files -f file_path pid1-sample
```sh
pipenv run ultraviolet-cli upload-files -d dir_path pid1-sample
```

## Update Vocabularies

### Usage

```sh
Usage: ultraviolet-cli update_vocabularies vocabulary_key vocabulary_data

Adds a new entry to the Ultraviolet vocabulary.

Arguments:
VOCABULARY_TYPE Type of vocabulary to update. Valid options including:
languages (lng), licenses (lic), resourcetypes (rsrct),
creatorsroles (crr), affiliations (aff), subjects (sub) [required]
VOCABULARY_TYPE JSON string containing the vocabulary entry data [required]

Options:
--help Show this message and exit.
```

### Example

```sh
ultraviolet-cli update-vocabularies languages '{"id": "testid", "tags": ["individual", "living"], "props": {"alpha_2": "22"}, "title": {"en": "testlanguagetitle"}, "type": "languages"}'

ultraviolet-cli update-vocabularies lng '{"id": "testid", "tags": ["individual", "living"], "props": {"alpha_2": "22"}, "title": {"en": "testlanguagetitle"}, "type": "languages"}'

```

The code add a new language record to vocabulary.

```sh
ultraviolet-cli update-vocabularies sub '{"id": "http://www.test.com", "scheme": "FOS", "subject": "test subject", "type": "subjects"}'

```

The code add a new subject record to vocabulary.

```sh
ultraviolet-cli update-vocabularies rsrct '{"id": "testid", "tags": ["testtag1", "testtag2"], "props": {"csl": "testcsl", "datacite_general": "testdatacite_general", "datacite_type": "testdatacite_type", "openaire_resourceType": "testopenaire_resourceType", "openaire_type": "testopenaire_type", "schema.org": "https://schema.org/testschema", "subtype": "testsubtype", "subtype_name": "testsubtype_name", "type": "testtype", "type_icon": "testtype_icon", "type_name": "testtype_name"}, "title": {"en": "testtitle"}, "type": "resourcetypes"}'

```

The code add a new resource type record to vocabulary.

```sh
ultraviolet-cli update-vocabularies creatorsroles '{"id": "testid", "type": "creatorsroles", "props": {"datacite": "testdatacite"}, "title": {"en": "testtitle"}}'

```

The code add a new creator role record to vocabulary.

```sh
ultravoilet-cli update-vocabularies licenses '{"id": "TEST-ID", "icon": "https://example.com/icon.png", "tags": ["TAG1", "TAG2"], "props": {"url": "https://example.com/license", "scheme": "spdx", "osi_approved": "y"}, "title": {"en": "Example License"}, "type": "licenses"}'
```

The code add a new license record to vocabulary.

```sh
ultraviolet-cli update-vocabularies affiliations '{"acronym": "TST", "id": "TESTID123", "identifiers": [{"identifier": "019wvm591","scheme": "ror"}],"name": "Test University", "title": {"en": "Test University", "fr": "Université de Test"}}'
```

The code add a new affiliation record to vocabulary.

Required Fields for vocabularies:

- Languages (lng):
Required: id, title, props, tags, type

- Licenses (lic):
Required: id, tags, props, title, type

- Resource Types (rsrct):
Required: id, title, props, tags, type

- Creators Roles (crr):
Required: id, title, props, type

- Subjects (sub):
Required: id, scheme, subject

- Affiliations (aff):
Required: id, identifiers, name, title

## Create Draft Records

### Usage

```sh
Usage: ultraviolet-cli create-draft-records [OPTIONS]

Create a draft record.

Options:
-o, --owner TEXT Email address of the designated owner of the
community. [default: [email protected]]
-d, --data Record metadata.
--help Show this message and exit.
```

### Example

```sh
pipenv run ultraviolet-cli create-draft-records -o [email protected] -d '{"access": {"record": "public","files": "public"},"files": {"enabled": true},"metadata": {"title": "A Romans story","publication_date": "2020-06-01","publisher": "Acme Inc","resource_type": {"id": "image-photo"},"creators":[{"person_or_org":{"name":"Troy Inc.","type":"organizational"}}]}}'

```

The code create a draft record and return the PID in cmd.
41 changes: 22 additions & 19 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,32 @@
]

install_requires = [
'babel>=2.16.0',
'click>=8.1.3',
'Flask>=2.2.2',
'Flask-BabelEx>=0.9.4',
'invenio-i18n>=1.2.0',
'invenio-files-rest>=1.4.0',
'invenio-access>=1.4.4',
'invenio-accounts>=2.0.0',
'invenio-app>=1.3.4',
'invenio-pidstore>=1.2.3',
'invenio-rdm-records>=1.0.0',
'invenio-search>=2.1.0',
'opensearch-dsl>=2.0.0',
'opensearch-py>=2.0.0',
'jsonschema>=4.17.3',
'requests>=2.28.2',
'Sphinx>=3,<4',
'Flask-Babel>=4.0.0',
'invenio-app>=1.5.0',
'invenio-base==1.4.0',
'invenio-i18n>=2.1.2',
'invenio-files-rest>=2.2.1',
'invenio-access>=2.0.0',
'invenio-accounts>=5.1.2',
'invenio-pidstore>=1.3.1',
'invenio-rdm-records>=10.8.6',
'invenio-search>=2.4.1',
'opensearch-dsl>=2.1.0',
'opensearch-py>=2.7.1',
'jsonschema>=4.23.0',
'Sphinx>=7.3.7',
'Werkzeug==2.2.2',
'python-dotenv',
'invenio-app-rdm',
'check-manifest',
'pytest',
'invenio-cli'
]


packages = find_packages()


Expand Down Expand Up @@ -95,11 +102,7 @@
'Programming Language :: Python',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Software Development :: Libraries :: Python Modules',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Development Status :: 1 - Planning',
],
)
)
Loading