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: Regolith Grant Report Builder #523

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
89 changes: 50 additions & 39 deletions regolith/builders/grantreportbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@
from datetime import datetime
import time
from nameparser import HumanName
import dateutil.parser as date_parser

from regolith.builders.basebuilder import LatexBuilderBase
from regolith.dates import month_to_int
from regolith.dates import (month_to_int,
get_dates,
get_due_date,
is_current,
is_after,
is_before)
from regolith.fsclient import _id_key
from regolith.sorters import position_key
from regolith.tools import (
Expand All @@ -25,7 +31,7 @@ def subparser(subpi):
class GrantReportBuilder(LatexBuilderBase):
"""Build a proposal review from database entries"""
btype = "grantreport"
needed_dbs = ['presentations', 'projecta', 'people', 'grants', 'institutions']
needed_dbs = ['presentations', 'projecta', 'people', 'grants', 'institutions', 'expenses']

def construct_global_ctx(self):
"""Constructs the global context"""
Expand All @@ -44,54 +50,59 @@ def construct_global_ctx(self):
def latex(self):
"""Render latex template"""
rc = self.rc
# Get Dates
start_date = datetime.strptime(rc.start_date, "%Y-%m-%d")
end_date = datetime.strptime(rc.end_date, "%Y-%m-%d")

# Convert Date Strings to Datetime Objects
rp_start_date = date_parser.parse(rc.start_date)
rp_end_date = date_parser.parse(rc.end_date)

# NSF Grant _id
grant_name = "dmref"
# Get people and prum linked to grant and active during reporting period
prums = [prum for prum in self.gtx['projecta']
if grant_name in prum['grants']
and
((start_date <= datetime.strptime(prum['end_date'], "%Y-%m-%d") <= end_date
and prum['status'] is 'finished')
or
start_date <= datetime.strptime(prum['begin_date'], "%Y-%m-%d") <= end_date)]
people = list(set([prum['lead'] for prum in prums]))

# Accomplishments

# Get All Active Members
current_members = [person for person in self.gtx['people'] if person['active']]

# Major Goals
# Get prum associated to grant and active during reporting period
grant_prums = []
for prum in self.gtx['projecta']:
if grant_name in prum['grants']:
begin_date = get_dates(prum).get('begin_date')
due_date = get_due_date(prum['deliverable'])
# if projectum was finished during reporting period or is still current
# some projectum don't have an "end date", but all projecta have a deliverable
# due_date
if (rp_start_date <= due_date <= rp_end_date and prum['status'] is "finished") or is_current(prum):
grant_prums.append(prum)
# Get people associated with grant
grant_people = list(set([prum['lead'] for prum in grant_prums]))

# Accomplishments

# Opportunities for Training and Professional Development and
# Individuals that have worked on project
valid_presentations = []
individuals_data = []
for person in current_members:
valid_presentations.append(filter_presentations(
self.gtx["people"], self.gtx["presentations"], self.gtx["institutions"], person["_id"],
["tutorial", "contributed_oral"], begin_date, end_date))
individuals_data.append([person["_id"], person["position"]])

major_activities = []
significant_results = []
for prum in grant_prums:
if prum['status'] is "finished":
significant_results.append(prum)
else:
major_activities.append(prum)

# Opportunities for Training and Professional Development
training_and_professional_development = []
# presentations
for id in grant_people:
training_and_professional_development.extend(
filter_presentations(self.gtx["people"], self.gtx["presentations"], self.gtx["institutions"], id,
types=["all"], since=rp_start_date, before=rp_end_date, statuses=["accepted"]))
# thesis defendings
# how do i access people.yml in rg-db-public vs the people.yml file in rg-db-group?
for id in grant_people:
person = self.gtx['people'][id]
if person['']
# How have results been disseminated

# Plans for Next Reporting Period to Accomplish Goals

self.render(
"grantreport.txt",
"billinge_grant_report.txt",
endYear=end_year,
endMonth=end_month,
endDay=end_date,
beginYear=begin_year,
beginMonth=begin_month,
beginDay=begin_day,
presentations=valid_presentations,
individuals=individuals_data,
beginYear=rp_start_date.year,
endYear=rp_end_date.year,
majorActivities=major_activities,
significantResults=significant_results,
trainingAndProfessionalDevelopment=training_and_professional_development,
)
37 changes: 29 additions & 8 deletions regolith/templates/grantreport.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
NSF {{beginYear}}-{{endYear}} Annual Report by {{authorFullName}}, ({{ institution }})
NSF {{beginYear}}-{{endYear}} Annual Report by Simon J. L. Billinge, (Columbia University)
Copy link
Contributor

Choose a reason for hiding this comment

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

I shouldn't be hard-coded in here.


Accomplishments
------------------------------
------------------------------------------------------------------------------
* What are the major goals of the project?

In real-world applications, materials are rarely perfect crystals and their properties
depend sensitively on defects, nanoscale structures, interfaces, surfaces and multi-scale
heterogeneities. A major challenge is to gain a greater understanding of how such
Expand All @@ -28,17 +27,39 @@ Goal 4: Apply this to real scientific problems

* What was accomplished under these goals (you must provide information for
at least one of the 4 categories below)?
Major Activities:
Specific Objectives:
Significant Results:
------------------------------------------------------------------------------
- Major Activities (currently worked on projecta):
Copy link
Contributor

Choose a reason for hiding this comment

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

again, can't have me hard-coded in here.

If there is something that is "me" specific that doesn't change often it should probably be in people. However, since this is a grant-specific thing it might better be in grants? If it is mostly me-specific but will be described in the grant report of multiple grants, this should probably be in people but have a field that is grant. This is how we discover how the world is organized!

PDF in the cloud (PDFitc): Development of a web-based service for determining
structures from measured PDFs given known structures in structural databases
xpdTools, xpdAcq, xpdAn, xpdView: Software tools for streaming data analysis
and visualization of diffraction data from the XPD diffractometer at NSLS-II
synchrotron. The tools can also be used to analyze data from other diffraction
beamlines.
{%- for prum in majorActivities %}
{{ prum['name'] }}: {{ prum['description'] }}
{% endfor -%}

- Specific Objectives:
PDF in the cloud (PDFitc): Development of a web-based service for determining
structures from measured PDFs given known structures in structural databases

- Significant Results (finished projecta):
{%- for prum in significantResults %}
{{ prum['name'] }}: {{ prum['description'] }}
{% endfor -%}

Key outcomes or Other achievements:
* What opportunities for training and professional development has the project provided?
{%- for opportunity in presentations %}
- {{opportunity -}}
{%- for opportunity in trainingAndProfessionalDevelopment %}
- Authors: {{ opportunity['authors'] }}
- Title: {{ opportunity['title'] }}
- Location: {{ opportunity['meeting_name'] }}
{% endfor -%}}

