outerbounds 0.3.183rc1__py3-none-any.whl → 0.3.185__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.
@@ -1,125 +0,0 @@
1
- """
2
- Examples demonstrating how to use the code packager abstraction.
3
-
4
- This file provides usage examples for the code packager classes.
5
- These examples are for documentation purposes and are not meant to be run directly.
6
- """
7
-
8
- import os
9
- import sys
10
- from io import BytesIO
11
- from typing import List, Dict, Any, Callable, Optional
12
-
13
- from .code_packager import CodePackager
14
-
15
-
16
- def basic_usage_example(datastore_type: str = "s3") -> None:
17
- """
18
- Basic usage example with ContentAddressedStore.
19
-
20
- This example shows how to:
21
- 1. Define paths to include in a package
22
- 2. Create a package using CodePackager's default packaging
23
- 3. Store the package using ContentAddressedStore directly
24
- 4. Generate a download command
25
-
26
- Parameters
27
- ----------
28
- datastore_type : str, default "s3"
29
- The type of datastore to use: "s3", "azure", "gs", or "local"
30
- """
31
- # Define the paths to include in the package
32
- paths_to_include = ["./"]
33
-
34
- # Define which file suffixes to include
35
- file_suffixes = [".py", ".md"]
36
-
37
- # Create metadata for the package
38
- metadata = {"example": True, "timestamp": "2023-01-01T00:00:00Z"}
39
-
40
- # Initialize the packager with datastore configuration
41
- packager = CodePackager(
42
- datastore_type=datastore_type,
43
- code_package_prefix="my-custom-prefix", # Optional
44
- )
45
-
46
- # Store the package with packaging parameters
47
- package_url, package_key = packager.store(
48
- paths_to_include=paths_to_include,
49
- file_suffixes=file_suffixes,
50
- metadata=metadata,
51
- )
52
-
53
- # Generate a download command
54
- download_cmd = CodePackager.get_download_cmd(
55
- package_url=package_url,
56
- datastore_type=datastore_type,
57
- target_file="my_package.tar",
58
- )
59
-
60
- # Generate complete package commands for downloading and setup
61
- package_commands = packager.get_package_commands(
62
- code_package_url=package_url,
63
- target_file="my_package.tar",
64
- working_dir="my_app",
65
- )
66
-
67
- # Print some information
68
- print(f"Package URL: {package_url}")
69
- print(f"Package Key: {package_key}")
70
- print(f"Download Command: {download_cmd}")
71
- print(f"Complete package commands: {package_commands}")
72
-
73
-
74
- def usage_with_custom_package_function(datastore_type: str = "s3") -> None:
75
- """
76
- Example of using the CodePackager with a custom package creation function.
77
-
78
- Parameters
79
- ----------
80
- datastore_type : str, default "s3"
81
- The type of datastore to use: "s3", "azure", "gs", or "local"
82
- """
83
-
84
- # Define a custom package function
85
- def create_custom_package():
86
- # This is a simple example - in real use, you might create a more complex package
87
- from io import BytesIO
88
- import tarfile
89
- import time
90
-
91
- buf = BytesIO()
92
- with tarfile.open(fileobj=buf, mode="w:gz") as tar:
93
- # Add a simple file to the tarball
94
- content = b"print('Hello, custom package!')"
95
- info = tarfile.TarInfo(name="hello.py")
96
- info.size = len(content)
97
- info.mtime = int(time.time())
98
- file_object = BytesIO(content)
99
- tar.addfile(info, file_object)
100
-
101
- return bytearray(buf.getvalue())
102
-
103
- # Initialize the packager with datastore configuration
104
- packager = CodePackager(datastore_type=datastore_type)
105
-
106
- # Store the package with the custom package function
107
- package_url, package_key = packager.store(package_create_fn=create_custom_package)
108
-
109
- # Generate a download command
110
- download_cmd = CodePackager.get_download_cmd(
111
- package_url=package_url,
112
- datastore_type=datastore_type,
113
- target_file="custom_package.tar",
114
- )
115
-
116
- # Generate complete package commands
117
- package_commands = packager.get_package_commands(
118
- code_package_url=package_url,
119
- )
120
-
121
- # Print some information
122
- print(f"Package URL: {package_url}")
123
- print(f"Package Key: {package_key}")
124
- print(f"Download Command: {download_cmd}")
125
- print(f"Complete commands: {package_commands}")
@@ -1,269 +0,0 @@
1
-
2
- title: Outerbounds App Configuration Schema
3
- description: |
4
- Schema for defining Outerbounds Apps configuration. This schema is what we will end up using on the CLI/programmatic interface.
5
- How to read this schema:
6
- 1. If the a property has `allow_union`:true then it will allow overrides from the cli.
7
- 2. If a property has `experimental` set to true then a lot its validations may-be skipped and parsing handled somewhere else.
8
-
9
- The YAML based schema file is for Humans to change and consume. The JSON based schema file is what gets autogenerated based on pre-commit
10
- hooks so that we can use within the outerbounds package. The reasons for two distinct types of files it that YAML provides the ability to
11
- add comments and make readability easier. While JSON is so that we can reduce the dependency on YAML when working with apps within both
12
- Metaflow and OB package.
13
- version: 1.0.0
14
- type: object
15
- required:
16
- - name
17
- - port
18
- properties:
19
- name: # Only used in `deploy` command
20
- allow_union: true # Allow overriding name from the CLI.
21
- type: string
22
- description: The name of the app to deploy.
23
- maxLength: 20 # todo: check if we should allow a larger length.
24
- example: "myapp"
25
- port: # Only used in `deploy` command
26
- allow_union: false
27
- type: integer
28
- description: Port where the app is hosted. When deployed this will be port on which we will deploy the app.
29
- minimum: 1
30
- maximum: 65535
31
- example: 8000
32
- tags: # Only used in `deploy` command
33
- allow_union: true
34
- type: array
35
- description: The tags of the app to deploy.
36
- items:
37
- type: object
38
- example:
39
- - foo: bar
40
- - x: y
41
- description: # Only used in `deploy` command
42
- allow_union: true
43
- type: string
44
- description: The description of the app to deploy.
45
- example: "This is a description of my app."
46
- force_upgrade: # Only used in `deploy` command
47
- allow_union: true
48
- type: boolean
49
- description: Whether to force upgrade the app even if it is currently being upgraded.
50
- example: true
51
- app_type: # Only used in `deploy` command
52
- allow_union: true
53
- type: string
54
- description: The User defined type of app to deploy. Its only used for bookkeeping purposes.
55
- example: "MyCustomAgent"
56
- image: # Only used in `deploy` command
57
- allow_union: true # We will overrwite the image if specified on the CLI.
58
- type: string
59
- description: The Docker image to deploy with the App.
60
- secrets: # Used in `run` command
61
- allow_union: true
62
- type: array
63
- description: Outerbounds integrations to attach to the app. You can use the value you set in the `@secrets` decorator in your code.
64
- items:
65
- type: string
66
- example: ["hf-token"]
67
- environment: # Used in `run` command
68
- # Todo: So this part might not be best on the CLI. We should probably have a better way to handle this.
69
- # In simplicity, we can just JSON dump anything that looks like a dict/list/
70
- allow_union: true
71
- type: object
72
- description: Environment variables to deploy with the App.
73
- additionalProperties:
74
- oneOf:
75
- - type: string
76
- - type: number
77
- - type: boolean
78
- - type: object
79
- - type: array # When users give arrays, or objects, we need to JSON dump them. Users need to be aware of this.
80
- example:
81
- DEBUG: true
82
- DATABASE_CONFIG: {"host": "localhost", "port": 5432}
83
- ALLOWED_ORIGINS: ["http://localhost:3000", "https://myapp.com"]
84
- dependencies: # Used in `run` command
85
- allow_union: false
86
- type: object
87
- description: |
88
- The dependencies to attach to the app. Only one of the properties can be specified.
89
- properties:
90
- from_requirements_file:
91
- type: string
92
- description: The path to the requirements.txt file to attach to the app.
93
- example: "requirements.txt"
94
- from_pyproject_toml:
95
- type: string
96
- description: The path to the pyproject.toml file to attach to the app.
97
- example: "pyproject.toml"
98
- python:
99
- type: string
100
- description: |
101
- The Python version to use for the app.
102
- example: "3.10"
103
- pypi:
104
- type: object
105
- description: |
106
- A dictionary of pypi dependencies to attach to the app.
107
- The key is the package name and the value is the version.
108
- example:
109
- numpy: 1.23.0
110
- pandas: ""
111
- conda:
112
- type: object
113
- description: |
114
- A dictionary of pypi dependencies to attach to the app.
115
- The key is the package name and the value is the version.
116
- example:
117
- numpy: 1.23.0
118
- pandas: ""
119
- package:
120
- allow_union: false
121
- type: object
122
- description: |
123
- Configurations associated with packaging the app.
124
- properties:
125
- src_path:
126
- type: string
127
- description: The path to the source code to deploy with the App.
128
- example: "./"
129
- suffixes:
130
- type: array
131
- description: |
132
- A list of suffixes to add to the source code to deploy with the App.
133
- items:
134
- type: string
135
- example: [".py", ".ipynb"]
136
-
137
- commands: # Used in `run` command
138
- allow_union: false
139
- type: array
140
- description: A list of commands to run the app with. Cannot be configured from the CLI. Only used in `run` command.
141
- items:
142
- type: string
143
- example: ["python app.py", "python app.py --foo bar"]
144
- resources: # Only used in `deploy` command
145
- allow_union: true # You can override CPU/Memory/GPU/Storage from the CLI.
146
- type: object
147
- properties:
148
- cpu:
149
- type: string
150
- description: CPU resource request and limit.
151
- example: "500m"
152
- default: "1"
153
- memory:
154
- type: string
155
- description: Memory resource request and limit.
156
- example: "512Mi"
157
- default: "4Gi"
158
- gpu:
159
- type: string
160
- description: GPU resource request and limit.
161
- example: "1"
162
- storage:
163
- type: string
164
- description: Storage resource request and limit.
165
- example: "1Gi"
166
- default: "10Gi"
167
- replicas:
168
- allow_union: true
169
- type: object
170
- description: |
171
- The number of replicas to deploy the app with.
172
- properties:
173
- min:
174
- type: integer
175
- description: The minimum number of replicas to deploy the app with.
176
- example: 1
177
- max:
178
- type: integer
179
- description: The maximum number of replicas to deploy the app with.
180
- example: 10
181
- health_check: # Can be used in `run` command
182
- type: object
183
- # `allow_union` property means that any object in this field will be done a union with the config file if something is provided on commanline.
184
- # If it is set to false, then we should throw an exception if the CLI is trying to override something specified in the config file.
185
- # We will only allow unions in certains options. The rest will not allow any unions and only need to be specified in one place.
186
- allow_union: false
187
- properties:
188
- enabled:
189
- type: boolean
190
- description: Whether to enable health checks.
191
- example: true
192
- default: false
193
- path:
194
- type: string
195
- description: The path for health checks.
196
- example: "/health"
197
- initial_delay_seconds:
198
- type: integer
199
- description: Number of seconds to wait before performing the first health check.
200
- example: 10
201
- period_seconds:
202
- type: integer
203
- description: How often to perform the health check.
204
- example: 30
205
- compute_pools: # Only used in `deploy` command
206
- allow_union: true
207
- type: array
208
- description: |
209
- A list of compute pools to deploy the app to.
210
- items:
211
- type: string
212
- example: ["default", "large"]
213
- auth: # Only used in `deploy` command
214
- allow_union: false
215
- type: object
216
- description: |
217
- Auth related configurations.
218
- properties:
219
- type:
220
- type: string
221
- description: |
222
- The type of authentication to use for the app.
223
- enum: [API, Browser]
224
- public:
225
- type: boolean
226
- description: |
227
- Whether the app is public or not.
228
- default: true
229
- # There is an allowed perimeters property
230
- # But that needs a little more thought on how
231
- # to expose.
232
-
233
- # ------------------------------------ EXPERIMENTAL ------------------------------------
234
- project:
235
- type: string
236
- description: The project name to deploy the app to.
237
- experimental: true
238
- allow_union: true
239
- branch:
240
- type: string
241
- description: The branch name to deploy the app to.
242
- experimental: true
243
- allow_union: true
244
-
245
- models: #
246
- type: array
247
- description: model asset ids to include with the deployment. NO CLI Option for this Now.
248
- experimental: true
249
- allow_union: true
250
- items:
251
- type: object
252
- properties:
253
- asset_id:
254
- type: string
255
- asset_instance_id:
256
- type: string
257
- data: #
258
- type: array
259
- description: data asset ids to include with the deployment.
260
- experimental: true
261
- allow_union: true
262
- items:
263
- type: object
264
- properties:
265
- asset_id:
266
- type: string
267
- asset_instance_id:
268
- type: string
269
- # ------------------------------------ EXPERIMENTAL ------------------------------------