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

initial commit of code to add current grants to projects #1061

Merged
merged 4 commits into from
Mar 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
30 changes: 19 additions & 11 deletions regolith/builders/activitylogbuilder.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Builder for CVs."""
import datetime as dt
import uuid

from dateutil import parser as date_parser
from dateutil.relativedelta import relativedelta
from copy import deepcopy, copy
Expand Down Expand Up @@ -144,17 +146,6 @@
and get_dates(manrev, date_field_prefix="submitted"
).get("submitted_date", dt.date(1971,1,1)
) >= begin_period])
#########
# highlights
#########
for proj in projs:
if proj.get('highlights'):
proj["current_highlights"] = False
for highlight in proj.get('highlights'):
highlight_date = get_dates(highlight)
if highlight_date.get("end_date") >= begin_period:
highlight["is_current"] = True
proj["current_highlights"] = True

#########
# current and pending
Expand Down Expand Up @@ -253,6 +244,23 @@
# end current and pending
#########

#########
# highlights
#########
for grant in current_grants:
holdid = grant.get("_id")
grant["_id"] = uuid.uuid4()
projs.append(grant)
grant["_id"] = holdid #not sure if this will update on dump so just be careful

Check warning on line 254 in regolith/builders/activitylogbuilder.py

View check run for this annotation

Codecov / codecov/patch

regolith/builders/activitylogbuilder.py#L251-L254

Added lines #L251 - L254 were not covered by tests
for proj in projs:
if proj.get('highlights'):
proj["current_highlights"] = False
for highlight in proj.get('highlights'):
highlight_date = get_dates(highlight)
if highlight_date.get("end_date") >= begin_period:
highlight["is_current"] = True
proj["current_highlights"] = True

Check warning on line 262 in regolith/builders/activitylogbuilder.py

View check run for this annotation

Codecov / codecov/patch

regolith/builders/activitylogbuilder.py#L256-L262

Added lines #L256 - L262 were not covered by tests

#########
# advising
#########
Expand Down
4 changes: 2 additions & 2 deletions regolith/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ def validate(rc):
else:
# uncomment when debugging scheme errors
#
# sys.exit(f"Validation failed on some records\n {cap}")
sys.exit(f"Validation failed on some records")
sys.exit(f"Validation failed on some records\n {cap}")
# sys.exit(f"Validation failed on some records")

DISCONNECTED_COMMANDS = {
"rc": lambda rc: print(rc._pformat()),
Expand Down
16 changes: 16 additions & 0 deletions regolith/schemas.json
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,22 @@
"required": false,
"type": "string"
},
"highlights": {
"description": "lists of highlights from the project",
"required": false,
"type": "list",
"schema": {
"schema": {
"year": {"required": false, "type": "integer"},
"month": {"required": false, "type": "integer"},
"description": {
"required": false,
"type": "string"
}
},
"type": "dict"
}
},
"institution": {
"description": "the host institution for the grant",
"type": "string",
Expand Down
3 changes: 3 additions & 0 deletions regolith/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,9 @@ def load_exemplars():
},
],
"status": "accepted",
"highlights": [
{"year": 2020, "month": 5, "description": "high profile pub in Nature"}
],
"title": "SymPy 2.0 Release Support",
"budget": [
{
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def main():
"static/*.*",
"static/img/*.*",
"*.xsh",
"*.json"
]
},
scripts=["scripts/regolith"],
Expand Down
3 changes: 1 addition & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from regolith.fsclient import dump_yaml
from regolith.schemas import EXEMPLARS

OUTPUT_FAKE_DB = True # always turn it to false after you used it
OUTPUT_FAKE_DB = False # always turn it to false after you used it
# Currently the first two must be named test solely to match the helper map test output text
REGOLITH_MONGODB_NAME = "test"
FS_DB_NAME = 'test'
Expand Down Expand Up @@ -500,4 +500,3 @@ def exemplars_to_mongo(mongo_db_name, collection_list=None):
print('Duplicate key error, check exemplars for duplicates if tests fail')
except mongo_errors.BulkWriteError:
print('Duplicate key error, check exemplars for duplicates if tests fail')

Loading