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

188 discrepancies betwee import and export formats rebased #198

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
6609caf
minor - renaming function
vildead Jul 22, 2020
b49503c
moving general functions to super class (BaseImporter)
vildead Jul 22, 2020
8b9abd4
moving import_json method to BaseImporter
vildead Jul 22, 2020
1460618
update JSON schemas URL
vildead Jul 22, 2020
0a84251
parse contacts affiliations as list
vildead Jul 22, 2020
72ad499
issue error on invalid data type
vildead Jul 22, 2020
5ea2dd5
update records on import/update
vildead Jul 22, 2020
59f2072
adding missing fields to conform to JSON schema
vildead Jul 22, 2020
db1338d
removing id_at_source/pk field to conform to JSON schema
vildead Jul 22, 2020
eb44cb7
project mapped using project name
vildead Jul 22, 2020
a7ce3e3
handle missing fields in import
vildead Jul 23, 2020
502fc16
fix typo
vildead Jul 23, 2020
e328374
adding PartnerImporter class
vildead Jul 23, 2020
b62fc50
adding superclasses ImportBaseCommand and ExportBaseCommand
vildead Jul 23, 2020
a583803
fixing use_restriction export to comply to JSON schema
vildead Jul 23, 2020
b990c34
adding import_partners command
vildead Jul 23, 2020
3afac67
Adding JSONSchema validators
vildead Jul 24, 2020
2df9eda
Adding missing test fixture - datatypes
vildead Jul 24, 2020
17cb909
tests - add email field to conform to JSON schema (required field)
vildead Jul 24, 2020
e19e1f3
Update of demo/test data to conform to JSONSchema
vildead Jul 24, 2020
1347e0d
typos + small fixes
vildead Jul 24, 2020
60e8873
is_local_contact method extraction
vildead Jul 24, 2020
c345542
institution -> affiliations (from JSONSchema)
vildead Jul 24, 2020
f39f73f
fix - process_partner() - expect string
vildead Jul 24, 2020
ed900c7
add acronym to pass field UNIQUE constrain
vildead Jul 24, 2020
42c6c79
skip elx_submission test
vildead Jul 27, 2020
8b6c377
README - update import/export command doc
vildead Jul 27, 2020
f25bd34
chore: restored ID to serialization of partner
jLebioda Jan 5, 2021
7447876
chore: removed unused constant
jLebioda Jan 5, 2021
655bcf4
fix: corrections in JSONSchemaValidator
jLebioda Jan 5, 2021
0fbb73c
fix: corrections in schema validator
jLebioda Jan 6, 2021
af8ebf0
chore: added elu-study schema
jLebioda Jan 7, 2021
47a1263
feat: changes in importer exceptions
jLebioda Jan 7, 2021
2ec8083
fix: updated demo fixtures
jLebioda Jan 7, 2021
9c20ff4
fix: typo in load_demo_data command
jLebioda Jan 8, 2021
9f91773
feat: use restrictions renaming fields
jLebioda Jan 8, 2021
485aa87
fix: corrections in the importer
jLebioda Jan 8, 2021
271b548
fix: improvements of the project/dataset importer
jLebioda Jan 11, 2021
392fa54
feat: include legal bases in the export
jLebioda Jan 11, 2021
676262f
fix: updated test fixture
jLebioda Jan 12, 2021
0a016b7
fix: corrected import of elu accession to be not null
jLebioda Jan 12, 2021
7d0fa4c
fix: more corrections
jLebioda Jan 13, 2021
65a5fda
feat: import legal bases
jLebioda Jan 13, 2021
8c9301d
fix: bugfix
jLebioda Jan 13, 2021
7130ce6
fix: a couple of fixes to the importers
jLebioda Jan 14, 2021
651b63b
fix: small improvement to handle null in consent status
jLebioda Jan 19, 2021
a8203fc
feat: added projects and datasets to the API
jLebioda Jan 20, 2021
5e6b4ad
fix: further changes to the importer/exporter
jLebioda Jan 21, 2021
6ffcbbd
fix: corrections to use restriction
jLebioda Jan 21, 2021
04e3a76
fix: pinpoint flower version in docker-compose
jLebioda Jan 22, 2021
0002890
fix: use docker login in travis CI
jLebioda Jan 22, 2021
09c68ba
chore: changed print to logger in json validation error handling
jLebioda Jan 22, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ before_install:
- cp elixir_daisy/settings_compose_ci.py elixir_daisy/settings_compose.py

