fairdataihub / SODA-for-SPARC

Simplifying data curation for researchers funded by the NIH SPARC initiative
https://fairdataihub.org/sodaforsparc
MIT License
28 stars 9 forks source link

fix: SODA-Pennsieve key in config.ini becomes default if it exists and is broken #363

Closed aaronm-2112 closed 1 month ago

aaronm-2112 commented 1 month ago

Summary by Sourcery

Fix the handling of the SODA-Pennsieve key in the configuration to ensure it becomes the default if it exists and is broken, by adjusting the order of checks in the account retrieval logic.

Bug Fixes:

fairdataihub-bot[bot] commented 1 month ago

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!

sourcery-ai[bot] commented 1 month ago

Reviewer's Guide by Sourcery

This pull request modifies the authentication process in the SODA-Pennsieve application. It changes the order of checking for authentication credentials and fixes a bug in the lowercase conversion of account names.

Sequence diagram for the updated authentication process

sequenceDiagram
    participant User
    participant Application
    participant Config
    participant Logger

    User->>Application: Request authentication
    Application->>Config: Check 'global' section
    alt Global section exists
        Config->>Application: Return default profile
        Application->>Config: Check default profile
        alt Default profile valid
            Application->>Config: Get access token
            Application->>User: Return default profile
        else Default profile invalid
            Application->>Logger: Log authentication failure
            Application->>User: Return error
        end
    else Global section does not exist
        Application->>Config: Check SODA_SPARC_API_KEY section
        alt SODA_SPARC_API_KEY exists
            Application->>Config: Lowercase account names
            Application->>Config: Get access token
            Application->>User: Return SODA_SPARC_API_KEY
        else SODA_SPARC_API_KEY does not exist
            Application->>Logger: Log no default account
            Application->>User: Return error
        end
    end

Updated class diagram for config management

classDiagram
    class Config {
        +sections()
        +add_section(sectionName)
        +set(sectionName, option, value)
        +get(sectionName, option)
    }

    class ManageDatasets {
        +bf_get_accounts()
    }

    Config <.. ManageDatasets : uses

    class Logger {
        +info(message)
    }

    ManageDatasets <.. Logger : logs to

    class Contextlib {
        +suppress(Exception)
    }

    ManageDatasets <.. Contextlib : uses

    class Account {
        +lowercase_account_names(config, account_name, configpath)
    }

    Config <.. Account : modifies

    ManageDatasets <.. Account : uses

File-Level Changes

Change Details Files
Reordered authentication checks to prioritize the 'global' section over SODA_SPARC_API_KEY
  • Moved the check for 'global' section before SODA_SPARC_API_KEY
  • Removed the immediate return if SODA_SPARC_API_KEY is found
  • Added SODA_SPARC_API_KEY check as an else-if condition
src/pyflask/manageDatasets/manage_datasets.py
Fixed a bug in the lowercase conversion of account names
  • Changed the source of api_token and api_secret to use the original account_name instead of the formatted_account_name
src/pyflask/configUtils/config.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. #### Customizing Your Experience Access your [dashboard](https://app.sourcery.ai) 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 - [Contact our support team](mailto:support@sourcery.ai) for questions or feedback. - Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information. - Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).
fairdataihub-bot[bot] commented 1 month ago

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!

sonarcloud[bot] commented 1 month ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

fairdataihub-bot[bot] commented 1 month ago

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!