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
2 changes: 2 additions & 0 deletions regolith/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from regolith.builders.coabuilder import RecentCollaboratorsBuilder
from regolith.builders.beamplanbuilder import BeamPlanBuilder
from regolith.builders.activitylogbuilder import ActivitylogBuilder
from regolith.builders.grantreportbuilder import GrantReportBuilder


BUILDERS = {
Expand All @@ -34,6 +35,7 @@
"resume": ResumeBuilder,
"review-man": ManRevBuilder,
"review-prop": PropRevBuilder,
"grantreport": GrantReportBuilder
}


Expand Down
97 changes: 97 additions & 0 deletions regolith/builders/grantreportbuilder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
"""Builder for Proposal Reviews."""
from datetime import datetime
import time
from nameparser import HumanName

from regolith.builders.basebuilder import LatexBuilderBase
from regolith.dates import month_to_int
from regolith.fsclient import _id_key
from regolith.sorters import position_key
from regolith.tools import (
all_docs_from_collection,
filter_grants,
filter_presentations,
fuzzy_retrieval
)


def subparser(subpi):
subpi.add_argument("start_date", help="start date of the reporting period, formatted as YYYY-MM-DD",
default=None)
subpi.add_argument("end_date", help="end date of the reporting period, formatted as YYYY-MM-DD")
return subpi


class GrantReportBuilder(LatexBuilderBase):
"""Build a proposal review from database entries"""
btype = "grantreport"
needed_dbs = ['presentations', 'projecta', 'people', 'grants', 'institutions']

def construct_global_ctx(self):
"""Constructs the global context"""
super().construct_global_ctx()
gtx = self.gtx
rc = self.rc
for dbs in rc.needed_dbs:
Copy link
Contributor

Choose a reason for hiding this comment

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

so pretty! 👍

gtx[dbs] = sorted(
all_docs_from_collection(rc.client, dbs), key=_id_key
)
gtx["all_docs_from_collection"] = all_docs_from_collection
gtx["float"] = float
gtx["str"] = str
gtx["zip"] = zip

def latex(self):
"""Render latex template"""
rc = self.rc
# Get Dates
start_date = datetime.strptime(rc.start_date, "%Y-%m-%d")
Copy link
Contributor

Choose a reason for hiding this comment

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

we usually use a date parser from dateutils. pls could you look in one of the other helpers for the syntax?

end_date = datetime.strptime(rc.end_date, "%Y-%m-%d")

# 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
Copy link
Contributor

Choose a reason for hiding this comment

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

use get_dates to get dates and is_current etc. (fully tested functions in tools.py to do this work if poss.

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']]
Copy link
Contributor

Choose a reason for hiding this comment

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

:) nice!


# Major Goals

# 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"]])

# 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,
)
121 changes: 121 additions & 0 deletions regolith/templates/grantreport.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
NSF {{beginYear}}-{{endYear}} Annual Report by {{authorFullName}}, ({{ institution }})

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
"imperfect" materials operate, including on different length and time-scales. In situations
as complicated as this it is essential to validate theories against experiment, and vice versa.
A more tightly coupled partnership between experiment and theory is needed, having its roots
in information theory: the models need to capture all the physics of the problem become more
complicated, while at the same time the information content of experimental data is reduced,
due to lower resolution from finite size effects, defects, the presence of multiple components
with overlapping problems, which yield unreliable and non-unique solutions, a bottleneck to
predictive materials discovery. We will develop novel mathematical approaches to address this
problem. We will study as a test case the nanostructure inverse problem (NIP), a well defined
but generally ill-posed materials inverse problem; however, the methods that we develop will
have much broader applicability in the world of materials discovery.

Goal 1: Develop databases of nanostructure data from model systems
Goal 2: Develop data analytic and stochastic optimization methodologies for robust
nanostructure solutions
Goal 3: Develop software infrastructure for nanostructure modeling that use the databases
and the new methodologies for nanostructure solution
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:

Key outcomes or Other achievements:
* What opportunities for training and professional development has the project provided?
{%- for opportunity in presentations %}
- {{opportunity -}}
{% endfor -%}}