install:
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- docker-compose build
- docker-compose up -d
- sleep 60

script:
- docker-compose exec web python setup.py pytest
- docker-compose exec web python setup.py pytest
27 changes: 15 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,19 @@ You are encouraged to try Daisy for yourself using our [DEMO deployment](https:/

#### Importing

In addition to loading of initial data, DAISY database can be populated by importing Project and Dataset records from JSON files.
The commands for import are given below: </br>
In addition to loading of initial data, DAISY database can be populated by importing Project, Dataset and Partners records from JSON files using commands `import_projects`, `import_datasets` and `import_partners` respectively.
The commands for import are accepting one JSON file (flag `-f`): </br>

```bash
docker-compose exec web python manage.py import_projects -f ${PROJECTS_JSON}
docker-compose exec web python manage.py <COMMAND> -f ${PATH_TO_JSON_FILE}
```
where ${PROJECTS_JSON} is the path to a json file containing the projects definitions.
See file daisy/data/projects.json as an example.
where ${PATH_TO_JSON_FILE} is the path to a json file containing the records definitions.
See file daisy/data/demo/projects.json as an example.


Alternatively, you can specify directory containing multiple JSON files to be imported with `-d` flag:
```bash
docker-compose exec web python manage.py import_datasets -d ${DATASETS_FOLDER}
docker-compose exec web python manage.py <COMMAND> -d ${PATH_TO_DIR}
```
where ${DATASETS_FOLDER} is the path to a folder containing datasets and data declarations definitions.
See folder daisy/data/datasets as an example.

#### Exporting

Expand Down Expand Up @@ -206,16 +204,21 @@ To be completed.
./manage.py import_users
```

### Import projects from external system
### Import projects, datasets or partners from external system
Single file mode:
```bash
./manage.py import_projects -f path/to/json_file.json
```

### Import datasets from external system
Batch mode:
```bash
./manage.py import_datasets -d path/to/folder_with_json
./manage.py import_projects -f path/to/dir/with/json/files/
```

Available commands: `import_projects`, `import_datasets`, `import_partners`.

In case of problems, add `--verbose` flag to the command, and take a look inside `./log/daisy.log`.

### Install js and css dependencies

```bash
Expand Down
8 changes: 8 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ def storage_resources():
CommandLoadInitialData.create_storage_resources()


@pytest.fixture
def data_types():
"""
Create data types
"""
CommandLoadInitialData.create_datatypes()


@pytest.fixture
def partners():
"""
Expand Down
12 changes: 11 additions & 1 deletion core/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class DaisyError(Exception):
"""Base error class for the module."""

default_message = "Unspecified daisy error"
default_message = "Unspecified DAISY error"

def __init__(self, msg=None):
self._msg = msg or self.default_message
Expand Down Expand Up @@ -37,3 +37,13 @@ class FixtureImportError(DaisyError):
def __init__(self, data, msg=None):
self.data = data
super().__init__(msg=msg)


class JSONSchemaValidationError(DaisyError):
"""Error when validating data to be imported."""

default_message = "Error when validating data against JSON schema:' {data}'"

def __init__(self, data, msg=None):
self.data = data
super().__init__(msg=msg)
285 changes: 285 additions & 0 deletions core/fixtures/elu-dataset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,285 @@
{
"description": "ELIXIR Luxembourg Projects Schema",
"title": "A JSON Schema for describing biomedical research Projects.",
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"allOf": [
{
"$ref": "https://git-r3lab.uni.lu/pinar.alper/metadata-tools/raw/master/metadata_tools/resources/elu-core.json"
}
],
"properties": {
"project": {
"description": "Name of the project the dataset belongs to.",
"type": ["string", "null"]
},
"data_declarations": {
"type": "array",
"items": {
"$ref": "#/definitions/elu:data"
}
},
"storages": {
"type": "array",
"items": {
"$ref": "#/definitions/elu:storage"
}
},
"legal_bases": {
"type": "array",
"items": {
"$ref": "#/definitions/elu:legal_basis"
}
},
"transfers": {
"type": "array",
"items": {
"$ref": "#/definitions/elu:transfer"
}
}
},
"definitions": {
"elu:storage": {
"type": "object",
"properties": {
"platform": {"type": "string"},
"location": {"type": "string"},
"accesses": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"elu:transfer": {
"type": "object",
"properties": {
"partner": {"type": "string"},
"transfer_details": {"type": ["string", "null"]},
"transfer_date": {
"type": ["string", "null"],
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
}
}
},
"elu:legal_basis": {
"type": "object",
"properties": {
"data_declarations": {
"type": "array",
"items": {
"type": "string"
}
},
"legal_basis_codes": {
"type": "array",
"items": {
"type": "string",
"enum": [
"6.1(a)",
"6.1(b)",
"6.1(c)",
"6.1(d)",
"6.1(e)",
"6.1(f)"
]
}},
"personal_data_codes": {
"type": "array",
"items": {
"type": "string",
"enum": [
"Standard",
"Special",
"Race",
"Genetic",
"Biometric",
"Health",
"Sexual orientation",
"Convictions",
"Other"
]
}
},
"legal_basis_notes": {
"type": "string"
}
},
"required": [
"legal_basis_codes",
"personal_data_codes"
]
},
"elu:data": {
"type": "object",
"properties": {
"title": {
"type": "string"
},
"use_restrictions": {
"type": "array",
"items": {
"type": "object",
"properties": {
"use_class": {
"type": "string",
"enum": [
"NRES",
"GRU(CC)",
"HMB(CC)",
"DS-[XX](CC)",
"POA",
"RS-[XX]",
"RUO",
"NMDS",
"GSO",
"NPU",
"PUB",
"COL-[XX]",
"RTN",
"IRB",
"GS-[XX]",
"MOR-[XX]",
"TS-[XX]",
"US",
"PS",
"IS",
"Other"
]
},
"use_class_note": {
"type": "string"
},
"use_restriction_rule": {
"type": "string",
"enum": [
"CONSTRAINTS",
"NO_CONSTRAINTS",
"FORBIDDEN"
]
},
"use_restriction_objects": {
"type": "array",
"items": {
"type": "string"
},
"use_restriction_note": {
"type": "string"
}
}
},
"required": [
"use_class_note",
"use_restriction_rule"
]
}
},
"data_types": {
"type": "array",
"items": {
"type": "string",
"enum": [
"ATAC-seq",
"Biometric_data",
"ChIP-seq",
"Samples",
"Disease status",
"Ethnic_origin",
"Imaging",
"Omics_data",
"Genotype_data",
"Whole_genome_sequencing",
"Exome_sequencing",
"Genomics_variant_array",
"RNASeq",
"Genetic_and_derived_genetic_data",
"Transcriptome_array",
"Methylation_array",
"MicroRNA_array",
"Metabolomics",
"Metagenomics",
"Metatranscriptomics",
"Metaproteomics",
"Single_Cell_RNAseq",
"Proteomics",
"Other_omics_data",
"Clinical_Imaging",
"Cell_Imaging",
"Human_subject_data",
"Clinical_data",
"Lifestyle_data",
"Socio_Economic_Data",
"Environmental_Data",
"Other_Phenotype_data",
"Other"
]
},
"data_type_notes": {
"type": "string"
},
"access_category": {
"type": "string",
"enum": [
"open-access",
"controlled-access",
"registered-access"
]
},
"subjects_category": {
"type": "array",
"items": {
"type": "string",
"enum": [
"cases",
"controls",
"cases_and_controls"
]
}
},
"de_identification": {
"type": "string",
"enum": [
"anonymized",
"pseudonymized"
]
},
"consent_status": {
"type": "string",
"enum": [
"heterogeneous",
"homogeneous"
]
},
"consent_status_description": {
"type": "string"
},
"has_special_subjects": {
"type": "boolean"
},
"special_subjects_description": {
"type": "string"
},
"embargo_date": {
"type": "string",
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
},
"storage_end_date": {
"type": "string",
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
},
"storage_duration_criteria": {
"type": "string",
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
}
}
}
}
}
}






Loading