* How have the results been disseminated to communities of interest?
1. Publications
Copy link
Contributor

Choose a reason for hiding this comment

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

This is an interesting one. It should probably be in people too so any user of Regolith can decide for themselves.

2. Software releases and deployment of software packages on conda-forge and pypi for ease of installation
3. Presentations at conferences and seminars

* What do you plan to do during the next reporting period to accomplish the goals?

Expand Down
23 changes: 18 additions & 5 deletions tests/outputs/grantreport/billinge_grant_report.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
NSF 2019-2020 Annual Report by Simon J. L. Billinge, (Columbia University)

Accomplishments
------------------------------
------------------------------------------------------------------------------
* What are the major goals of the project?

In real-world applications, materials are rarely perfect crystals and their properties
depend sensitively on defects, nanoscale structures, interfaces, surfaces and multi-scale
heterogeneities. A major challenge is to gain a greater understanding of how such
Expand All @@ -28,14 +27,28 @@ Goal 4: Apply this to real scientific problems

* What was accomplished under these goals (you must provide information for
at least one of the 4 categories below)?
Major Activities:
Specific Objectives:
Significant Results:
------------------------------------------------------------------------------
- Major Activities (currently worked on projecta):
PDF in the cloud (PDFitc): Development of a web-based service for determining
structures from measured PDFs given known structures in structural databases
xpdTools, xpdAcq, xpdAn, xpdView: Software tools for streaming data analysis
and visualization of diffraction data from the XPD diffractometer at NSLS-II
synchrotron. The tools can also be used to analyze data from other diffraction
beamlines.

- Specific Objectives:
PDF in the cloud (PDFitc): Development of a web-based service for determining
structures from measured PDFs given known structures in structural databases

- Significant Results (finished projecta):

Key outcomes or Other achievements:
* What opportunities for training and professional development has the project provided?

* How have the results been disseminated to communities of interest?
1. Publications
2. Software releases and deployment of software packages on conda-forge and pypi for ease of installation
3. Presentations at conferences and seminars

* What do you plan to do during the next reporting period to accomplish the goals?

Expand Down