* How have the results been disseminated to communities of interest?

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

Products
------------------------------
Books

Book Chapters

Inventions

Journals or Juried Conference Papers

Licenses

Other Conference Presentations / Papers

Other Products

Other Publications

Patents

Technologies or Techniques

Thesis/Dissertations

Websites

Participants/Organizations
------------------------------
What individuals have worked on the project?

Name, Most Senior Project Role, Nearest Person Month Worked

Full details of individuals who have worked on the project:

Name:
Email:
Most Senior Project Role:
Nearest Person Month Worked:
Contribution to the Project:
Funding Support:
International Collaboration:
International Travel:

What other organizations have been involved as partners?
What other collaborators or contacts have been involved?

Impacts
------------------------------
What is the impact on the development of the principal discipline(s) of the project?

What is the impact on other disciplines?

What is the impact on the development of human resources?

What is the impact on physical resources that form infrastructure?

What is the impact on institutional resources that form infrastructure?

What is the impact on information resources that form infrastructure?

What is the impact on technology transfer?

What is the impact on society beyond science and technology?

Changes/Problems
------------------------------
Changes in approach and reason for change

Actual or Anticipated problems or delays and actions or plans to resolve them

Changes that have a significant impact on expenditures

Significant changes in use or care of human subjects

Significant changes in use or care of vertebrate animals

Significant changes in use or care of biohazards
118 changes: 118 additions & 0 deletions tests/outputs/grantreport/billinge_grant_report.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
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
"imperfect" materials operate, including on different length and time-scales. In situations
as complicated as this it is essential to validate theories against experiment, and vice versa.
A more tightly coupled partnership between experiment and theory is needed, having its roots
in information theory: the models need to capture all the physics of the problem become more
complicated, while at the same time the information content of experimental data is reduced,
due to lower resolution from finite size effects, defects, the presence of multiple components
with overlapping problems, which yield unreliable and non-unique solutions, a bottleneck to
predictive materials discovery. We will develop novel mathematical approaches to address this
problem. We will study as a test case the nanostructure inverse problem (NIP), a well defined
but generally ill-posed materials inverse problem; however, the methods that we develop will
have much broader applicability in the world of materials discovery.

Goal 1: Develop databases of nanostructure data from model systems
Goal 2: Develop data analytic and stochastic optimization methodologies for robust
nanostructure solutions
Goal 3: Develop software infrastructure for nanostructure modeling that use the databases
and the new methodologies for nanostructure solution
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:

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?

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

Products
------------------------------
Books

Book Chapters

Inventions

Journals or Juried Conference Papers

Licenses

Other Conference Presentations / Papers

Other Products

Other Publications

Patents

Technologies or Techniques

Thesis/Dissertations

Websites

Participants/Organizations
------------------------------
What individuals have worked on the project?

Name, Most Senior Project Role, Nearest Person Month Worked

Full details of individuals who have worked on the project:

Name:
Email:
Most Senior Project Role:
Nearest Person Month Worked:
Contribution to the Project:
Funding Support:
International Collaboration:
International Travel:

What other organizations have been involved as partners?
What other collaborators or contacts have been involved?

Impacts
------------------------------
What is the impact on the development of the principal discipline(s) of the project?

What is the impact on other disciplines?

What is the impact on the development of human resources?

What is the impact on physical resources that form infrastructure?

What is the impact on institutional resources that form infrastructure?

What is the impact on information resources that form infrastructure?

What is the impact on technology transfer?

What is the impact on society beyond science and technology?

Changes/Problems
------------------------------
Changes in approach and reason for change

Actual or Anticipated problems or delays and actions or plans to resolve them

Changes that have a significant impact on expenditures

Significant changes in use or care of human subjects

Significant changes in use or care of vertebrate animals

Significant changes in use or care of biohazards
3 changes: 2 additions & 1 deletion tests/test_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"reimb",
"figure",
"recent-collabs",
"beamplan"
"beamplan",
"grantreport"
]
db_srcs = ["mongo", "fs"]

Expand Down