Skip to content

Allow optionally fetching lease data from S3#8

Merged
QuanMPhm merged 1 commit intoCCI-MOC:mainfrom
QuanMPhm:7/b2_client
Nov 4, 2025
Merged

Allow optionally fetching lease data from S3#8
QuanMPhm merged 1 commit intoCCI-MOC:mainfrom
QuanMPhm:7/b2_client

Conversation

@QuanMPhm
Copy link
Collaborator

@QuanMPhm QuanMPhm commented Sep 9, 2025

Closes #7. I have a single question before considering this complete

@QuanMPhm QuanMPhm marked this pull request as draft September 10, 2025 14:04

bm_usage_file = args.bm_usage_file or s3_bucket.fetch_s3(
...
) # TODO: Confirm S3 path
Copy link
Collaborator Author

@QuanMPhm QuanMPhm Sep 10, 2025

Choose a reason for hiding this comment

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

@knikolla @naved001 Can I have confirmation on the S3 path of the lease info? Given @naved001's comment, the lease info is uploaded daily?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since lease info is uploaded daily. I'll fetch the lease info from the last day of the month.

@QuanMPhm QuanMPhm marked this pull request as ready for review September 18, 2025 20:45
# S3 Configuration
S3_ENDPOINT_URL = os.getenv("S3_ENDPOINT_URL", "https://s3.us-east-005.backblazeb2.com")
S3_KEY_ID = os.getenv("S3_KEY_ID")
S3_APP_KEY = os.getenv("S3_APP_KEY")
Copy link
Collaborator

Choose a reason for hiding this comment

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

you'll need 2 sets of credentials later when you access the bucket to upload the generated invoice to, but that's for later.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd rather change the environment variable names now to not be generic by adding to them either USAGE or LEASE since renaming environment variables is a breaking change.



@functools.lru_cache
def get_lease_bucket(bucket_name: str):
Copy link
Collaborator

Choose a reason for hiding this comment

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

shouldn't this just be get_bucket?

# S3 Configuration
S3_ENDPOINT_URL = os.getenv("S3_ENDPOINT_URL", "https://s3.us-east-005.backblazeb2.com")
S3_KEY_ID = os.getenv("S3_KEY_ID")
S3_APP_KEY = os.getenv("S3_APP_KEY")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd rather change the environment variable names now to not be generic by adding to them either USAGE or LEASE since renaming environment variables is a breaking change.

If a lease file is not provided, we default to fetching a lease
file that our metrics automation uploads to B2 daily
@QuanMPhm QuanMPhm merged commit fb6042e into CCI-MOC:main Nov 4, 2025
2 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.

Add a B2 client to fetch lease information

3 participants