cognite-extractor-utils 7.10.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. cognite_extractor_utils-7.10.1/.gitignore +157 -0
  2. cognite_extractor_utils-7.10.1/LICENSE +176 -0
  3. cognite_extractor_utils-7.10.1/PKG-INFO +116 -0
  4. cognite_extractor_utils-7.10.1/README.md +82 -0
  5. cognite_extractor_utils-7.10.1/cognite/examples/unstable/extractors/simple_extractor/config/config.yaml +3 -0
  6. cognite_extractor_utils-7.10.1/cognite/examples/unstable/extractors/simple_extractor/config/connection_config.yaml +10 -0
  7. cognite_extractor_utils-7.10.1/cognite/examples/unstable/extractors/simple_extractor/main.py +81 -0
  8. cognite_extractor_utils-7.10.1/cognite/extractorutils/__init__.py +22 -0
  9. cognite_extractor_utils-7.10.1/cognite/extractorutils/_inner_util.py +53 -0
  10. cognite_extractor_utils-7.10.1/cognite/extractorutils/base.py +465 -0
  11. cognite_extractor_utils-7.10.1/cognite/extractorutils/configtools/__init__.py +133 -0
  12. cognite_extractor_utils-7.10.1/cognite/extractorutils/configtools/_util.py +116 -0
  13. cognite_extractor_utils-7.10.1/cognite/extractorutils/configtools/elements.py +975 -0
  14. cognite_extractor_utils-7.10.1/cognite/extractorutils/configtools/loaders.py +544 -0
  15. cognite_extractor_utils-7.10.1/cognite/extractorutils/configtools/validators.py +40 -0
  16. cognite_extractor_utils-7.10.1/cognite/extractorutils/exceptions.py +43 -0
  17. cognite_extractor_utils-7.10.1/cognite/extractorutils/metrics.py +428 -0
  18. cognite_extractor_utils-7.10.1/cognite/extractorutils/py.typed +0 -0
  19. cognite_extractor_utils-7.10.1/cognite/extractorutils/statestore/__init__.py +86 -0
  20. cognite_extractor_utils-7.10.1/cognite/extractorutils/statestore/_base.py +84 -0
  21. cognite_extractor_utils-7.10.1/cognite/extractorutils/statestore/hashing.py +372 -0
  22. cognite_extractor_utils-7.10.1/cognite/extractorutils/statestore/watermark.py +483 -0
  23. cognite_extractor_utils-7.10.1/cognite/extractorutils/threading.py +127 -0
  24. cognite_extractor_utils-7.10.1/cognite/extractorutils/unstable/__init__.py +8 -0
  25. cognite_extractor_utils-7.10.1/cognite/extractorutils/unstable/configuration/__init__.py +3 -0
  26. cognite_extractor_utils-7.10.1/cognite/extractorutils/unstable/configuration/exceptions.py +59 -0
  27. cognite_extractor_utils-7.10.1/cognite/extractorutils/unstable/configuration/loaders.py +193 -0
  28. cognite_extractor_utils-7.10.1/cognite/extractorutils/unstable/configuration/models.py +899 -0
  29. cognite_extractor_utils-7.10.1/cognite/extractorutils/unstable/core/__init__.py +5 -0
  30. cognite_extractor_utils-7.10.1/cognite/extractorutils/unstable/core/_dto.py +119 -0
  31. cognite_extractor_utils-7.10.1/cognite/extractorutils/unstable/core/_messaging.py +5 -0
  32. cognite_extractor_utils-7.10.1/cognite/extractorutils/unstable/core/base.py +549 -0
  33. cognite_extractor_utils-7.10.1/cognite/extractorutils/unstable/core/checkin_worker.py +428 -0
  34. cognite_extractor_utils-7.10.1/cognite/extractorutils/unstable/core/errors.py +128 -0
  35. cognite_extractor_utils-7.10.1/cognite/extractorutils/unstable/core/logger.py +347 -0
  36. cognite_extractor_utils-7.10.1/cognite/extractorutils/unstable/core/restart_policy.py +43 -0
  37. cognite_extractor_utils-7.10.1/cognite/extractorutils/unstable/core/runtime.py +528 -0
  38. cognite_extractor_utils-7.10.1/cognite/extractorutils/unstable/core/tasks.py +168 -0
  39. cognite_extractor_utils-7.10.1/cognite/extractorutils/unstable/scheduling/__init__.py +16 -0
  40. cognite_extractor_utils-7.10.1/cognite/extractorutils/unstable/scheduling/_scheduler.py +104 -0
  41. cognite_extractor_utils-7.10.1/cognite/extractorutils/unstable/scheduling/_schedules.py +31 -0
  42. cognite_extractor_utils-7.10.1/cognite/extractorutils/uploader/__init__.py +95 -0
  43. cognite_extractor_utils-7.10.1/cognite/extractorutils/uploader/_base.py +156 -0
  44. cognite_extractor_utils-7.10.1/cognite/extractorutils/uploader/_metrics.py +56 -0
  45. cognite_extractor_utils-7.10.1/cognite/extractorutils/uploader/assets.py +168 -0
  46. cognite_extractor_utils-7.10.1/cognite/extractorutils/uploader/data_modeling.py +151 -0
  47. cognite_extractor_utils-7.10.1/cognite/extractorutils/uploader/events.py +169 -0
  48. cognite_extractor_utils-7.10.1/cognite/extractorutils/uploader/files.py +783 -0
  49. cognite_extractor_utils-7.10.1/cognite/extractorutils/uploader/raw.py +190 -0
  50. cognite_extractor_utils-7.10.1/cognite/extractorutils/uploader/time_series.py +955 -0
  51. cognite_extractor_utils-7.10.1/cognite/extractorutils/uploader/upload_failure_handler.py +97 -0
  52. cognite_extractor_utils-7.10.1/cognite/extractorutils/uploader_extractor.py +217 -0
  53. cognite_extractor_utils-7.10.1/cognite/extractorutils/uploader_types.py +53 -0
  54. cognite_extractor_utils-7.10.1/cognite/extractorutils/util.py +678 -0
  55. cognite_extractor_utils-7.10.1/pyproject.toml +127 -0
