Skip to content
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

fix: ps_upload_to_ds errors before retry vary initialization and caus… #365

Merged
merged 1 commit into from
Oct 6, 2024

Conversation

aaronm-2112
Copy link
Member

@aaronm-2112 aaronm-2112 commented Oct 6, 2024

…es secondary error

Summary by Sourcery

Fix errors in the ps_upload_to_dataset function by moving the initialization of retry variables outside the function to prevent secondary errors.

Bug Fixes:

  • Fix errors in the ps_upload_to_dataset function by initializing retry variables outside the function.

@aaronm-2112 aaronm-2112 requested a review from bvhpatel as a code owner October 6, 2024 17:34
Copy link

Thank you for submitting this pull request! We appreciate your contribution to the project. Before we can merge it, we need to review the changes you've made to ensure they align with our code standards and meet the requirements of the project. We'll get back to you as soon as we can with feedback. Thanks again!

Copy link
Contributor

sourcery-ai bot commented Oct 6, 2024

Reviewer's Guide by Sourcery

This pull request addresses an issue with the ps_upload_to_dataset function in the curate.py file. The main change is the initialization of retry-related variables outside the function scope to prevent errors before retry initialization.

Class diagram for ps_upload_to_dataset function changes

classDiagram
    class Curate {
        +dict bytes_file_path_dict
        +dict list_of_files_to_rename
        +int renamed_files_counter
        +ps_upload_to_dataset(soda_json_structure, ps, ds, resume=False)
    }

    Curate : +build_create_folder_request(folder_name, folder_parent_id, dataset_id)
Loading

File-Level Changes

Change Details Files
Initialize retry-related variables outside function scope
  • Add 'list_of_files_to_rename' dictionary initialization
  • Add 'renamed_files_counter' variable initialization
  • Declare 'list_of_files_to_rename' and 'renamed_files_counter' as global variables inside the function
src/pyflask/curate/curate.py
Minor code formatting improvement
  • Remove trailing whitespace from 'global main_curate_status' line
src/pyflask/curate/curate.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @aaronm-2112 - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider the thread-safety implications of using global variables in a web application context. In the future, exploring a more object-oriented approach for state management could improve the overall design and maintainability of the code.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +1903 to +1905
# retry variables instantiated outside function
list_of_files_to_rename = {}
renamed_files_counter = 0
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Consider encapsulating retry logic instead of using global variables

Global variables for retry mechanism can lead to unexpected behavior and make the code harder to maintain. Consider using a dedicated retry handler or a context manager to encapsulate this logic.

class RetryHandler:
    def __init__(self):
        self.files_to_rename = {}
        self.renamed_files_count = 0

    def add_file(self, file):
        self.files_to_rename[file] = True

    def increment_renamed(self):
        self.renamed_files_count += 1

retry_handler = RetryHandler()

Copy link

Thanks for making updates to your pull request. Our team will take a look and provide feedback as soon as possible. Please wait for any GitHub Actions to complete before editing your pull request. If you have any additional questions or concerns, feel free to let us know. Thank you for your contributions!

Copy link

sonarqubecloud bot commented Oct 6, 2024

@aaronm-2112 aaronm-2112 merged commit 27dc9e8 into pre-staging Oct 6, 2024
6 of 11 checks passed
Copy link

Thanks for closing this pull request! If you have any further questions, please feel free to open a new issue. We are always happy to help!

@aaronm-2112 aaronm-2112 deleted the files_to_rename_bad_reference branch October 6, 2024 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant