ocean-runner 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,179 @@
1
+ Metadata-Version: 2.4
2
+ Name: ocean-runner
3
+ Version: 0.1.0
4
+ Summary: A Python PyPI package template
5
+ Project-URL: Homepage, https://github.com/AgrospAI/ocean-runner
6
+ Project-URL: Issues, https://github.com/AgrospAI/ocean-runner/issues
7
+ Author-email: John Doe <john.doe@foo.bar>
8
+ License: Copyright 2025 spin3l
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15
+ License-File: LICENSE
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Requires-Python: >=3.10
20
+ Requires-Dist: oceanprotocol-job-details==0.2.4
21
+ Requires-Dist: pytest>=8.4.2
22
+ Description-Content-Type: text/markdown
23
+
24
+ # ocean-runner
25
+
26
+ Ocean Runner is a package that brings a fluent API for APP creation and running in the scope of OceanProtocol.
27
+
28
+
29
+ ## Usage
30
+
31
+ ### Minimal Example
32
+
33
+ ```python
34
+ import random
35
+ from ocean_runner import Algorithm, Config
36
+
37
+
38
+ Algorithm().run(lambda _: random.randint()).save_results()
39
+ ```
40
+
41
+ To use minimally the API, you can just provide a callback to the run method, defaulting for the rest of behaviours. This code snippet will:
42
+
43
+ - Read the OceanProtocol JobDetails from the environment variables and use default file paths.
44
+ - Generate a random integer.
45
+ - Store the result in a "result.txt" file within the default outputs path.
46
+
47
+ ### Tuning
48
+
49
+ #### Application Config
50
+
51
+ The application configuration can be tweaked by passing a Config instance to its' constructor.
52
+
53
+ ```python
54
+ Algorithm(
55
+ Config(
56
+ custom_input: ... # dataclass
57
+ # Custom algorithm parameters dataclass.
58
+
59
+ error_callback: ... # Callable[[Exception], None]
60
+ # Callback to run on exceptions.
61
+
62
+ logger: ... # type: logging.Logger
63
+ # Custom logger to use.
64
+
65
+ environment: ...
66
+ # type: ocean_runner.Environment. Mock of environment variables.
67
+ )
68
+ )
69
+ ```
70
+
71
+ ```python
72
+ import logging
73
+
74
+
75
+ @dataclass
76
+ class CustomInput:
77
+ foobar: string
78
+
79
+
80
+ logger = logging.getLogger(__name__)
81
+
82
+
83
+ Algorithm(
84
+ Config(
85
+ custom_input: CustomInput,
86
+ """
87
+ Load the Algorithm's Custom Input into a CustomInput dataclass instance.
88
+ """
89
+
90
+ error_callback: lambda ex: logger.exception(ex),
91
+ """
92
+ Run this callback when an exception is caught
93
+ NOTE: it's not recommended to catch exceptions this way. Should re-raise and halt the execution.
94
+ """
95
+
96
+ logger: logger,
97
+ """
98
+ Custom logger to use in the Algorithm.
99
+ """
100
+
101
+ environment: Environment(
102
+ base_dir: "./_data",
103
+ """
104
+ Custom data path to use test data.
105
+ """
106
+
107
+ dids: '["17feb697190d9f5912e064307006c06019c766d35e4e3f239ebb69fb71096e42"]',
108
+ """
109
+ Dataset DID.
110
+ """
111
+
112
+ transformation_did: "1234",
113
+ """
114
+ Random transformation DID to use while testing.
115
+ """
116
+
117
+ secret: "1234",
118
+ """
119
+ Random secret to use while testing.
120
+ """
121
+ )
122
+ """
123
+ Should not be needed in production algorithms, used to mock environment variables, defaults to using env.
124
+ """
125
+ )
126
+ )
127
+
128
+ ```
129
+
130
+ ## Default behaviours
131
+
132
+ ### Default implementations
133
+
134
+ As seen in the minimal example, all methods implemented in `Algorithm` have a default implementation which will be commented here.
135
+
136
+ ```python
137
+
138
+ (
139
+ Algorithm()
140
+
141
+ """
142
+ Default constructor, will use default values of Config.
143
+ """
144
+
145
+ .validate()
146
+
147
+ """
148
+ Will validate the algorithm's job detail instance, checking for the existence of:
149
+ - `job_details.ddos`
150
+ - `job_details.files`
151
+ """
152
+
153
+ .run()
154
+
155
+ """
156
+ Has NO default implementation, must pass a callback that returns a result of any type.
157
+ """
158
+
159
+ .save_results()
160
+
161
+ """
162
+ Stores the result of running the algorithm in "outputs/results.txt"
163
+ """
164
+
165
+ )
166
+
167
+
168
+ ```
169
+
170
+ ### Job Details
171
+
172
+ To load the OceanProtocol JobDetails instance, the program will read some environment variables, they can be mocked passing an instance of `Environment` through the configuration of the algorithm.
173
+
174
+ Environment variables:
175
+ - *DIDS*: Input dataset(s) DID's.
176
+ - *TRANSFORMATION_DID*: Algorithm DID.
177
+ - *SECRET*: Algorithm secret.
178
+ - *BASE_DIR* (optional, default='/data'): Base path to the OceanProtocol data directories.
179
+
@@ -0,0 +1,4 @@
1
+ ocean_runner-0.1.0.dist-info/METADATA,sha256=RNcTJa7JJDpda1CbBiRFUQgBANV0h8PR_b-TNuYgS2U,5420
2
+ ocean_runner-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
3
+ ocean_runner-0.1.0.dist-info/licenses/LICENSE,sha256=_B25KqK4amoADWkMN150tnZFm_Fy7VvZpvIC8ZydWdI,1053
4
+ ocean_runner-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.27.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,7 @@
1
+ Copyright 2025 spin3l
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.