@@ -0,0 +1,157 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # Local test files
7
+ test.py
8
+ test.yaml
9
+ local-test.yaml
10
+ pyrightconfig.json
11
+
12
+ # Tokens, etc
13
+ token.txt
14
+
15
+ # Mac files
16
+ .DS_Store
17
+
18
+ # C extensions
19
+ *.so
20
+
21
+ # Distribution / packaging
22
+ .Python
23
+ build/
24
+ develop-eggs/
25
+ dist/
26
+ downloads/
27
+ eggs/
28
+ .eggs/
29
+ lib/
30
+ lib64/
31
+ parts/
32
+ sdist/
33
+ var/
34
+ wheels/
35
+ pip-wheel-metadata/
36
+ share/python-wheels/
37
+ *.egg-info/
38
+ .installed.cfg
39
+ *.egg
40
+ MANIFEST
41
+
42
+ # PyInstaller
43
+ # Usually these files are written by a python script from a template
44
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
45
+ *.manifest
46
+ *.spec
47
+
48
+ # Installer logs
49
+ pip-log.txt
50
+ pip-delete-this-directory.txt
51
+
52
+ # Unit test / coverage reports
53
+ htmlcov/
54
+ .tox/
55
+ .nox/
56
+ .coverage
57
+ .coverage.*
58
+ .cache
59
+ test-report.xml
60
+ nosetests.xml
61
+ coverage.xml
62
+ *.cover
63
+ .hypothesis/
64
+ .pytest_cache/
65
+
66
+ # Translations
67
+ *.mo
68
+ *.pot
69
+
70
+ # Django stuff:
71
+ *.log
72
+ local_settings.py
73
+ db.sqlite3
74
+ db.sqlite3-journal
75
+
76
+ # Flask stuff:
77
+ instance/
78
+ .webassets-cache
79
+
80
+ # Scrapy stuff:
81
+ .scrapy
82
+
83
+ # Sphinx documentation
84
+ docs/_build/
85
+
86
+ # PyBuilder
87
+ target/
88
+
89
+ # Jupyter Notebook
90
+ .ipynb_checkpoints
91
+
92
+ # IPython
93
+ profile_default/
94
+ ipython_config.py
95
+
96
+ # pyenv
97
+ .python-version
98
+
99
+ # pipenv
100
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
101
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
102
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
103
+ # install all needed dependencies.
104
+ #Pipfile.lock
105
+
106
+ uv.lock
107
+ poetry.lock
108
+
109
+ # pyenv
110
+ .python-version
111
+
112
+ # celery beat schedule file
113
+ celerybeat-schedule
114
+
115
+ # SageMath parsed files
116
+ *.sage.py
117
+
118
+ # Environments
119
+ .env
120
+ .venv
121
+ env/
122
+ venv/
123
+ ENV/
124
+ env.bak/
125
+ venv.bak/
126
+
127
+ # Spyder project settings
128
+ .spyderproject
129
+ .spyproject
130
+
131
+ # Rope project settings
132
+ .ropeproject
133
+
134
+ # mkdocs documentation
135
+ /site
136
+
137
+ # mypy
138
+ .mypy_cache/
139
+ .dmypy.json
140
+ dmypy.json
141
+
142
+ # Pyre type checker
143
+ .pyre/
144
+ =======
145
+
146
+ # jetbrains
147
+ .idea/
148
+
149
+ # vscode
150
+ .vscode/
151
+
152
+ # unit tests output
153
+ /test_dump_config.yml
154
+ /testfile-invalid.json
155
+ /testfile-startstop.json
156
+ /bar
157
+ /foo
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,116 @@
1
+ Metadata-Version: 2.4
2
+ Name: cognite-extractor-utils
3
+ Version: 7.10.1
4
+ Summary: Utilities for easier development of extractors for CDF
5
+ Project-URL: repository, https://github.com/cognitedata/python-extractor-utils
6
+ Author-email: Mathias Lohne <mathias.lohne@cognite.com>
7
+ License: Apache-2.0
8
+ License-File: LICENSE
9
+ Classifier: Development Status :: 5 - Production/Stable
10
+ Classifier: Programming Language :: Python
11
+ Requires-Python: >=3.10
12
+ Requires-Dist: arrow>=1.0.0
13
+ Requires-Dist: azure-identity>=1.14.0
14
+ Requires-Dist: azure-keyvault-secrets>=4.7.0
15
+ Requires-Dist: cognite-sdk>=7.90.0
16
+ Requires-Dist: croniter>=6.0.0
17
+ Requires-Dist: dacite<1.10.0,>=1.9.2
18
+ Requires-Dist: decorator>=5.1.1
19
+ Requires-Dist: httpx<1,>=0.27.0
20
+ Requires-Dist: jsonlines>=4.0.0
21
+ Requires-Dist: more-itertools>=10.0.0
22
+ Requires-Dist: orjson>=3.10.3
23
+ Requires-Dist: prometheus-client<=1.0.0,>=0.7.0
24
+ Requires-Dist: psutil>=6.0.0
25
+ Requires-Dist: pydantic>=2.8.2
26
+ Requires-Dist: pyhumps>=3.8.0
27
+ Requires-Dist: python-dotenv>=1.0.0
28
+ Requires-Dist: pyyaml<7,>=5.3.0
29
+ Requires-Dist: simple-winservice>=0.1.0; sys_platform == 'win32'
30
+ Requires-Dist: typing-extensions<5,>=3.7.4
31
+ Provides-Extra: experimental
32
+ Requires-Dist: cognite-sdk-experimental; extra == 'experimental'
33
+ Description-Content-Type: text/markdown
34
+
35
+ <a href="https://cognite.com/">
36
+ <img src="https://github.com/cognitedata/cognite-python-docs/blob/master/img/cognite_logo.png" alt="Cognite logo" title="Cognite" align="right" height="80" />
37
+ </a>
38
+
39
+ Cognite Python `extractor-utils`
40
+ ================================
41
+ [![Build Status](https://github.com/cognitedata/python-extractor-utils/workflows/release/badge.svg)](https://github.com/cognitedata/python-extractor-utils/actions)
42
+ [![Documentation Status](https://readthedocs.com/projects/cognite-extractor-utils/badge/?version=latest&token=a9bab88214cbf624706005f6a71bbd77964efc910f8e527c7b3d75edc016397c)](https://cognite-extractor-utils.readthedocs-hosted.com/en/latest/?badge=latest)
43
+ [![codecov](https://codecov.io/gh/cognitedata/python-extractor-utils/branch/master/graph/badge.svg?token=7AmVCpAh7I)](https://codecov.io/gh/cognitedata/python-extractor-utils)
44
+ [![PyPI version](https://badge.fury.io/py/cognite-extractor-utils.svg)](https://pypi.org/project/cognite-extractor-utils)
45
+ ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/cognite-extractor-utils)
46
+ [![License](https://img.shields.io/github/license/cognitedata/python-extractor-utils)](LICENSE)
47
+ [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
48
+
49
+ The `extractor-utils` package is an extension of the Cognite Python SDK intended to simplify the development of data
50
+ extractors or other integrations for Cognite Data Fusion.
51
+
52
+ Documentation is hosted [here](https://cognite-extractor-utils.readthedocs-hosted.com/en/latest/), including a
53
+ [quickstart tutorial](https://cognite-extractor-utils.readthedocs-hosted.com/en/latest/quickstart.html).
54
+
55
+ The changelog is found [here](./CHANGELOG.md).
56
+
57
+ ## Overview
58
+
59
+ The best way to start a new extractor project is to use the `cogex` CLI. You can install that from PyPI:
60
+
61
+ ``` bash
62
+ pip install cognite-extractor-manager
63
+ ```
64
+
65
+ To initialize a new extractor project, run
66
+
67
+ ``` bash
68
+ cogex init
69
+ ```
70
+
71
+ in the directory you want your extractor project in. The `cogex` CLI will prompt you for some information about your
72
+ project, and then set up a poetry environment, git repository, commit hooks with type and style checks and load a
73
+ template.
74
+
75
+
76
+ ## Contributing
77
+
78
+ The package is open source under the [Apache 2.0 license](./LICENSE), and contribtuions are welcome.
79
+
80
+ This project adheres to the [Contributor Covenant v2.0](https://www.contributor-covenant.org/version/2/0/code_of_conduct/)
81
+ as a code of conduct.
82
+
83
+
84
+ ### Development environment
85
+
86
+ We use [uv](https://docs.astral.sh/uv/) to manage dependencies and to administrate virtual environments. To develop
87
+ `extractor-utils`, follow the following steps to set up your local environment:
88
+
89
+ 1. [Install uv](https://docs.astral.sh/uv/getting-started/installation/) if you haven't already.
90
+
91
+ 2. Clone repository:
92
+ ```
93
+ $ git clone git@github.com:cognitedata/python-extractor-utils.git
94
+ ```
95
+ 3. Move into the newly created local repository:
96
+ ```
97
+ $ cd python-extractor-utils
98
+ ```
99
+ 4. Create virtual environment and install dependencies:
100
+ ```
101
+ $ uv sync
102
+ ```
103
+
104
+
105
+ ### Code requirements
106
+
107
+ All code must pass [black](https://github.com/ambv/black) and [isort](https://github.com/timothycrosley/isort) style
108
+ checks to be merged. It is recommended to install pre-commit hooks to ensure this locally before commiting code:
109
+
110
+ ```
111
+ $ poetry run pre-commit install
112
+ ```
113
+
114
+ Each public method, class and module should have docstrings. Docstrings are written in the [Google
115
+ style](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings). Please include unit and/or
116
+ integration tests for submitted code, and remember to update the [changelog](./CHANGELOG.md).
@@ -0,0 +1,82 @@
1
+ <a href="https://cognite.com/">
2
+ <img src="https://github.com/cognitedata/cognite-python-docs/blob/master/img/cognite_logo.png" alt="Cognite logo" title="Cognite" align="right" height="80" />
3
+ </a>
4
+
5
+ Cognite Python `extractor-utils`
6
+ ================================
7
+ [![Build Status](https://github.com/cognitedata/python-extractor-utils/workflows/release/badge.svg)](https://github.com/cognitedata/python-extractor-utils/actions)
8
+ [![Documentation Status](https://readthedocs.com/projects/cognite-extractor-utils/badge/?version=latest&token=a9bab88214cbf624706005f6a71bbd77964efc910f8e527c7b3d75edc016397c)](https://cognite-extractor-utils.readthedocs-hosted.com/en/latest/?badge=latest)
9
+ [![codecov](https://codecov.io/gh/cognitedata/python-extractor-utils/branch/master/graph/badge.svg?token=7AmVCpAh7I)](https://codecov.io/gh/cognitedata/python-extractor-utils)
10
+ [![PyPI version](https://badge.fury.io/py/cognite-extractor-utils.svg)](https://pypi.org/project/cognite-extractor-utils)
11
+ ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/cognite-extractor-utils)
12
+ [![License](https://img.shields.io/github/license/cognitedata/python-extractor-utils)](LICENSE)
13
+ [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
14
+
15
+ The `extractor-utils` package is an extension of the Cognite Python SDK intended to simplify the development of data
16
+ extractors or other integrations for Cognite Data Fusion.
17
+
18
+ Documentation is hosted [here](https://cognite-extractor-utils.readthedocs-hosted.com/en/latest/), including a
19
+ [quickstart tutorial](https://cognite-extractor-utils.readthedocs-hosted.com/en/latest/quickstart.html).
20
+
21
+ The changelog is found [here](./CHANGELOG.md).
22
+
23
+ ## Overview
24
+
25
+ The best way to start a new extractor project is to use the `cogex` CLI. You can install that from PyPI:
26
+
27
+ ``` bash
28
+ pip install cognite-extractor-manager
29
+ ```
30
+
31
+ To initialize a new extractor project, run
32
+
33
+ ``` bash
34
+ cogex init
35
+ ```
36
+
37
+ in the directory you want your extractor project in. The `cogex` CLI will prompt you for some information about your
38
+ project, and then set up a poetry environment, git repository, commit hooks with type and style checks and load a
39
+ template.
40
+
41
+
42
+ ## Contributing
43
+
44
+ The package is open source under the [Apache 2.0 license](./LICENSE), and contribtuions are welcome.
45
+
46
+ This project adheres to the [Contributor Covenant v2.0](https://www.contributor-covenant.org/version/2/0/code_of_conduct/)
47
+ as a code of conduct.
48
+
49
+
50
+ ### Development environment
51
+
52
+ We use [uv](https://docs.astral.sh/uv/) to manage dependencies and to administrate virtual environments. To develop
53
+ `extractor-utils`, follow the following steps to set up your local environment:
54
+
55
+ 1. [Install uv](https://docs.astral.sh/uv/getting-started/installation/) if you haven't already.
56
+
57
+ 2. Clone repository:
58
+ ```
59
+ $ git clone git@github.com:cognitedata/python-extractor-utils.git
60
+ ```
61
+ 3. Move into the newly created local repository:
62
+ ```
63
+ $ cd python-extractor-utils
64
+ ```
65
+ 4. Create virtual environment and install dependencies:
66
+ ```
67
+ $ uv sync
68
+ ```
69
+
70
+
71
+ ### Code requirements
72
+
73
+ All code must pass [black](https://github.com/ambv/black) and [isort](https://github.com/timothycrosley/isort) style
74
+ checks to be merged. It is recommended to install pre-commit hooks to ensure this locally before commiting code:
75
+
76
+ ```
77
+ $ poetry run pre-commit install
78
+ ```
79
+
80
+ Each public method, class and module should have docstrings. Docstrings are written in the [Google
81
+ style](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings). Please include unit and/or
82
+ integration tests for submitted code, and remember to update the [changelog](./CHANGELOG.md).
@@ -0,0 +1,3 @@
1
+ log-handlers:
2
+ - type: console
3
+ level: INFO
@@ -0,0 +1,10 @@
1
+ project: ${COGNITE_PROJECT}
2
+ base_url: ${COGNITE_BASE_URL}
3
+ integration:
4
+ external_id: ${COGNITE_INTEGRATION_ID}
5
+ authentication:
6
+ type: "client-credentials"
7
+ client_id: ${COGNITE_CLIENT_ID}
8
+ client_secret: ${COGNITE_CLIENT_SECRET}
9
+ token_url: ${COGNITE_TOKEN_URL}
10
+ scopes: ${COGNITE_SCOPES}
@@ -0,0 +1,81 @@
1
+ """
2
+ An example extractor that logs messages at various levels.
3
+ """
4
+
5
+ from cognite.extractorutils.unstable.configuration.models import ExtractorConfig, IntervalConfig, TimeIntervalConfig
6
+ from cognite.extractorutils.unstable.core.base import Extractor, StartupTask, TaskContext
7
+ from cognite.extractorutils.unstable.core.runtime import Runtime
8
+ from cognite.extractorutils.unstable.core.tasks import ScheduledTask
9
+
10
+
11
+ class SimpleConfig(ExtractorConfig):
12
+ """
13
+ Defines the configuration for the SimpleExtractor.
14
+ """
15
+
16
+ pass
17
+
18
+
19
+ class SimpleExtractor(Extractor[SimpleConfig]):
20
+ """
21
+ An example extractor that logs messages at various levels.
22
+ """
23
+
24
+ NAME = "SimpleTestExtractor"
25
+ EXTERNAL_ID = "test-extractor"
26
+ DESCRIPTION = "An extractor for testing log levels"
27
+ VERSION = "1.0.0"
28
+ CONFIG_TYPE = SimpleConfig
29
+ SUPPORTS_DRY_RUN = True
30
+
31
+ def __init_tasks__(self) -> None:
32
+ """
33
+ Initializes and adds tasks to the extractor.
34
+ """
35
+ self.add_task(StartupTask(name="main_task", target=self.run_my_task))
36
+ self.add_task(
37
+ ScheduledTask(
38
+ name="scheduled_task",
39
+ target=self.scheduled_task,
40
+ schedule=IntervalConfig(type="interval", expression=TimeIntervalConfig("3s")),
41
+ )
42
+ )
43
+
44
+ # example task that logs messages at different levels
45
+ def run_my_task(self, ctx: TaskContext) -> None:
46
+ """
47
+ An example task that logs messages at different levels.
48
+
49
+ Args:
50
+ ctx: The context for the task execution, used for logging.
51
+ """
52
+ ctx.debug("This is a detailed debug message.")
53
+ ctx.info("This is an informational message.")
54
+ ctx.warning("This is a warning message.")
55
+ ctx.info("Test finished.")
56
+
57
+ def scheduled_task(self, ctx: TaskContext) -> None:
58
+ """
59
+ An example scheduled task that logs a message.
60
+
61
+ Args:
62
+ ctx: The context for the task execution, used for logging.
63
+ """
64
+ ctx.info("This is a scheduled task running.")
65
+ ctx.warning("This is a warning from the scheduled task.")
66
+ ctx.debug("Debugging the scheduled task execution.")
67
+ ctx.error("This is an error message from the scheduled task.")
68
+
69
+ # add more tasks as needed
70
+
71
+
72
+ def main() -> None:
73
+ """
74
+ Main function to run the SimpleExtractor.
75
+ """
76
+ runtime = Runtime(SimpleExtractor)
77
+ runtime.run()
78
+
79
+
80
+ if __name__ == "__main__":
81
+ main()
@@ -0,0 +1,22 @@
1
+ # Copyright 2020 Cognite AS
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """
16
+ Cognite extractor utils is a Python package that simplifies the development of new extractors.
17
+ """
18
+
19
+ __version__ = "7.10.1"
20
+ from .base import Extractor
21
+
22
+ __all__ = ["Extractor"]