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

ENH: add public and professional summary when f_prum #657

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

dragonyanglong
Copy link
Contributor

@sbillinge , as we discussed. We want people mandatory to input the public and professional summary when finishing a prum.

Currently, I didn't update the schema.py and a_projectumhelper.py, because I don't know how to initialize these two entries. If we initialize them, it is difficult afterwards for us to check whether people really input something useful for the summaries, or just random useless str when f_prum.

Please review.

@codecov
Copy link

codecov bot commented Dec 6, 2020

Codecov Report

Merging #657 (d77ee42) into master (c544721) will decrease coverage by 0.03%.
The diff coverage is 50.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #657      +/-   ##
==========================================
- Coverage   68.12%   68.09%   -0.04%     
==========================================
  Files          67       67              
  Lines        6705     6717      +12     
==========================================
+ Hits         4568     4574       +6     
- Misses       2137     2143       +6     
Impacted Files Coverage Δ
regolith/helpers/u_finishprumhelper.py 87.69% <50.00%> (-8.54%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c544721...e15f55e. Read the comment docs.

Copy link
Contributor

@sbillinge sbillinge left a comment

Choose a reason for hiding this comment

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

pls see inline comments

regolith/helpers/u_finishprumhelper.py Show resolved Hide resolved
regolith/helpers/u_finishprumhelper.py Outdated Show resolved Hide resolved
regolith/helpers/u_finishprumhelper.py Outdated Show resolved Hide resolved
@@ -60,6 +64,16 @@ def db_updater(self):
print("Please rerun the helper specifying the complete ID.")
return
found_projectum.update({'status':'finished'})
if rc.pub_sum:
found_projectum['deliverable'].update({'public_summary': rc.pub_sum})
elif found_projectum['deliverable'].get('public_summary') is not None:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the logic should probably be:

if not found_prum['professional_summary']:
  if rc.pro_sum:
     found_prum['professional_summary'] = rc.pro_sum
  else:
     raise RuntimeError("ERROR: please rerun with a professional summary in field --pro_sum and public summary in --pub_sum")

and

if not found_prum['public_summary']:
  if rc.pub_sum:
     found_prum['professional_summary'] = rc.pub_sum
  else:
     raise RuntimeError("ERROR: please rerun with a professional summary in field --pro_sum and public summary in --pub_sum")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi Simon, I am a bit hesitate to change the logic into this way, because once we update the schema.py and a_projectumhelper.py, when people create a new prum, the professional_summary field will automatically have some words there (because we initize it).

In this situation, the first if statmentif not found_prum['public_summary']: is useless.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should prevent people entering random stuff or not changing the original initialization words in the professional_summary field when people finish a prum.

Copy link
Contributor

@sbillinge sbillinge left a comment

Choose a reason for hiding this comment

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

still not quite there. I don't want the cli to overwrite any summary in the db inadvertently.

print("Error: please enter the public summary by specifying pub_sum argument.")
return
found_projectum['public_summary'] = rc.pub_sum
elif found_projectum.get('public_summary') is not None:
Copy link
Contributor

@sbillinge sbillinge Dec 8, 2020

Choose a reason for hiding this comment

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

I think this logic is not quite right, please see my code from the previous convo. The outer loop should check if the summaries exist in the db or not and it should not overwrite them if they do. Then it should check if rc.pub_sum exists and use that, finally it should raise a runtime error if it neither already exists in the db nor has been given to the cli.

We should also catch the case where it finds something in the db and is given a value on the cli with a f"WARNING: public summary {found_projectum.get('public_summary')} exists in the db and will not be overwritten with {rc.pub_sum} given on the command line. If you want to force this change please rerun adding --force" or sthg like that.

Copy link
Contributor

@sbillinge sbillinge left a comment

Choose a reason for hiding this comment

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

pls see inline comments

regolith/helpers/u_finishprumhelper.py Show resolved Hide resolved
@sbillinge
Copy link
Contributor

sbillinge commented Dec 18, 2020 via email

@sbillinge
Copy link
Contributor

haha, this is why we write tests! :) (and do code review, but the review is easier if there are good tests!)

@sbillinge
Copy link
Contributor

btw, if you write a good function, we can abstract it to be used more widely. This kind of "syncing" is presumably quite common in our helpers. So I encourage you to use variable names that are not specific to this UC.

@sbillinge
Copy link
Contributor

@dragonyanglong I am not sure where you are with this, but I have had a change of thought. I am wondering, should we put the public and professional summaries into the paper entry in the citations db? I think yes. This means that the summaries/descriptions follow the paper around and we don't have to dereference a projectum for each paper. Most papers will have a prum, but we don't have an "associated_prum" field in the citation so there is currently no way to find the summaries for a paper just from the paper, which doesn't make sense to me. Actually, come to think of it we shoujld probably have a citation_id field in the prum and a prum_id field in the citation entry.

None of this changes much what is happening in this PR, except that we want to push the prof and pub summaries to the ciatation and not the prum. What do you think?

@dragonyanglong
Copy link
Contributor Author

Hi Simon, yup, I agree. make these summaries attached with papers sound reasonable. I will migrate the changes to citations. For the citation_id in the prum, I am not sure if it is necessary or not. Since we will have a prum_id in the citataion entry, so they are linked together in the db, so I guess we don't need another key to link in the reverse way, otherwise, if people made mistake, ie. citataion_id and prum_id doesn't match with each other, it may cause confusing.

@dragonyanglong
Copy link
Contributor Author

and BTW, it seems like there is no helper functions for citataions like f_prum etc.... And for citations, usually we just create one, then manually update the info when published (like updating the final page numbers etc). So the workflow is bit different from prums.

@sbillinge
Copy link
Contributor

sbillinge commented Dec 19, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants