-
Notifications
You must be signed in to change notification settings - Fork 6
fix: feed files are not been extracted #1303
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0db0a9d
fix generated file variable for extracted files
davidgamez ea31389
Update functions-python/batch_process_dataset/src/main.py
davidgamez c232e37
Update functions-python/batch_process_dataset/src/scripts/download_ve…
davidgamez 52a1ff9
Revert "Update functions-python/batch_process_dataset/src/main.py"
davidgamez bbc7904
fix lint
davidgamez b145811
use the correct file path
davidgamez 1024c95
Unzip files after hash check.
davidgamez f0701a8
Add local testing and fix function response
davidgamez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ omit = | |
| */database_gen/* | ||
| */dataset_service/* | ||
| */shared/* | ||
| */scripts/* | ||
|
|
||
| [report] | ||
| exclude_lines = | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,4 +2,5 @@ Faker | |
| pytest~=7.4.3 | ||
| urllib3-mock | ||
| requests-mock | ||
| python-dotenv~=1.0.0 | ||
| python-dotenv~=1.0.0 | ||
| gcp-storage-emulator | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
functions-python/batch_process_dataset/src/scripts/download_verifier.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| import logging | ||
|
davidgamez marked this conversation as resolved.
|
||
| import os | ||
|
|
||
| from main import DatasetProcessor | ||
| from gcp_storage_emulator.server import create_server | ||
|
|
||
| HOST = "localhost" | ||
| PORT = 9023 | ||
| BUCKET_NAME = "verifier" | ||
| PRODUCER_URL = "https://example.com/dataset.zip" # Replace with actual producer URL | ||
|
|
||
|
|
||
| def verify_download_content(producer_url: str): | ||
| """ | ||
| Verifies the download_content is able to retrieve the file | ||
| This is useful to simulate the download code locally and test issues related with user-agent and downloaded content. | ||
| Not supported authenticated feeds currently. | ||
| """ | ||
| logging.info("Verifying downloaded content... (not implemented)") | ||
|
|
||
| logging.info(f"Producer URL: {producer_url}") | ||
|
|
||
| processor = DatasetProcessor( | ||
| producer_url=producer_url, | ||
| feed_id=None, | ||
| feed_stable_id=None, | ||
| execution_id=None, | ||
| latest_hash=None, | ||
| bucket_name=None, | ||
| authentication_type=0, | ||
| api_key_parameter_name=None, | ||
| public_hosted_datasets_url=None, | ||
| ) | ||
| tempfile = processor.generate_temp_filename() | ||
| logging.info(f"Temp filename: {tempfile}") | ||
| file_hash, is_zip = processor.download_content(tempfile) | ||
| logging.info(f"File hash: {file_hash}") | ||
|
|
||
|
|
||
| def verify_upload_dataset(producer_url: str): | ||
| """ | ||
| Verifies the upload_dataset is able to upload the dataset to the GCP storage emulator. | ||
| This is useful to simulate the upload code locally and test issues related with user-agent and uploaded content. | ||
| This function also tests the DatasetProcessor class methods for generating a temporary filename | ||
| and uploading the dataset. | ||
| :param producer_url: | ||
| :return: | ||
| """ | ||
| processor = DatasetProcessor( | ||
| producer_url=producer_url, | ||
| feed_id="feed_id", | ||
| feed_stable_id="feed_stable_id", | ||
| execution_id=None, | ||
| latest_hash="123", | ||
| bucket_name=BUCKET_NAME, | ||
| authentication_type=0, | ||
| api_key_parameter_name=None, | ||
| public_hosted_datasets_url=None, | ||
| ) | ||
| tempfile = processor.generate_temp_filename() | ||
| logging.info(f"Temp filename: {tempfile}") | ||
| dataset_file = processor.upload_dataset(public=False) | ||
| logging.info(f"Dataset File: {dataset_file}") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| logging.basicConfig(level=logging.INFO) | ||
| # Replace with actual producer URL | ||
| try: | ||
| os.environ["STORAGE_EMULATOR_HOST"] = f"http://{HOST}:{PORT}" | ||
| server = create_server( | ||
| host=HOST, port=PORT, in_memory=False, default_bucket=BUCKET_NAME | ||
| ) | ||
| server.start() | ||
|
|
||
| verify_download_content(producer_url=PRODUCER_URL) | ||
| logging.info("Download content verification completed successfully.") | ||
| verify_upload_dataset(producer_url=PRODUCER_URL) | ||
| verify_upload_dataset(producer_url=PRODUCER_URL) | ||
| except Exception as e: | ||
| logging.error(f"Error verifying download content: {e}") | ||
| finally: | ||
| server.stop() | ||
| logging.info("Verification completed.") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.