-
Notifications
You must be signed in to change notification settings - Fork 8
Mohamad Bader AA #2
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
Open
noneeeed
wants to merge
10
commits into
HackYourAssignment:main
Choose a base branch
from
noneeeed:week3-attempt
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
77e6796
ingested api with expo retries, added fetch api records.
noneeeed 21fc4c6
added read_csv_records using DictReader
noneeeed 797d30a
added validate records with pydantic
noneeeed 6d3ba8b
created tables, implemented insert raw, upsert readings, count readings
noneeeed 732cb46
implemented run pipleline, called all created functions in entry point
noneeeed aa9258e
added clean station (was not implemented)
noneeeed 10399f5
completed azure compare.md, created script (removed token) to create …
noneeeed e01d894
added AI debug
noneeeed 1a70c19
added more line breaks to azure_compare
noneeeed 41f53a1
removed azure_resource_groups from gitignore and commited the file
noneeeed 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
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,23 @@ | ||
| import json | ||
|
|
||
| import requests | ||
| from pathlib import Path | ||
|
|
||
|
|
||
| OUTPUT_DIR = Path("output") | ||
| OUTPUT_DIR.mkdir(exist_ok=True) | ||
|
|
||
|
|
||
| token = "token_here" | ||
| subscription_id = "1120c89d-2a5f-4a15-a582-2ea34f0bb5c3" # from the portal above | ||
|
|
||
| url = f"https://management.azure.com/subscriptions/{subscription_id}/resourcegroups?api-version=2024-03-01" | ||
| headers = {"Authorization": f"Bearer {token}"} | ||
|
|
||
| response = requests.get(url, headers=headers, timeout=10) | ||
| response.raise_for_status() | ||
| for rg in response.json()["value"]: | ||
| print(f"{rg['name']}: {rg['location']}") | ||
|
|
||
| with open(OUTPUT_DIR / "azure_resource_groups.json", "w") as f: | ||
| json.dump(response.json(), f, indent=2) |
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
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
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 |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "value": [ | ||
| { | ||
| "id": "/subscriptions/1120c89d-2a5f-4a15-a582-2ea34f0bb5c3/resourceGroups/rg-hyf-students-readonly", | ||
| "name": "rg-hyf-students-readonly", | ||
| "type": "Microsoft.Resources/resourceGroups", | ||
| "location": "westeurope", | ||
| "properties": { | ||
| "provisioningState": "Succeeded" | ||
| } | ||
| } | ||
| ] | ||
| } |
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.
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.
Using a for loop to execute individual INSERT statements creates a row-by-row processing which is not optimal. Every single time conn.execute() runs inside a loop, Python has to make a separate call to the SQLite database, write one row, and close the connection. While this works fine for a test file with 10 rows, this will really cause your pipeline to be extremely slow and not be scalable.
Instead, you can stage your dataset into a list of tuples and utilize
conn.executemany()!