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, date
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
)


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
gtx["projecta"] = sorted(
all_docs_from_collection(rc.client, "projecta"), key=_id_key
)
gtx["people"] = sorted(
all_docs_from_collection(rc.client, "people"), key=_id_key
)
gtx["presentations"] = sorted(
all_docs_from_collection(rc.client, "presentations"), key=_id_key
)
gtx["grants"] = sorted(
all_docs_from_collection(rc.client, "grants"), key=_id_key
)
gtx["institutions"] = sorted(
all_docs_from_collection(rc.client, "institutions"), 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"""
# Get Dates
today = str(date.today()).split("-")
end_year, end_month, end_day = int(today[0]), int(today[1]), int(today[2])
begin_year, begin_month, begin_day = int(today[0])-1, int(today[1]), int(today[2])
end_date = date(end_year, end_month, end_day)
begin_date = date(begin_year, begin_month, begin_day)

# Get All Active Members
people = []
for p in self.gtx["people"]:
Copy link
Contributor

Choose a reason for hiding this comment

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

current_members = [person for person in self.gtx['people'] if person['active']]

if p["active"]:
people.append(p)

# Major Goals

# Accomplishments

# Opportunities for Training and Professional Development
valid_presentations = []
for p in people:
Copy link
Contributor

Choose a reason for hiding this comment

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

for person in people

if p["_id"] is not "sbillinge":
Copy link
Contributor

Choose a reason for hiding this comment

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

my name shouldn't be hard-coded in here

valid_presentations.append(filter_presentations(
self.gtx["people"], self.gtx["presentations"], self.gtx["institutions"], p["_id"],
["tutorial", "contributed_oral"], begin_date, end_date))

# How have results been disseminated

# Plans for Next Reporting Period to Accomplish Goals

# Individuals that have worked on project
individuals_data = []
for p in people:
Copy link
Contributor

Choose a reason for hiding this comment

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

you keep looping over people so why not put each of these actions inside a single outer loop over people?

individuals_data.append([p["_id"], p["position"]])


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

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

* 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
97 changes: 97 additions & 0 deletions tests/outputs/grantreport/billinge_grant_report.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
NSF 2019-2020 Annual Report by
Simon J. L. Billinge, (Columbia University)

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

* 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