From aeca229222849e0de95704596d16108441f1d72d Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Thu, 18 Jan 2024 23:02:34 -0300 Subject: [PATCH 1/6] chore: remove empty flagsmith provider Signed-off-by: Federico Bond --- openfeature/contrib/providers/flagsmith/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 openfeature/contrib/providers/flagsmith/__init__.py diff --git a/openfeature/contrib/providers/flagsmith/__init__.py b/openfeature/contrib/providers/flagsmith/__init__.py deleted file mode 100644 index e69de29b..00000000 From afcbdfbb7222291eb6b52e349334ff19646646b3 Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Thu, 18 Jan 2024 23:50:44 -0300 Subject: [PATCH 2/6] chore: reorganize repo for multiple packages Signed-off-by: Federico Bond --- .github/workflows/build.yml | 14 +- .gitmodules | 2 +- README.md | 4 +- hooks/README.md | 4 + hooks/openfeature-hooks-opentelemetry/LICENSE | 201 ++++++++++++++++++ .../README.md | 23 +- .../contrib/hooks/opentelemetry/__init__.py | 3 +- .../pyproject.toml | 28 +++ .../tests}/__init__.py | 0 .../tests}/test_otel.py | 2 +- openfeature/contrib/providers/__init__.py | 0 .../contrib/providers => providers}/README.md | 0 providers/openfeature-provider-flagd/LICENSE | 201 ++++++++++++++++++ .../openfeature-provider-flagd/README.md | 35 +++ .../contrib/provider}/flagd/__init__.py | 0 .../contrib/provider}/flagd/defaults.py | 0 .../contrib/provider}/flagd/flag_type.py | 0 .../contrib/provider}/flagd/provider.py | 0 .../openfeature-provider-flagd/pyproject.toml | 31 +++ .../openfeature-provider-flagd/schemas | 0 .../tests}/__init__.py | 0 .../tests}/conftest.py | 2 +- .../tests}/test_flagd.py | 2 +- pyproject.toml | 79 ------- ruff.toml | 54 +++++ tests/__init__.py | 0 tests/hooks/__init__.py | 0 tests/providers/__init__.py | 0 28 files changed, 579 insertions(+), 106 deletions(-) create mode 100644 hooks/README.md create mode 100644 hooks/openfeature-hooks-opentelemetry/LICENSE rename {openfeature/contrib/hooks => hooks/openfeature-hooks-opentelemetry}/README.md (82%) rename openfeature/contrib/hooks/otel.py => hooks/openfeature-hooks-opentelemetry/openfeature/contrib/hooks/opentelemetry/__init__.py (99%) create mode 100644 hooks/openfeature-hooks-opentelemetry/pyproject.toml rename {openfeature/contrib => hooks/openfeature-hooks-opentelemetry/tests}/__init__.py (100%) rename {tests/hooks => hooks/openfeature-hooks-opentelemetry/tests}/test_otel.py (96%) delete mode 100644 openfeature/contrib/providers/__init__.py rename {openfeature/contrib/providers => providers}/README.md (100%) create mode 100644 providers/openfeature-provider-flagd/LICENSE create mode 100644 providers/openfeature-provider-flagd/README.md rename {openfeature/contrib/providers => providers/openfeature-provider-flagd/openfeature/contrib/provider}/flagd/__init__.py (100%) rename {openfeature/contrib/providers => providers/openfeature-provider-flagd/openfeature/contrib/provider}/flagd/defaults.py (100%) rename {openfeature/contrib/providers => providers/openfeature-provider-flagd/openfeature/contrib/provider}/flagd/flag_type.py (100%) rename {openfeature/contrib/providers => providers/openfeature-provider-flagd/openfeature/contrib/provider}/flagd/provider.py (100%) create mode 100644 providers/openfeature-provider-flagd/pyproject.toml rename schemas => providers/openfeature-provider-flagd/schemas (100%) rename {openfeature/contrib/hooks => providers/openfeature-provider-flagd/tests}/__init__.py (100%) rename {tests/providers => providers/openfeature-provider-flagd/tests}/conftest.py (71%) rename {tests/providers => providers/openfeature-provider-flagd/tests}/test_flagd.py (96%) delete mode 100644 pyproject.toml create mode 100644 ruff.toml delete mode 100644 tests/__init__.py delete mode 100644 tests/hooks/__init__.py delete mode 100644 tests/providers/__init__.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index eac1a186..a6cbfeef 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,21 +39,13 @@ jobs: github_token: ${{ github.token }} - name: Install dependencies - run: pip install -r requirements.txt + run: make venv - name: Generate flagd protobuf files - run: | - cd schemas - buf generate buf.build/open-feature/flagd --template protobuf/buf.gen.python.yaml - cd ../ - rm -rf openfeature/contrib/providers/flagd/proto - mv proto/python openfeature/contrib/providers/flagd/proto - sed -i.bak 's/^from schema.v1 import/from . import/' openfeature/contrib/providers/flagd/proto/schema/v1/*.py - rm openfeature/contrib/providers/flagd/proto/schema/v1/*.bak - rmdir proto + run: make grpc - name: Test with pytest - run: coverage run --omit="*/test*" -m pytest + run: make testcov - name: Upload coverage to Codecov uses: codecov/codecov-action@e0fbd592d323cb2991fb586fdd260734fcb41fcb diff --git a/.gitmodules b/.gitmodules index 17f09c4d..0a552e2f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "schemas"] - path = schemas + path = providers/openfeature-provider-flagd/schemas url = https://github.com/open-feature/schemas diff --git a/README.md b/README.md index 56df6692..9e8cfac4 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,8 @@ This repository is intended for OpenFeature contributions which are not included The project includes: -- [Providers](./openfeature/contrib/providers) -- [Hooks](./openfeature/contrib/hooks) +- [Providers](./providers) +- [Hooks](./hooks) ## License diff --git a/hooks/README.md b/hooks/README.md new file mode 100644 index 00000000..70f53f6f --- /dev/null +++ b/hooks/README.md @@ -0,0 +1,4 @@ +# OpenFeature Python Hooks +Hooks are a mechanism whereby application developers can add arbitrary behavior to flag evaluation. +They operate similarly to middleware in many web frameworks. Please see the +[spec](https://openfeature.dev/specification/sections/hooks) for more details. diff --git a/hooks/openfeature-hooks-opentelemetry/LICENSE b/hooks/openfeature-hooks-opentelemetry/LICENSE new file mode 100644 index 00000000..1ef7dad2 --- /dev/null +++ b/hooks/openfeature-hooks-opentelemetry/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright The OpenTelemetry Authors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/openfeature/contrib/hooks/README.md b/hooks/openfeature-hooks-opentelemetry/README.md similarity index 82% rename from openfeature/contrib/hooks/README.md rename to hooks/openfeature-hooks-opentelemetry/README.md index 21b06ecf..6b2d28db 100644 --- a/openfeature/contrib/hooks/README.md +++ b/hooks/openfeature-hooks-opentelemetry/README.md @@ -1,19 +1,22 @@ -# OpenFeature Python Hooks -Hooks are a mechanism whereby application developers can add arbitrary behavior to flag evaluation. -They operate similarly to middleware in many web frameworks. Please see the -[spec](https://openfeature.dev/specification/sections/hooks) for more details. -## OpenTelemetry Hook +# OpenTelemetry Hook The OpenTelemetry tracing hook for OpenFeature provides a [spec compliant][otel-spec] way to automatically add a feature flag evaluation to a span as a span event. Since feature flags are dynamic and affect runtime behavior, it’s important to collect relevant feature flag telemetry signals. This can be used to determine the impact a feature has on a request, enabling enhanced observability use cases, such as A/B testing or progressive feature releases. -### Usage +## Installation + +``` +pip install openfeature-hooks-opentelemetry +``` + + +## Usage OpenFeature provides various ways to register hooks. The location that a hook is registered affects when the hook is run. It's recommended to register the `TracingHook` globally in most situations but it's possible to only enable the hook on specific clients. You should **never** register the `TracingHook` globally and on a client. More information on hooks can be found in the [OpenFeature documentation][hook-concept]. -#### Register Globally +### Register Globally The `TracingHook` can be set on the OpenFeature singleton. This will ensure that every flag evaluation will always create a span event, if am active span is available. @@ -24,7 +27,7 @@ from openfeature.contrib.hooks.otel import TracingHook api.add_hooks(TracingHook()) ``` -#### Register Per Client +### Register Per Client The `TracingHook` can be set on an individual client. This should only be done if it wasn't set globally and other clients shouldn't use this hook. Setting the hook on the client will ensure that every flag evaluation performed by this client will always create a span event, if an active span is available. @@ -35,3 +38,7 @@ from openfeature.contrib.hooks.otel import TracingHook client = api.get_client("my-app") client.add_hooks(TracingHook()) ``` + +## License + +Apache 2.0 - See [LICENSE](./LICENSE) for more information. diff --git a/openfeature/contrib/hooks/otel.py b/hooks/openfeature-hooks-opentelemetry/openfeature/contrib/hooks/opentelemetry/__init__.py similarity index 99% rename from openfeature/contrib/hooks/otel.py rename to hooks/openfeature-hooks-opentelemetry/openfeature/contrib/hooks/opentelemetry/__init__.py index 6af5eac4..083df5dd 100644 --- a/openfeature/contrib/hooks/otel.py +++ b/hooks/openfeature-hooks-opentelemetry/openfeature/contrib/hooks/opentelemetry/__init__.py @@ -1,9 +1,8 @@ import json -from opentelemetry import trace - from openfeature.flag_evaluation import FlagEvaluationDetails from openfeature.hook import Hook, HookContext +from opentelemetry import trace OTEL_EVENT_NAME = "feature_flag" diff --git a/hooks/openfeature-hooks-opentelemetry/pyproject.toml b/hooks/openfeature-hooks-opentelemetry/pyproject.toml new file mode 100644 index 00000000..b1d127ba --- /dev/null +++ b/hooks/openfeature-hooks-opentelemetry/pyproject.toml @@ -0,0 +1,28 @@ +# pyproject.toml +[build-system] +requires = ["setuptools>=61.0.0", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "openfeature-hooks-opentelemetry" +version = "0.1.0" +description = "OpenTelemetry hooks for the OpenFeature Python SDK" +readme = "readme.md" +authors = [{ name = "OpenFeature", email = "openfeature-core@groups.io" }] +license = { file = "LICENSE" } +classifiers = [ + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", +] +keywords = [] +dependencies = [] +requires-python = ">=3.8" + +[project.optional-dependencies] +tests = [ + 'pytest', +] + +[project.urls] +Homepage = "https://github.com/open-feature/python-sdk-contrib" diff --git a/openfeature/contrib/__init__.py b/hooks/openfeature-hooks-opentelemetry/tests/__init__.py similarity index 100% rename from openfeature/contrib/__init__.py rename to hooks/openfeature-hooks-opentelemetry/tests/__init__.py diff --git a/tests/hooks/test_otel.py b/hooks/openfeature-hooks-opentelemetry/tests/test_otel.py similarity index 96% rename from tests/hooks/test_otel.py rename to hooks/openfeature-hooks-opentelemetry/tests/test_otel.py index 233f5560..cebcb596 100644 --- a/tests/hooks/test_otel.py +++ b/hooks/openfeature-hooks-opentelemetry/tests/test_otel.py @@ -4,7 +4,7 @@ from opentelemetry import trace from opentelemetry.trace import Span -from openfeature.contrib.hooks.otel import TracingHook +from openfeature.contrib.hooks.opentelemetry import TracingHook from openfeature.evaluation_context import EvaluationContext from openfeature.flag_evaluation import FlagEvaluationDetails, FlagType from openfeature.hook import HookContext diff --git a/openfeature/contrib/providers/__init__.py b/openfeature/contrib/providers/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/openfeature/contrib/providers/README.md b/providers/README.md similarity index 100% rename from openfeature/contrib/providers/README.md rename to providers/README.md diff --git a/providers/openfeature-provider-flagd/LICENSE b/providers/openfeature-provider-flagd/LICENSE new file mode 100644 index 00000000..1ef7dad2 --- /dev/null +++ b/providers/openfeature-provider-flagd/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright The OpenTelemetry Authors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/providers/openfeature-provider-flagd/README.md b/providers/openfeature-provider-flagd/README.md new file mode 100644 index 00000000..3b76cff9 --- /dev/null +++ b/providers/openfeature-provider-flagd/README.md @@ -0,0 +1,35 @@ +# flagd Provider for OpenFeature + +This provider is designed to use flagd's [evaluation protocol](https://github.com/open-feature/schemas/blob/main/protobuf/schema/v1/schema.proto), or locally evaluate flags defined in a flagd [flag definition](https://github.com/open-feature/schemas/blob/main/json/flagd-definitions.json). + +## Installation + +``` +pip install openfeature-provider-flagd +``` + +## Configuration and Usage + +Instantiate a new FlagdProvider instance and configure the OpenFeature SDK to use it: + +```python +from openfeature import api +from openfeature.contrib.provider.flagd import FlagdProvider + +api.set_provider(FlagdProvider()) +``` + +### Configuration options + +The default options can be defined in the FlagdProvider constructor. + +| Option name | Type & Values | Default | +|----------------|---------------|-----------| +| host | str | localhost | +| port | int | 8013 | +| schema | str | http | +| timeout | int | 2 | + +## License + +Apache 2.0 - See [LICENSE](./LICENSE) for more information. diff --git a/openfeature/contrib/providers/flagd/__init__.py b/providers/openfeature-provider-flagd/openfeature/contrib/provider/flagd/__init__.py similarity index 100% rename from openfeature/contrib/providers/flagd/__init__.py rename to providers/openfeature-provider-flagd/openfeature/contrib/provider/flagd/__init__.py diff --git a/openfeature/contrib/providers/flagd/defaults.py b/providers/openfeature-provider-flagd/openfeature/contrib/provider/flagd/defaults.py similarity index 100% rename from openfeature/contrib/providers/flagd/defaults.py rename to providers/openfeature-provider-flagd/openfeature/contrib/provider/flagd/defaults.py diff --git a/openfeature/contrib/providers/flagd/flag_type.py b/providers/openfeature-provider-flagd/openfeature/contrib/provider/flagd/flag_type.py similarity index 100% rename from openfeature/contrib/providers/flagd/flag_type.py rename to providers/openfeature-provider-flagd/openfeature/contrib/provider/flagd/flag_type.py diff --git a/openfeature/contrib/providers/flagd/provider.py b/providers/openfeature-provider-flagd/openfeature/contrib/provider/flagd/provider.py similarity index 100% rename from openfeature/contrib/providers/flagd/provider.py rename to providers/openfeature-provider-flagd/openfeature/contrib/provider/flagd/provider.py diff --git a/providers/openfeature-provider-flagd/pyproject.toml b/providers/openfeature-provider-flagd/pyproject.toml new file mode 100644 index 00000000..c1a720f6 --- /dev/null +++ b/providers/openfeature-provider-flagd/pyproject.toml @@ -0,0 +1,31 @@ +# pyproject.toml +[build-system] +requires = ["setuptools>=61.0.0", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "openfeature-provider-flagd" +version = "0.1.0" +description = "OpenFeature provider for the flagd flag evaluation engine" +readme = "readme.md" +authors = [{ name = "OpenFeature", email = "openfeature-core@groups.io" }] +license = { file = "LICENSE" } +classifiers = [ + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", +] +keywords = [] +dependencies = [] +requires-python = ">=3.8" + +[project.optional-dependencies] +tests = [ + 'pytest', +] + +[project.urls] +Homepage = "https://github.com/open-feature/python-sdk-contrib" + +[tool.setuptools.packages.find] +exclude = ["schemas"] diff --git a/schemas b/providers/openfeature-provider-flagd/schemas similarity index 100% rename from schemas rename to providers/openfeature-provider-flagd/schemas diff --git a/openfeature/contrib/hooks/__init__.py b/providers/openfeature-provider-flagd/tests/__init__.py similarity index 100% rename from openfeature/contrib/hooks/__init__.py rename to providers/openfeature-provider-flagd/tests/__init__.py diff --git a/tests/providers/conftest.py b/providers/openfeature-provider-flagd/tests/conftest.py similarity index 71% rename from tests/providers/conftest.py rename to providers/openfeature-provider-flagd/tests/conftest.py index 63f5eb96..cdf4bf59 100644 --- a/tests/providers/conftest.py +++ b/providers/openfeature-provider-flagd/tests/conftest.py @@ -1,7 +1,7 @@ import pytest from openfeature import api -from openfeature.contrib.providers.flagd import FlagdProvider +from openfeature.contrib.provider.flagd import FlagdProvider @pytest.fixture() diff --git a/tests/providers/test_flagd.py b/providers/openfeature-provider-flagd/tests/test_flagd.py similarity index 96% rename from tests/providers/test_flagd.py rename to providers/openfeature-provider-flagd/tests/test_flagd.py index db51719f..402abe74 100644 --- a/tests/providers/test_flagd.py +++ b/providers/openfeature-provider-flagd/tests/test_flagd.py @@ -1,7 +1,7 @@ from numbers import Number from openfeature import api -from openfeature.contrib.providers.flagd import FlagdProvider +from openfeature.contrib.provider.flagd import FlagdProvider def setup(): diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index f0440a6f..00000000 --- a/pyproject.toml +++ /dev/null @@ -1,79 +0,0 @@ -# pyproject.toml -[build-system] -requires = ["setuptools>=61.0.0", "wheel"] -build-backend = "setuptools.build_meta" - -[project] -name = "openfeature_sdk_contrib" -version = "0.1.0" -description = "Contributions around the Python OpenFeature SDK, such as providers and hooks" -readme = "readme.md" -authors = [{ name = "OpenFeature", email = "openfeature-core@groups.io" }] -license = { file = "LICENSE" } -classifiers = [ - "License :: OSI Approved :: Apache Software License", - "Programming Language :: Python", - "Programming Language :: Python :: 3", -] -keywords = [] -dependencies = [] -requires-python = ">=3.8" - -[project.optional-dependencies] -dev = ["pip-tools", "pytest", "pre-commit"] - -[project.urls] -Homepage = "https://github.com/open-feature/python-sdk-contrib" - -[tool.ruff] -exclude = [ - ".git", - ".venv", - "__pycache__", - "venv", - "openfeature/contrib/providers/flagd/proto/*" -] -target-version = "py38" - -[tool.ruff.lint] -select = [ - "A", - "B", - "C4", - "C90", - "E", - "F", - "FLY", - "FURB", - "I", - "LOG", - "N", - "PERF", - "PGH", - "PLC", - "PLR0913", - "PLR0915", - "RUF", - "S", - "SIM", - "T10", - "T20", - "UP", - "W", - "YTT", -] -ignore = [ - "E501", # the formatter will handle any too long line -] -preview = true - -[tool.ruff.lint.per-file-ignores] -"tests/**/*" = ["S101"] - -[tool.ruff.lint.pylint] -max-args = 6 -max-statements = 30 - -[tool.ruff.lint.pyupgrade] -# Preserve types, even if a file imports `from __future__ import annotations`. -keep-runtime-typing = true diff --git a/ruff.toml b/ruff.toml new file mode 100644 index 00000000..3b3c4e88 --- /dev/null +++ b/ruff.toml @@ -0,0 +1,54 @@ +exclude = [ + ".git", + ".venv", + "__pycache__", + "venv", + "openfeature/contrib/providers/flagd/proto/*" +] +target-version = "py38" + +[lint] +select = [ + "A", + "B", + "C4", + "C90", + "E", + "F", + "FLY", + "FURB", + "I", + "LOG", + "N", + "PERF", + "PGH", + "PLC", + "PLR0913", + "PLR0915", + "RUF", + "S", + "SIM", + "T10", + "T20", + "UP", + "W", + "YTT", +] +ignore = [ + "E501", # the formatter will handle any too long line +] +preview = true + +[lint.isort] +known-first-party = ["openfeature"] + +[lint.per-file-ignores] +"**/tests/**/*" = ["S101"] + +[lint.pylint] +max-args = 6 +max-statements = 30 + +[lint.pyupgrade] +# Preserve types, even if a file imports `from __future__ import annotations`. +keep-runtime-typing = true diff --git a/tests/__init__.py b/tests/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/hooks/__init__.py b/tests/hooks/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/providers/__init__.py b/tests/providers/__init__.py deleted file mode 100644 index e69de29b..00000000 From 3af6ab59349d55d284980cadd466a0997a205a3b Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Sat, 20 Jan 2024 01:05:47 -0300 Subject: [PATCH 3/6] chore: continue migrating to hatch Signed-off-by: Federico Bond --- .github/workflows/build.yml | 16 +++--- .../pyproject.toml | 43 ++++++++++++---- .../contrib/hooks/opentelemetry/__init__.py | 0 .../openfeature-provider-flagd/pyproject.toml | 49 ++++++++++++++----- .../scripts/gen_protos.sh | 10 ++++ .../contrib/provider/flagd/__init__.py | 0 .../contrib/provider/flagd/defaults.py | 0 .../contrib/provider/flagd/flag_type.py | 0 .../contrib/provider/flagd/provider.py | 0 9 files changed, 91 insertions(+), 27 deletions(-) rename hooks/openfeature-hooks-opentelemetry/{ => src}/openfeature/contrib/hooks/opentelemetry/__init__.py (100%) create mode 100755 providers/openfeature-provider-flagd/scripts/gen_protos.sh rename providers/openfeature-provider-flagd/{ => src}/openfeature/contrib/provider/flagd/__init__.py (100%) rename providers/openfeature-provider-flagd/{ => src}/openfeature/contrib/provider/flagd/defaults.py (100%) rename providers/openfeature-provider-flagd/{ => src}/openfeature/contrib/provider/flagd/flag_type.py (100%) rename providers/openfeature-provider-flagd/{ => src}/openfeature/contrib/provider/flagd/provider.py (100%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a6cbfeef..79688937 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,6 +22,9 @@ jobs: strategy: matrix: python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + package: + - "hooks/openfeature-hooks-opentelemetry" + - "providers/openfeature-provider-flagd" steps: - uses: actions/checkout@v4 @@ -38,20 +41,19 @@ jobs: with: github_token: ${{ github.token }} - - name: Install dependencies - run: make venv - - - name: Generate flagd protobuf files - run: make grpc + - name: Install hatch + run: pip install hatch - name: Test with pytest - run: make testcov + run: hatch run cov + working-directory: ${{ matrix.package }} - name: Upload coverage to Codecov - uses: codecov/codecov-action@e0fbd592d323cb2991fb586fdd260734fcb41fcb + uses: codecov/codecov-action@v3 with: flags: unittests # optional name: coverage # optional + directory: ${{ matrix.package }} fail_ci_if_error: true # optional (default = false) verbose: true # optional (default = false) diff --git a/hooks/openfeature-hooks-opentelemetry/pyproject.toml b/hooks/openfeature-hooks-opentelemetry/pyproject.toml index b1d127ba..ad4efa00 100644 --- a/hooks/openfeature-hooks-opentelemetry/pyproject.toml +++ b/hooks/openfeature-hooks-opentelemetry/pyproject.toml @@ -1,13 +1,13 @@ # pyproject.toml [build-system] -requires = ["setuptools>=61.0.0", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["hatchling"] +build-backend = "hatchling.build" [project] name = "openfeature-hooks-opentelemetry" version = "0.1.0" description = "OpenTelemetry hooks for the OpenFeature Python SDK" -readme = "readme.md" +readme = "README.md" authors = [{ name = "OpenFeature", email = "openfeature-core@groups.io" }] license = { file = "LICENSE" } classifiers = [ @@ -16,13 +16,38 @@ classifiers = [ "Programming Language :: Python :: 3", ] keywords = [] -dependencies = [] -requires-python = ">=3.8" - -[project.optional-dependencies] -tests = [ - 'pytest', +dependencies = [ + "openfeature-sdk>=0.4.0", + "opentelemetry-api", ] +requires-python = ">=3.8" [project.urls] Homepage = "https://github.com/open-feature/python-sdk-contrib" + +[tool.hatch] + +[tool.hatch.envs.default] +dependencies = [ + "coverage[toml]>=6.5", + "pytest", +] + +[tool.hatch.envs.default.scripts] +test = "pytest {args:tests}" +test-cov = "coverage run -m pytest {args:tests}" +cov-report = [ + "coverage xml", +] +cov = [ + "test-cov", + "cov-report", +] + +[tool.hatch.build.targets.sdist] +exclude = [ + ".gitignore", +] + +[tool.hatch.build.targets.wheel] +packages = ["src/openfeature"] diff --git a/hooks/openfeature-hooks-opentelemetry/openfeature/contrib/hooks/opentelemetry/__init__.py b/hooks/openfeature-hooks-opentelemetry/src/openfeature/contrib/hooks/opentelemetry/__init__.py similarity index 100% rename from hooks/openfeature-hooks-opentelemetry/openfeature/contrib/hooks/opentelemetry/__init__.py rename to hooks/openfeature-hooks-opentelemetry/src/openfeature/contrib/hooks/opentelemetry/__init__.py diff --git a/providers/openfeature-provider-flagd/pyproject.toml b/providers/openfeature-provider-flagd/pyproject.toml index c1a720f6..bd4cbe6a 100644 --- a/providers/openfeature-provider-flagd/pyproject.toml +++ b/providers/openfeature-provider-flagd/pyproject.toml @@ -1,13 +1,13 @@ # pyproject.toml [build-system] -requires = ["setuptools>=61.0.0", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["hatchling"] +build-backend = "hatchling.build" [project] name = "openfeature-provider-flagd" version = "0.1.0" description = "OpenFeature provider for the flagd flag evaluation engine" -readme = "readme.md" +readme = "README.md" authors = [{ name = "OpenFeature", email = "openfeature-core@groups.io" }] license = { file = "LICENSE" } classifiers = [ @@ -16,16 +16,43 @@ classifiers = [ "Programming Language :: Python :: 3", ] keywords = [] -dependencies = [] -requires-python = ">=3.8" - -[project.optional-dependencies] -tests = [ - 'pytest', +dependencies = [ + "openfeature-sdk>=0.4.0", + "grpcio>=1.60.0", + "protobuf>=4.25.2", ] +requires-python = ">=3.8" [project.urls] Homepage = "https://github.com/open-feature/python-sdk-contrib" -[tool.setuptools.packages.find] -exclude = ["schemas"] +[tool.hatch] + +[tool.hatch.envs.default] +dependencies = [ + "coverage[toml]>=6.5", + "pytest", +] +post-install-commands = [ + "./scripts/gen_protos.sh" +] + +[tool.hatch.envs.default.scripts] +test = "pytest {args:tests}" +test-cov = "coverage run -m pytest {args:tests}" +cov-report = [ + "coverage xml", +] +cov = [ + "test-cov", + "cov-report", +] + +[tool.hatch.build.targets.sdist] +exclude = [ + ".gitignore", + "schemas", +] + +[tool.hatch.build.targets.wheel] +packages = ["src/openfeature"] diff --git a/providers/openfeature-provider-flagd/scripts/gen_protos.sh b/providers/openfeature-provider-flagd/scripts/gen_protos.sh new file mode 100755 index 00000000..5c7c5fb2 --- /dev/null +++ b/providers/openfeature-provider-flagd/scripts/gen_protos.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +set -e + +buf generate buf.build/open-feature/flagd --template schemas/protobuf/buf.gen.python.yaml --output schemas +rm -rf openfeature/contrib/provider/flagd/proto +sed -i.bak 's/^from schema.v1 import/from . import/' proto/python/schema/v1/*.py +rm proto/python/schema/v1/*.bak +mv proto/python src/openfeature/contrib/provider/flagd/proto +rmdir proto diff --git a/providers/openfeature-provider-flagd/openfeature/contrib/provider/flagd/__init__.py b/providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/__init__.py similarity index 100% rename from providers/openfeature-provider-flagd/openfeature/contrib/provider/flagd/__init__.py rename to providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/__init__.py diff --git a/providers/openfeature-provider-flagd/openfeature/contrib/provider/flagd/defaults.py b/providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/defaults.py similarity index 100% rename from providers/openfeature-provider-flagd/openfeature/contrib/provider/flagd/defaults.py rename to providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/defaults.py diff --git a/providers/openfeature-provider-flagd/openfeature/contrib/provider/flagd/flag_type.py b/providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/flag_type.py similarity index 100% rename from providers/openfeature-provider-flagd/openfeature/contrib/provider/flagd/flag_type.py rename to providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/flag_type.py diff --git a/providers/openfeature-provider-flagd/openfeature/contrib/provider/flagd/provider.py b/providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/provider.py similarity index 100% rename from providers/openfeature-provider-flagd/openfeature/contrib/provider/flagd/provider.py rename to providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/provider.py From 25d27b963177b50f48661aa8e77019d559d3ec01 Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Sat, 20 Jan 2024 12:39:06 -0300 Subject: [PATCH 4/6] docs: update documentation and remove unneeded files Signed-off-by: Federico Bond --- CONTRIBUTING.md | 16 +++++++++++----- Makefile | 46 ---------------------------------------------- requirements.txt | 9 --------- 3 files changed, 11 insertions(+), 60 deletions(-) delete mode 100644 Makefile delete mode 100644 requirements.txt diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d73fd726..906f9b50 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,13 +12,15 @@ Python 3.8 and above are supported by the SDK. ### Installation and Dependencies -A [`Makefile`](./Makefile) has been included in the project which should make it straightforward to start the project locally. We utilize virtual environments (see [`virtualenv`](https://docs.python.org/3/tutorial/venv.html)) in order to provide isolated development environments for the project. This reduces the risk of invalid or corrupt global packages. It also integrates nicely with Make, which will detect changes in the `requirements.txt` file and update the virtual environment if any occur. +We use [Hatch](https://hatch.pypa.io/) to manage the project. Hatch is does not have built-in support for monorepos yet, so you must run it inside each package directory. -Run `make init` to initialize the project's virtual environment and install all dev dependencies. +To install Hatch, just run `pip install hatch`. + +You will also need to setup the `pre-commit` hooks. Run `pre-commit install` in the root directory of the repository. If you don't have `pre-commit` installed, you can install it with `pip install pre-commit`. ### Testing -Run tests with `make test`. +Run tests by entering the package directory and running `hatch run test`. We use `pytest` for our unit testing, making use of `parametrized` to inject cases at scale. @@ -28,7 +30,10 @@ These are planned once the SDK has been stabilized and a Flagd provider implemen ### Packaging -We publish to the PyPI repository, where you can find this package at [openfeature-sdk-contrib](https://pypi.org/project/openfeature-sdk-contrib/). +We publish to the PyPI repository, where you can find each individual package: + +- [openfeature-provider-flagd](https://pypi.org/project/openfeature-provider-flagd/) +- [openfeature-hooks-opentelemetry](https://pypi.org/project/openfeature-hooks-opentelemetry/) ## Pull Request @@ -55,7 +60,8 @@ git remote add fork https://github.com/YOUR_GITHUB_USERNAME/python-sdk-contrib.g Ensure your development environment is all set up by building and testing ```bash -make +cd +hatch run test ``` To start working on a new feature or bugfix, create a new branch and start working on it. diff --git a/Makefile b/Makefile deleted file mode 100644 index e167a1e4..00000000 --- a/Makefile +++ /dev/null @@ -1,46 +0,0 @@ -VENV_NAME ?= .venv -VENV_ACTIVATE = . $(VENV_NAME)/bin/activate - -.DEFAULT_GOAL := help - -.PHONY: init -init: venv - -.PHONY: help -help: - @echo "Targets:" - @echo " requirements Installs dependencies" - @echo " venv Creates a virtual environment and install dependencies" - @echo " test Run pytest on the tests/ directory" - @echo " lint Check code with ruff" - @echo " format Format code with ruff-format" - -.PHONY: requirements -requirements: - $(VENV_ACTIVATE); pip install -r requirements.txt - -.PHONY: grpc -grpc: - $(VENV_ACTIVATE); cd schemas && buf generate buf.build/open-feature/flagd --template protobuf/buf.gen.python.yaml - rm -rf openfeature/contrib/providers/flagd/proto - mv proto/python openfeature/contrib/providers/flagd/proto - sed -i.bak 's/^from schema.v1 import/from . import/' openfeature/contrib/providers/flagd/proto/schema/v1/*.py - rm openfeature/contrib/providers/flagd/proto/schema/v1/*.bak - rmdir proto - -.PHONY: venv -venv: $(VENV_NAME) - test -d $(VENV_NAME) || python3 -m venv $(VENV_NAME) - $(VENV_ACTIVATE); pip install -r requirements.txt - -.PHONY: test -test: venv ## Run pytest on the tests/ directory - $(VENV_ACTIVATE); pytest tests/ - -.PHONY: lint -lint: venv ## Check code with ruff - $(VENV_ACTIVATE); pre-commit run -a - -.PHONY: format -format: venv ## Format code with black - $(VENV_ACTIVATE); pre-commit run -a ruff-format diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 9f262b70..00000000 --- a/requirements.txt +++ /dev/null @@ -1,9 +0,0 @@ -requests==2.31.0 -opentelemetry-sdk==1.20.0 -openfeature-sdk==0.3.1 -pytest==7.4.2 -pytest-mock==3.11.1 -pre-commit==3.4.0 -coverage==7.3.2 -grpcio==1.59.0 -grpcio-tools==1.59.0 From 6f7a06791449e7d67a206b0b1fda11deb278cbbe Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Sat, 20 Jan 2024 18:25:29 -0300 Subject: [PATCH 5/6] chore: remove pre-commit exclude as it's already covered by .gitignore Signed-off-by: Federico Bond --- .pre-commit-config.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e9c75fba..319d5fe1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,6 @@ repos: hooks: - id: ruff - id: ruff-format - exclude: ^openfeature/contrib/providers/flagd/proto/(.*) - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 From e3ea4b2ae68cb7aa38c76a863daea5fcd4e8e6df Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Wed, 24 Jan 2024 21:16:36 -0300 Subject: [PATCH 6/6] docs: fix typo in CONTRIBUTING.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Anton Grübel Signed-off-by: Federico Bond --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 906f9b50..07031016 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,7 +12,7 @@ Python 3.8 and above are supported by the SDK. ### Installation and Dependencies -We use [Hatch](https://hatch.pypa.io/) to manage the project. Hatch is does not have built-in support for monorepos yet, so you must run it inside each package directory. +We use [Hatch](https://hatch.pypa.io/) to manage the project. Hatch does not have built-in support for monorepos yet, so you must run it inside each package directory. To install Hatch, just run `pip install hatch`.