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

3106 reparse django action #3167

Merged
merged 72 commits into from
Oct 18, 2024
Merged

3106 reparse django action #3167

merged 72 commits into from
Oct 18, 2024

Conversation

raftmsohani
Copy link

@raftmsohani raftmsohani commented Sep 3, 2024

Summary of Changes

Pull request closes #3106

  • Added an action button to data_file admin page for reparsing fiels
  • Added a script which creates a modal to confirm action
  • Changed reparsing command to perform reparsing on selected number of files

How to Test

  1. Open http://localhost:3000/ and sign in.
  2. submit a couple of files
  3. go to /admin/data_files page
  4. choose a couple of files, and use action button to start the reparse
  5. you should be redirected to another page to confirm reparsing
  6. push confirm to proceed, then look at the logs

Deliverables

More details on how deliverables herein are assessed included here.

Deliverable 1: Accepted Features

Checklist of ACs:

  • OFA System Administrators can initiate a reparsing run from DAC
  • OFA System Administrators can filter/select datafiles for this action
  • Re-Parsing runs follow safety protocols implemented in #3065 whether from cli cmd or DAC
  • Ensure Testing Checklist passes successfully
  • Restrict the action such that DIGIT can not run re-parse command
  • lfrohlich and/or adpennington confirmed that ACs are met.

Deliverable 2: Tested Code

  • Are all areas of code introduced in this PR meaningfully tested?
    • If this PR introduces backend code changes, are they meaningfully tested?
    • If this PR introduces frontend code changes, are they meaningfully tested?
  • Are code coverage minimums met?
    • Frontend coverage: [insert coverage %] (see CodeCov Report comment in PR)
    • Backend coverage: [insert coverage %] (see CodeCov Report comment in PR)

Deliverable 3: Properly Styled Code

  • Are backend code style checks passing on CircleCI?
  • Are frontend code style checks passing on CircleCI?
  • Are code maintainability principles being followed?

Deliverable 4: Accessible

  • Does this PR complete the epic?
  • Are links included to any other gov-approved PRs associated with epic?
  • Does PR include documentation for Raft's a11y review?
  • Did automated and manual testing with iamjolly and ttran-hub using Accessibility Insights reveal any errors introduced in this PR?

Deliverable 5: Deployed

  • Was the code successfully deployed via automated CircleCI process to development on Cloud.gov?

Deliverable 6: Documented

  • Does this PR provide background for why coding decisions were made?
  • If this PR introduces backend code, is that code easy to understand and sufficiently documented, both inline and overall?
  • If this PR introduces frontend code, is that code easy to understand and sufficiently documented, both inline and overall?
  • If this PR introduces dependencies, are their licenses documented?
  • Can reviewer explain and take ownership of these elements presented in this code review?

Deliverable 7: Secure

  • Does the OWASP Scan pass on CircleCI?
  • Do manual code review and manual testing detect any new security issues?
  • If new issues detected, is investigation and/or remediation plan documented?

Deliverable 8: User Research

Research product(s) clearly articulate(s):

  • the purpose of the research
  • methods used to conduct the research
  • who participated in the research
  • what was tested and how
  • impact of research on TDP
  • (if applicable) final design mockups produced for TDP development

@raftmsohani raftmsohani self-assigned this Sep 3, 2024
@ADPennington ADPennington added Blocked Label for Pull Requests that are currently blocked by a dependency and removed Deploy with CircleCI-raft Deploy to https://tdp-frontend-raft.app.cloud.gov through CircleCI labels Oct 16, 2024
@raftmsohani
Copy link
Author

@ADPennington did the change on log message. Please re-review

@ADPennington
Copy link
Collaborator

@ADPennington did the change on log message. Please re-review

@raftmsohani when you have some time, Can you get the merge conflicts resolved?

