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

WIP: schemas #66

Merged
merged 29 commits into from
Jan 3, 2018
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3bdb6aa
WIP: schemas
CJ-Wright Dec 12, 2017
4c6ce36
TST: add test for validator
CJ-Wright Dec 13, 2017
4c2e92d
ENH: working schemas with examples
CJ-Wright Dec 13, 2017
5c2dd0f
DOC: add docs
CJ-Wright Dec 13, 2017
c684b86
CI: create not install
CJ-Wright Dec 13, 2017
4a498b3
MTN: fix run and move the schemas out of folder
CJ-Wright Dec 13, 2017
e2ae650
ENH: validator
CJ-Wright Dec 14, 2017
f8f7930
WIP: finalize schema
CJ-Wright Dec 14, 2017
2969e52
STY: pep8
CJ-Wright Dec 17, 2017
e0f26bd
STY: pep8 import
CJ-Wright Dec 17, 2017
5881956
MTN: move schema things to schemas
CJ-Wright Dec 17, 2017
986d5fa
STY: newline
CJ-Wright Dec 17, 2017
4dc419c
FIX: don't allow unknown
CJ-Wright Dec 17, 2017
f7bcfb1
FIX: custom validator for description
CJ-Wright Dec 17, 2017
6068349
WIP: write docs from schema/exemplars
CJ-Wright Dec 18, 2017
263441b
WIP: auto schema doc
CJ-Wright Dec 18, 2017
d0a0ac7
FIX: proper internal dict format
CJ-Wright Dec 18, 2017
c026c1b
DOC: remove auto docs, add to their own auto folder, add auto folder …
CJ-Wright Dec 18, 2017
55d3619
FIX: comments from @scopatz
CJ-Wright Dec 18, 2017
1394df2
ENH: move top docs to schemas module
CJ-Wright Dec 18, 2017
61ffe55
STY: pep8 line width
CJ-Wright Dec 18, 2017
9c3c8d6
STY: pep8 newline
CJ-Wright Dec 18, 2017
79b75a9
ENH: alph. yamls and added top docs to schema
CJ-Wright Dec 18, 2017
6222199
STY: pep8 line width
CJ-Wright Dec 18, 2017
4420cb5
FIX: comments from @scopatz
CJ-Wright Jan 2, 2018
b7d3565
FIX: fix app, move tests
CJ-Wright Jan 2, 2018
1491d88
FIX: move error to raise
CJ-Wright Jan 2, 2018
a990ed9
news
CJ-Wright Jan 2, 2018
5df3883
elaborate on news
CJ-Wright Jan 3, 2018
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
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ install:
- conda update conda

# Install dependencies
- conda install python
- conda create -n test --file requirements/run.txt
- source activate test
- python setup.py install

script:
- set -e
- conda install --file requirements/test.txt
- pytest -vvs .
- # Command to build your docs
- pip install doctr
- conda install --file requirements/doc.txt
Expand Down
2 changes: 1 addition & 1 deletion docs/collections/abstracts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The following lists key names mapped to its type and meaning for each entry.
:institution: str, name of the inistitution
:references: str, HTML string of reference for the abstract itself, optional
:text: str, HTML string of the abstract.
:timestamp: The time when the abstract was submitted.
:timestamp: float, The time when the abstract was submitted.


YAML Example
Expand Down
4 changes: 2 additions & 2 deletions docs/collections/grants.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The following lists key names mapped to its type and meaning for each entry.
:begin_day: int, start day of the grant, optional
:end_year: int, end year of the grant
:end_month": str, end month of the grant
:end_day: str, end day of teh grant, optional
:end_day: str, end day of the grant, optional
:team: list of dicts, information about the team members participating in the grant.
These dicts have the following form:

Expand All @@ -30,7 +30,7 @@ The following lists key names mapped to its type and meaning for each entry.
[{"name": str, # should match a person's name or AKA
"position": str, # PI, Co-PI, Co-I, Researcher, etc.
"institution": str, # The institution of this investigator
"subaward_amount", int or float, # optional
"subaward_amount": int or float, # optional
"cv": str, # optional, URL of document
},
...
Expand Down
12 changes: 6 additions & 6 deletions docs/collections/people.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ The following lists key names mapped to its type and meaning for each entry.
]

:funding: list of dicts, Funding and scholarship that the group member has
individually obtained in the past (optional). **WARNING:** this is not to be confused
individually obtained in the past, optional. **WARNING:** this is not to be confused
with the **grants** collection, that may refee back to group members.
These dicts have the following form:

Expand All @@ -70,7 +70,7 @@ The following lists key names mapped to its type and meaning for each entry.
...
]

:service: list of dicts, Service that this group member has provided (optional).
:service: list of dicts, Service that this group member has provided, optional.
These dicts have the following form:

.. code-block:: python
Expand All @@ -84,7 +84,7 @@ The following lists key names mapped to its type and meaning for each entry.
...
]

:honors: list of dicts, Honors that have been awarded to this group member (optional).
:honors: list of dicts, Honors that have been awarded to this group member, optional.
These dicts have the following form:

.. code-block:: python
Expand All @@ -97,7 +97,7 @@ The following lists key names mapped to its type and meaning for each entry.
...
]

:teaching: list of dicts, Courses that this group member has taught, if any (optional).
:teaching: list of dicts, Courses that this group member has taught, if any, optional.
These dicts have the following form:

.. code-block:: python
Expand All @@ -118,7 +118,7 @@ The following lists key names mapped to its type and meaning for each entry.
...
]

:membership: list of dicts, Profesional organizations this member is a part of (optional).
:membership: list of dicts, Profesional organizations this member is a part of, optional.
These dicts have the following form:

.. code-block:: python
Expand All @@ -135,7 +135,7 @@ The following lists key names mapped to its type and meaning for each entry.
...
]

:skills: list of dicts, Skill the group member has (optional)
:skills: list of dicts, Skill the group member has, optional
These dicts have the following form:

.. code-block:: python
Expand Down
23 changes: 23 additions & 0 deletions regolith/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

from flask import Flask, abort, request, render_template, redirect, url_for

from regolith.validators import validate

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PEP8 two newlines required after import lines

app = Flask('regolith')


Expand Down Expand Up @@ -59,6 +61,17 @@ def collection_page(dbname, collname):
f.write(form['body'])
traceback.print_exc()
raise
tv, errors = validate(dbname, body)
if not tv:
td = tempfile.TemporaryDirectory()
n = os.path.join(td.name, 'regolith.txt')
print(errors)
print('Writing text file to {}. '
'Please try again.'.format(n))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these prints should go into the body of the error message below. At the very least, they should be printed to stderr....

with open(n) as f:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file isn't opened in write mode. Do you have any tests for the invalid case?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we have any tests for the app.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made an issue #69

f.write(form['body'])
raise ValueError('Error while validating the record')

rc.client.update_one(dbname, collname, {'_id': body['_id']}, body)
status = 'saved ✓'
status_id = str(body['_id'])
Expand All @@ -75,6 +88,16 @@ def collection_page(dbname, collname):
f.write(form['body'])
traceback.print_exc()
raise
tv, errors = validate(dbname, body)
if not tv:
td = tempfile.TemporaryDirectory()
n = os.path.join(td.name, 'regolith.txt')
print(errors)
print('Writing text file to {}. '
'Please try again.'.format(n))
with open(n) as f:
f.write(form['body'])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

raise ValueError('Error while validating the record')
try:
added = rc.client.insert_one(dbname, collname, body)
except Exception:
Expand Down
Loading