Add StorageClient abstract type and GCS Client Implementation#61
Conversation
| def push_report(self, reports: List[str]) -> None: | ||
| for index, content in enumerate(reports): | ||
| filename = f"report-{index}" | ||
| blob_path = f"{self.path}/{filename}" if self.path else filename |
There was a problem hiding this comment.
We should make self.path optionally configurable instead of only base class reports-timestamp. Or at least the ability to specify a prefix so reports are written as bucket/prefix/reports-timestamp/reports-index
There was a problem hiding this comment.
Made path and report_file_prefix configurable, added more about usage in the description
| google_cloud_storage: Optional[GoogleCloudStorageConfig] = None | ||
|
|
||
| @model_validator(mode="after") | ||
| def check_oneof(self) -> "ReportStorageConfig": |
There was a problem hiding this comment.
It may make sense to allow multiple ReportStorageConfig like local path and GCS
There was a problem hiding this comment.
In that case removed the check altogether
SachinVarghese
left a comment
There was a problem hiding this comment.
Looks good overall! Minor changes requested.
| self.path = f"reports-{timestamp}" | ||
| print(f"Reports will be stored at: {self.path}") | ||
|
|
||
| def push_report(self, reports: List[str]) -> None: |
There was a problem hiding this comment.
save is a more generic term with storage solutions and appropriate for the abstract class.
Further, we should allow reportgen to pass a list of fileObjects (with filename and content). The storage client should be agnostic of reporting process and should only deal with storing of such file objects at the path.
| def push_report(self, reports: List[str]) -> None: | |
| def save_report(self, reports: List[ReportFile]) -> None: |
There was a problem hiding this comment.
Done, also heads up moved storage from config.report to config
| return self | ||
|
|
||
|
|
||
| class ReportConfig(BaseModel): |
There was a problem hiding this comment.
can we add an enum type for the report - defaulting to mock report?
There was a problem hiding this comment.
This is being addressed in a follow up PR, will link once its reviewable
86c041e to
dfc02e1
Compare
and revert unneeded changes in base.py deduplication missing licence statement in gcs.py deduplicate push_report tweak if/else in main.py addressing requested changes add ReportFile to init move reportfile remove duplciate import remove unneeded import move reportfile remove storageclient from reportgen to fix circular dependency remove hanging import lint change import change import fix imports reorder imports add missing __init__.py fix circular import remove unneeded import reportfile_prefix optional storage_clietns = [] missing positional argument missing positional argument ReportFile should not be BaseModel incorrect field mame update get_contents() remove reference to fileobj should loop over storage clients debug fix missing .get_contents() call model.dumps -> model_dump remove indent fix _store_locally fix upload_from_string types move storage to root of config config.report.storage -> config.storage typo reportfile_prefix -> report_file_prefix lint remove config from storage __init__ check if file already exists
|
Can you run |
|
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: achandrasekar, Bslabe123 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Fixes: #59
Example config.yml for uploading report to GCS:
Report destination will be logged:
Example of uploaded report:
GCS Screenshot:
