-
Notifications
You must be signed in to change notification settings - Fork 0
From json to pqt #32
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
From json to pqt #32
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,4 +1,5 @@ | ||||||||||||||||||
| import os | ||||||||||||||||||
| from socket import timeout | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||
| from airflow.sdk import dag, task | ||||||||||||||||||
| from pendulum import datetime | ||||||||||||||||||
| from celery import Celery | ||||||||||||||||||
|
|
@@ -27,9 +28,9 @@ def run_github_data_queue(): | |||||||||||||||||
|
|
||||||||||||||||||
| @task(do_xcom_push=True, multiple_outputs=True) | ||||||||||||||||||
| def check_rate_limit(**context): | ||||||||||||||||||
| api_token, api_token_two = os.getenv("GITHUB_API_TOKEN"), os.getenv("GITHUB_API_TOKEN_SECOND_ACCOUNT") | ||||||||||||||||||
| auth, auth_two = Auth.Token(api_token), Auth.Token(api_token_two) | ||||||||||||||||||
| gh, gh_two = Github(auth=auth), Github(auth=auth_two) | ||||||||||||||||||
| api_token = os.getenv("GITHUB_API_TOKEN") | ||||||||||||||||||
| auth = Auth.Token(api_token) | ||||||||||||||||||
| gh = Github(auth=auth) | ||||||||||||||||||
|
|
||||||||||||||||||
| rate_limit = gh.rate_limiting | ||||||||||||||||||
| print(f"Rate limit: {rate_limit[0]} remaining / {rate_limit[1]} total") | ||||||||||||||||||
|
|
@@ -44,15 +45,10 @@ def run_queue(**context): | |||||||||||||||||
| rate_limit = context["ti"].xcom_pull(task_ids="check_rate_limit", key="remaining") | ||||||||||||||||||
| max_total_api_calls = context["ti"].xcom_pull(task_ids="check_rate_limit", key="total") | ||||||||||||||||||
|
Comment on lines
45
to
46
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||
|
|
||||||||||||||||||
| if rate_limit > 100: | ||||||||||||||||||
| print("IT WORKS") | ||||||||||||||||||
| print(rate_limit) | ||||||||||||||||||
|
|
||||||||||||||||||
| celery_worker = app.send_task("worker.get_github_data") | ||||||||||||||||||
| app.send_task("worker.get_github_data") | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||
|
|
||||||||||||||||||
| print(celery_worker) | ||||||||||||||||||
|
|
||||||||||||||||||
| time.sleep(500) | ||||||||||||||||||
| print("celery_worker") | ||||||||||||||||||
|
Comment on lines
+49
to
+51
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The statement
Suggested change
Comment on lines
50
to
+51
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||
|
|
||||||||||||||||||
| @task | ||||||||||||||||||
| def save_data_from_queue(): | ||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| pipeline: | ||
| inputs: | ||
| - name: dummy | ||
| tag: workshop.info | ||
| dummy: '{"message": "INFO message"}' | ||
|
|
||
| - name: dummy | ||
| tag: workshop.info | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| dummy: '{"message": "ERROR message"}' | ||
|
Comment on lines
+7
to
+9
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This dummy input generates a record with the message 'ERROR message' but tags it as - name: dummy
tag: workshop.error
dummy: '{"message": "ERROR message"}' |
||
|
|
||
| outputs: | ||
| - name: stdout | ||
| match: '*' | ||
| format: json_lines | ||
|
|
||
| - name: file | ||
| file: /data | ||
| match: '*.info' | ||
| file: workshop-INFO.log | ||
|
Comment on lines
+17
to
+19
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a duplicate path: /data
match: '*.info'
file: workshop-INFO.log
Comment on lines
+17
to
+19
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| format: json_lines | ||
|
|
||
|
|
||
|
|
||
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.
The
timeoutobject from thesocketmodule is imported but never used in this file. It's best practice to remove unused imports to keep the code clean and avoid potential confusion.