Skip to content

Conversation

@ConsoleCatzirl
Copy link
Member

Refactor the lambda into multiple submodules in preparation of adding a new API endpoint for getting the current balances. The new API endpoint will use the chart of accounts for a different segment (not "Program") and collate with data from an additional upstream API endpoint.

Also rename 'mips' to 'mip' to accurately reflect the name of the upstream service.

Refactor the lambda into multiple submodules in preparation of adding
a new API endpoint for getting the current balances.

Also rename 'mips' to 'mip' to accurately reflect the name of the
upstream service.
@ConsoleCatzirl ConsoleCatzirl requested review from a team as code owners July 21, 2025 22:50
@coveralls
Copy link
Collaborator

coveralls commented Jul 21, 2025

Coverage Status

coverage: 95.076% (-0.9%) from 95.968%
when pulling 51c5912 on ConsoleCatzirl:it-4485-refactor
into bb18342 on Sage-Bionetworks-IT:master.

return out_chart


def limit_chart(params, chart_dict):

Choose a reason for hiding this comment

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

Typically long lists are handled by pagination, i.e. the client can limit the (page) size but then it can also request later page(s) to get all the content. What's the implication of having truncation without a way to get the rest of the content?

Copy link
Member Author

Choose a reason for hiding this comment

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

Interesting, I hadn't realized that this is basically half of a pagination implementation. The use case this is supporting is truncating the chart to the first 25 entries for configuring Service Catalog tag options: https://github.com/Sage-Bionetworks-IT/organizations-infra/blob/master/sceptre/scipool/config/prod/sc-tag-options.yaml#L16

Choose a reason for hiding this comment

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

Thank you for providing more context. So it's critical here that the items in the chart are prioritized, so that if a client can only handle n items, it can say, "give me the n most important ones." (Maybe it's more analogous to string truncation than to pagination.) With this understanding I think the code is fine, but perhaps you can just add a comment like, "limit the response to the chosen number of high priority items."

@ConsoleCatzirl ConsoleCatzirl requested a review from Copilot July 25, 2025 17:56
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the lambda codebase by breaking apart a monolithic mips_api module into multiple focused submodules in preparation for adding a new API endpoint. The refactoring improves code organization and maintainability while also correcting the service name from 'mips' to 'mip' throughout the codebase.

Key changes include:

  • Splitting the single mips_api/__init__.py file into separate modules (chart.py, upstream.py, ssm.py, s3.py, util.py)
  • Renaming the package from mips_api to mip_api to accurately reflect the upstream service name
  • Adding S3 lifecycle configuration for cleaning up old object versions

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/unit/test_handler.py Updates all test imports and function calls to use the new mip_api module structure
template.yaml Changes Lambda handler reference and adds S3 lifecycle policy for version cleanup
mips_api/init.py Removes the original monolithic module (543 lines deleted)
mip_api/util.py New utility module containing helper functions for parameter parsing and validation
mip_api/upstream.py New module handling all upstream API interactions with MIP Cloud
mip_api/ssm.py New module for AWS Systems Manager parameter retrieval
mip_api/s3.py New module for S3 cache operations
mip_api/chart.py New module for chart of accounts processing and business logic
mip_api/init.py New main module containing only the Lambda handler function
.github/workflows/test.yaml Removes pre-commit job from the workflow
.coveragerc Updates source path to use new mip_api module name
Comments suppressed due to low confidence (1)

mip_api/util.py:50

  • [nitpick] The variable 'number' is not descriptive. Consider renaming to 'limit_value' or 'parsed_limit' to better indicate its purpose.
            number = int(params["limit"])

@ConsoleCatzirl ConsoleCatzirl force-pushed the it-4485-refactor branch 2 times, most recently from 4fcf125 to 49bb9b3 Compare July 25, 2025 18:45
@ConsoleCatzirl ConsoleCatzirl requested a review from brucehoff July 25, 2025 20:30
Copy link

@brucehoff brucehoff left a comment

Choose a reason for hiding this comment

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

I left one follow up suggestion (documentation) but I don't think that should hold up approving.

@ConsoleCatzirl ConsoleCatzirl merged commit 0b660f4 into Sage-Bionetworks-IT:master Jul 28, 2025
4 of 5 checks passed
@ConsoleCatzirl ConsoleCatzirl deleted the it-4485-refactor branch July 28, 2025 23:03
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.

3 participants