Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added c_logging_config.py
Empty file.
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ services:
build: .
volumes:
- ./data:/app/data
command: celery -A worker worker --loglevel=info --pool=solo --concurrency=4
command: celery -A worker worker --loglevel=info --concurrency=8
env_file: ./config/.env
deploy:
deploy:
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

There is a trailing whitespace on this line. It should be removed to maintain clean formatting.

    deploy:

resources:
limits:
memory: 512M
Expand Down
Empty file added fluent-bit/fluent-bit.conf
Empty file.
22 changes: 10 additions & 12 deletions worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def get_github_data(self, start_in_repo_num: int = 0, batch_size: int = 500, git
remaining_api_calls = github_instance.rate_limiting
remaining = remaining_api_calls[0]

if int(counter) >= int(500):
if remaining_api_calls == 1:
Copy link
Contributor

Choose a reason for hiding this comment

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

security-high high

The condition if remaining_api_calls == 1: is a critical logic error. remaining_api_calls is a tuple (remaining, limit) from github_instance.rate_limiting, not an integer, so this comparison will always be False. This flaw prevents the loop from breaking, leading to an infinite loop that can cause Out-of-Memory (OOM) crashes, GitHub API rate limit abuse, and redundant processing. The current log message Reached batch size limit of {batch_size} will also be misleading in this context.

            if remaining <= 1:
            print(f"Reached rate limit threshold. Remaining: {remaining}")
            break

print(f"Reached batch size limit of {batch_size}")

break
Expand Down Expand Up @@ -178,21 +178,19 @@ def aggregate_results(results):

def build_repo_chord(total: int = 5000, batch_size: int = 500):
header = [
get_github_data.s(start, batch_size)
for start in range(0, total, batch_size)
get_github_data.s(start, batch_size) for start in range(0, total, batch_size)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

While this single-line list comprehension is valid, the previous multi-line version was more readable. For better maintainability and readability, it's often better to keep list comprehensions on multiple lines if they don't fit comfortably on one. I'd suggest reverting to the multi-line format.

        get_github_data.s(start, batch_size)
        for start in range(0, total, batch_size)

]
return chord(header)(aggregate_results.s())



# old code that did not work
@app.task
def distribute_tasks():
# @app.task
# def distribute_tasks():

jobs = group([
get_github_data.s(start, 500)
for start in range(0, 5000, 500)
])
# jobs = group([
# get_github_data.s(start, 500)
# for start in range(0, 5000, 500)
# ])

return chord(jobs)()

# return chord(jobs)()
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This line contains only whitespace and should be removed. Additionally, the file is missing a newline at the end, which is a common convention and good practice to add.

Loading