-
Notifications
You must be signed in to change notification settings - Fork 3
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
Allow exporting a snapshot of NERC Prepay Credits file #128
base: main
Are you sure you want to change the base?
Conversation
70b81f9
to
bc17a70
Compare
return self.prepay_credits[credits_mask] | ||
|
||
def _export_prepay_credits_snapshot(self, credits_snapshot): | ||
credits_snapshot.to_csv( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also upload to s3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Credits snapshot will now be uploaded to f"Invoices/{self.invoice_month}/NERC_Prepaid_Group-Credits-{self.invoice_month}.csv"
and the archive location f"Invoices/{self.invoice_month}/Archive/NERC_Prepaid_Group-Credits-{self.invoice_month} {util.get_iso8601_time()}.csv"
bc17a70
to
f3cce36
Compare
I have rebased the PR |
dace52c
to
dc66206
Compare
@knikolla did Quan manage to resolve the issue you had with this PR? are we ready to approve? |
dc66206
to
f52d39b
Compare
The PR has been rebased |
@QuanMPhm please re-request review after you rebase. |
@joachimweyl I don't see a button to allow a re-review yet :P I guess, @knikolla @naved001 @hakasapl Any opinions? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stylistic and consistency comments. Otherwise looks good.
prepay_credits: pandas.DataFrame | ||
prepay_projects: pandas.DataFrame | ||
prepay_contacts: pandas.DataFrame | ||
prepay_debits_filepath: str | ||
upload_to_s3: bool | ||
export_NERC_credits: bool = True # For testing purposes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export_NERC_credits
is inconsistently capitalized, should be export_nerc_credits
.
@@ -22,11 +22,24 @@ class PrepaymentProcessor(discount_processor.DiscountProcessor): | |||
def PREPAY_DEBITS_S3_BACKUP_FILEPATH(self): | |||
return f"Prepay/Archive/prepay_debits {util.get_iso8601_time()}.csv" | |||
|
|||
@property |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I usually try to have the following order for things defined in a class.
- attributes
- properties
- methods
This makes it easier to find out where things are defined, so please move the properties after the attributes.
return f"NERC_Prepaid_Group-Credits-{self.invoice_month}.csv" | ||
|
||
@property | ||
def CREDITS_SNAPSHOT_S3_FILEPATH(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While you could argue that these are all constants and therefore should be all caps, please don't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have repositioned and removed the capitalization on the properties.
317850c
to
e9382b5
Compare
def _export_s3_prepay_credits_snapshot(self, credits_snapshot): | ||
invoice_bucket = util.get_invoice_bucket() | ||
invoice_bucket.upload_file( | ||
self.CREDITS_SNAPSHOT_FILEPATH, self.CREDITS_SNAPSHOT_S3_FILEPATH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you changed the capitalization, but didn't change the capitalization of where they are used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like the idea of Processors
exporting files into the Invoices\<invoice_month>
folder, as that should be limited to only Invoices
.
Is this something that can be done in an Invoice
?
@knikolla Initially, I didn't want to create an invoice class for the NERC credits snapshot, since it wasn't technically an invoice. But now that you point it out, I'll make an |
@QuanMPhm Or alternatively, if it's not an Invoice, you could put it in a different folder. What is our purpose for exporting this file? What happens with it after export? |
From the prepay scaffolding document:
@joachimweyl Let me know if this is still correct. |
@QuanMPhm Sounds like it's an Invoice :)
|
@knikolla Could I have the prepay processor create the snapshot, and have the invoice class export it? That would make the code a bit less repetitive, but I understand if you think it might make the code look messier. |
e9382b5
to
c7ac870
Compare
I've decided to put everything into a new invoice class. |
…ot` invoice class The snapshot has custom export paths, and a test case has been written for it.
c7ac870
to
a7a7f68
Compare
Closes #86. This PR consists of only the last commit, "NERC Prepay Credits...".
Two functions have been added to the Prepayment Processor. One is to obtain the credits "snapshot". A test case has been written for this function.