@ADPennington ADPennington added Deploy with CircleCI-qasp Deploy to https://tdp-frontend-qasp.app.cloud.gov through CircleCI and removed Blocked Label for Pull Requests that are currently blocked by a dependency labels Oct 17, 2024
@ADPennington ADPennington added Deploy with CircleCI-qasp Deploy to https://tdp-frontend-qasp.app.cloud.gov through CircleCI and removed Deploy with CircleCI-qasp Deploy to https://tdp-frontend-qasp.app.cloud.gov through CircleCI labels Oct 17, 2024
@jtimpe jtimpe mentioned this pull request Oct 17, 2024
9 tasks
logger_context=log_context,
level='info')
else:
log(f"Starting clean and reparse action for files: {str(selected_files)}",
Copy link
Collaborator

Choose a reason for hiding this comment

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

@jtimpe I am confirming that this log change works as expected when triggering reparsing from DAC and terminal on a specific files 👍🏾

Copy link
Collaborator

Choose a reason for hiding this comment

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

T = reparsing from terminal
D = reparsing from DAC

actions_and_commands

@@ -33,6 +33,7 @@ def add_arguments(self, parser):
parser.add_argument("-y", "--fiscal_year", type=int, help="Reparse all files in the fiscal year, e.g. 2021.")
parser.add_argument("-a", "--all", action='store_true', help="Clean and reparse all datafiles. If selected, "
"fiscal_year/quarter aren't necessary.")
parser.add_argument("-f", "--files", nargs='+', type=str, help="Re-parse specific datafiles by datafile id")
Copy link
Collaborator

@ADPennington ADPennington Oct 17, 2024

Choose a reason for hiding this comment

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

i tested this new option on a subset of files with this command:

python manage.py clean_and_reparse -f "1215,1030,2246,1807,1737,1826,1044"

and this immediately triggered the reparsing process and did not prompt me to confirm that I wanted to reparse X number of files.

vcap@:~$ python manage.py clean_and_reparse -f "1215,1030,2246,1807,1737,1826,1044"
************** reparse all False
************** selected files [1215, 1030, 2246, 1807, 1737, 1826, 1044]


INSIDE FILE COUNTS MATCH:
7, 7, 0




INSIDE FILE COUNTS MATCH:
7, 7, 0


2024-10-17 22:01:51,087 INFO clean_and_reparse.py::_backup:L49 :  Beginning reparse DB Backup.
Beginning reparse DB Backup.
2024-10-17 22:01:51,092 INFO db_backup.py::get_system_values:L54 :  Using postgres client at: /home/vcap/deps/0/apt/usr/lib/postgresql/15/bin/
Using postgres client at: /home/vcap/deps/0/apt/usr/lib/postgresql/15/bin/
2024-10-17 22:01:51,094 INFO db_backup.py::backup_database:L89 :  Executing backup command: /home/vcap/deps/0/apt/usr/lib/postgresql/15/bin/pg_dump -Fc 
...
...

Copy link
Collaborator

Choose a reason for hiding this comment

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

i expected something like this:

vcap@:~$ python manage.py clean_and_reparse -y 2025
************** reparse all False
************** selected files None

You have selected to reparse datafiles for FY 2025 and Q1-4. The reparsed files will NOT be stored in new indices and the old indices
These options will delete and reparse (2) datafiles.
Continue [y/n]?

Copy link
Collaborator

@ADPennington ADPennington Oct 18, 2024

Choose a reason for hiding this comment

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

per Jan:

-f is only used by the action (which confirms via javascript), which is why the additional conditional checks weren't added

evidence here

}
submitBtn.addEventListener('click', function(e) {
e.preventDefault();
if (confirm("You are about to re-parse " + number_of_files.innerHTML.split(/(\s+)/)[0] + " files. Are you sure you want to continue?")) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

confirm_reparse_DAC

Copy link
Collaborator

@ADPennington ADPennington left a comment

Choose a reason for hiding this comment

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

Excellent work @raftmsohani 🚀 testing notes below ⬇️ cc: @ttran-hub

Tests

  • via DAC:

    • most recent version of all files submitted for FY21, tribes only.
    • one file
    • selected list of files
    • while one reparsing process was in-progress, triggering another reparse action
  • via management command (terminal):

    • all FY2025 files
    • selected list of files (by file id)

Notes

  • All of the tests were successful 🚀

  • Tests reaffirmed that its possible to trigger a new parsing action while one is in-progress, but it seems better to wait until the initial process is complete (the metamodel id for the new action will not appear until the initial process completes).

  • the LogEntries currently includes a list of files by ID to be reparsed, but could use some improvement to its more clear which files have been queued for reparsing. Relatedly, it would be helpful to add a logentry and/or email notification to admins when the reparsing process finished. In the meantime, we should monitor the metamodel metrics.
    logentries_dac

  • The following fields in the reparse metamodel are N/A, especially when reparsing from DAC, and may need to be refactored or removed in Re-parse command refactor #3205
    metamodel_fields_tobe_removed

  • Reparsing via terminal seems most useful if we want to reparse all versions of files by fiscal period. It is technically possible to select specific files to be reparsed, but confirmation prompts aren't currently included before the process begins, so not recommended at this time (reference) ⚠️

@ADPennington ADPennington removed the request for review from ttran-hub October 18, 2024 15:31
@ADPennington ADPennington added Ready to Merge and removed QASP Review Deploy with CircleCI-qasp Deploy to https://tdp-frontend-qasp.app.cloud.gov through CircleCI labels Oct 18, 2024
@raftmsohani raftmsohani merged commit 702f72f into develop Oct 18, 2024
25 checks passed
@raftmsohani raftmsohani deleted the 3106-reparse-django-action branch October 18, 2024 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Re-Parse Django Action
5 participants