Title: Simplify Env implementation with python dataclass by fujikosu · Pull Request #276 · microsoft/MLOpsPython · GitHub
Open Graph Title: Simplify Env implementation with python dataclass by fujikosu · Pull Request #276 · microsoft/MLOpsPython
X Title: Simplify Env implementation with python dataclass by fujikosu · Pull Request #276 · microsoft/MLOpsPython
Description: Summary This PR adopts dataclass https://docs.python.org/3.7/library/dataclasses.html to Env class. With this change, no need to manually edit 2 places anymore, which are class variable assignment and property creation. One place edit covers both of property creation and variable assignment. This reduces human errors around that. Before self._workspace_name = os.environ.get("WORKSPACE_NAME") @property def workspace_name(self): return self._workspace_name After workspace_name: Optional[str] = os.environ.get("WORKSPACE_NAME") Additional benefit Type annotation added to all variables frozen=True flag makes this Env's properties immutable Singlton is deleted Singlton is deleted for implementation simplification as I didn't see much value of keeping it. Points considered were these 3 points. Object has resources that are expensive to instantiate No. Every line is just get.environment so it's super cheap to execute Object has resources that should only be instantiated once It's not harmful to instantiate env object multiple times because it's basically just loading environment variables. Cheap & safe read-only Object has resources that should only be de-provisioned when the program ends Ideally we want to keep using the same env throught the codebase but it's fine to create it again if it's lost.
Open Graph Description: Summary This PR adopts dataclass https://docs.python.org/3.7/library/dataclasses.html to Env class. With this change, no need to manually edit 2 places anymore, which are class variable assignment ...
X Description: Summary This PR adopts dataclass https://docs.python.org/3.7/library/dataclasses.html to Env class. With this change, no need to manually edit 2 places anymore, which are class variable assignment ...
Opengraph URL: https://github.com/microsoft/MLOpsPython/pull/276
X: @github
Domain: patch-diff.githubusercontent.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:8ee39462-89ed-d141-caee-3d8a9259c687 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | E99A:2C23AD:212DA9F:2C073EB:697D3F9E |
| html-safe-nonce | a590681a88c37ef7c10c25f9418164c411e5bfddba2958deb55f70c4b26a068d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOTlBOjJDMjNBRDoyMTJEQTlGOjJDMDczRUI6Njk3RDNGOUUiLCJ2aXNpdG9yX2lkIjoiMjEyMjMxOTk4NjEzODM2NTg1NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f839afaf179a15ec4b348770175e0e7dbb68014427087f4d502c444353481237 |
| hovercard-subject-tag | pull_request:420151626 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/microsoft/MLOpsPython/pull/276/files |
| twitter:image | https://avatars.githubusercontent.com/u/7400827?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/7400827?s=400&v=4 |
| og:image:alt | Summary This PR adopts dataclass https://docs.python.org/3.7/library/dataclasses.html to Env class. With this change, no need to manually edit 2 places anymore, which are class variable assignment ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 60279d4097367e16897439d16d6bbe4180663db828c666eeed2656988ffe59f6 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/microsoft/MLOpsPython git https://github.com/microsoft/MLOpsPython.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 168217581 |
| octolytics-dimension-repository_nwo | microsoft/MLOpsPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 168217581 |
| octolytics-dimension-repository_network_root_nwo | microsoft/MLOpsPython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | c2b1f969137add620c89ee43eff21bca11243467 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width