Skip to content

Conversation

@QuanMPhm
Copy link
Contributor

Since invoices are now uploaded daily, simply downloading everything in the Service Invoices folder is not efficient. A list of invoice names have been added to track only the monthly invoices. This list needs to be updated if new services are added.

s3_name = os.path.join(
invoice_settings.invoice_path_template,
local_name,
).format(invoice_month=invoice_settings.invoice_month)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This particular use of os.path.join will produce the desired S3 key, despite that it's still not a good use of os.path.join because S3 Keys are not OS paths. This communicates wrong intent in my opinion. I'd rather we just use f strings to concatenate the 2 strings.

In our case, we have

invoice_path_template = "Invoices/{invoice_month}/Service Invoices/"

had it been missing the last "/"

invoice_path_template = "Invoices/{invoice_month}/Service Invoices"

on a windows system it would join with "\" and generate an incorrect S3 key.

>>> os.path.join("Invoices/{invoice_month}/Service Invoices", "local_file.csv").format(invoice_month="2025-11")
'Invoices/2025-11/Service Invoices\\local_file.csv'

Obviously, we don't support windows so we won't run into this failure but this is just an example. There's no advantage of using os.path.join only potential drawbacks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I switched to using basic string concatenation

Since invoices are now uploaded daily, simply downloading
everything in the `Service Invoices` folder is not efficient.
A list of invoice names have been added to track only the monthly
invoices. This list needs to be updated if new services are added.
@QuanMPhm QuanMPhm merged commit 791aa85 into CCI-MOC:main Jan 5, 2026
6 checks passed
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.

3 participants