Skip to content

Abstract SamConfig#5203

Closed
Leo10Gama wants to merge 29 commits intoaws:feat/config-filesfrom
Leo10Gama:abstract-config
Closed

Abstract SamConfig#5203
Leo10Gama wants to merge 29 commits intoaws:feat/config-filesfrom
Leo10Gama:abstract-config

Conversation

@Leo10Gama
Copy link
Contributor

Why is this change necessary?

This change decouples the logic of reading/writing TOML documents from the SamConfig class, allowing for the future implementation of additional samconfig file types. It also allows the class to better follow the Single Responsibility Principle, as it handles the logic of storing and representing the config data, rather than also implementing the reading and writing.

How does it address the issue?

The SamConfig has been changed such that document is now no longer a TOML document, but a dictionary object, making it easier to interface with. In addition, two new classes, the abstract FileManager and concrete child TomlFileManager have been created to handle the logic of reading and writing to TOML files.

What side effects does this change have?

The SamConfig class now more accurately represents and encapsulates solely the configuration options, and any reading and writing to TOML files has now been generalized to a designated FileManager, assigned based on the provided filename, and set to be TOML by default to ensure backwards compatibility.

Mandatory Checklist

PRs will only be reviewed after checklist is complete

  • Add input/output type hints to new functions/methods
  • Write design document if needed (Do I need to write a design document?)
  • Write/update unit tests
  • Write/update integration tests
  • Write/update functional tests if needed
  • make pr passes
  • make update-reproducible-reqs if dependencies were changed
  • Write documentation

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Leo10Gama and others added 26 commits June 7, 2022 11:05
* Implement project metadata metrics

* Implement metric metadata integration tests

* Tweak methods so tests don't fail on Linux machines

* Repair failing integration test

* Implement proper exception handling for subprocesses

* Format according to standard

* Refactor function names and encryption logic

* Remove unnecessary file

* Add type hints to new functions
* Implement event data structure and relevant unit tests

* Implement requested changes

* Remove unused (useless) file

* Remove unnecessary ABC class
* Implement tracker methods

* Improve readability of Event's __repr__ method

* Add method to convert Event to dictionary for JSON-compatibility
* Send Event metrics via Telemetry

* Add unit tests for event telemetry

* Simplify event telemetry unit tests

* Clean up unit tests
* Add BuildRuntime Events

* Remove unnecessary file

* Prevent tracked Event 'spillage' from previous tests

* Fix builder logic

* Redefine BuildRuntime to focus on function runtimes

* Remove unnecessary file (again)
* Add UsedFeature command and trackers

* Remove LocalTest events
Events regarding sam local will be implemented at a later time.

* Prevent methods from failing if track_event fails

* Reformat code to match current standard

* Use correct string formatting

* Use proper LOG message
* Add thread lock to EventTracker

* Place lock in appropriate methods
* Add new attributes to Event datastructure

* Fix non-JSON-serializable field in Event

* Fix repr to ensure SQL casting will work

* Add comment for timestamp method clarity
* Add framework for Event-sending method

* Perform some general refactors and cleanup

* Implement EventTracker Telemetry unit tests

* Cleanup tests and unused imports

* Update Metric name for consistency

* Repair failing unit test

* (Hopefully) repair broken integration test

* *Actually* repair broken integration test
I had the >= logic backwards lol

* Fix integration test
For sure this time

* Really fix the integration test
Windows development is not fun

* Properly fix integration test

* Reformat files

* Implement requested changes

* Add Lock logic to send_events method

* Implement requested changes

* Repair failing tests
* Upgrade encryption algorithm from SHA1 to SHA256

* Make return value of hash JSON-serializable
* Switch send_events to thread when at capacity

* Repair failing unit test
* Add sam sync Events

* Refactor methods for tracking sync events

* Improve SyncFlow tracking

* Add additional SyncFlow value
Merge `develop` into `customer-journey`
* Add workflow_config events

* Refactor workflow Events

* Add tests for verifying workflow events

* Remove redundant (UsedFeature, ESBuild) event

* Repair failing unit test

* Rename workflow event to prevent ambiguity
* Apply minor changes (some major)

* Add session_id for multithreaded send_events

* Adjust tests for new multithreading

* Fix failing integration test

* *Actually* fix failing integration test

* Properly fix integration test

* This time for sure

* Really really repair that test

* OK this one SHOULD work I swear

* This time for sure

* FIX INTEGRATION TEST

* IT'S A LIST

* Remove unused imports

* Add debug log for EventTracker session ID

* Place debug log in better position
@github-actions github-actions bot added area/build sam build command area/deploy sam deploy command pr/external stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels May 25, 2023
@moelasmar moelasmar added pr/internal and removed stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. pr/external labels May 26, 2023
@lucashuy
Copy link
Contributor

Superseded by #5208

@lucashuy lucashuy closed this May 26, 2023
@Leo10Gama Leo10Gama deleted the abstract-config branch June 5, 2023 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/build sam build command area/deploy sam deploy command pr/internal

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants