flamepy 0.3.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.
flamepy/types.py ADDED
@@ -0,0 +1,159 @@
1
+ """
2
+ Copyright 2025 The Flame Authors.
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
+ http://www.apache.org/licenses/LICENSE-2.0
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
12
+ """
13
+
14
+ from dataclasses import dataclass
15
+ from enum import IntEnum
16
+ from typing import Optional, List, Dict, Any, Union
17
+ from datetime import datetime
18
+
19
+
20
+ # Type aliases
21
+ TaskID = str
22
+ SessionID = str
23
+ ApplicationID = str
24
+ Message = bytes
25
+ TaskInput = Message
26
+ TaskOutput = Message
27
+ CommonData = Message
28
+
29
+
30
+ # Constants
31
+ DEFAULT_FLAME_CONF = "flame-conf.yaml"
32
+ DEFAULT_CONTEXT_NAME = "flame"
33
+ DEFAULT_FLAME_ENDPOINT = "http://127.0.0.1:8080"
34
+
35
+
36
+ class SessionState(IntEnum):
37
+ """Session state enumeration."""
38
+ OPEN = 0
39
+ CLOSED = 1
40
+
41
+
42
+ class TaskState(IntEnum):
43
+ """Task state enumeration."""
44
+ PENDING = 0
45
+ RUNNING = 1
46
+ SUCCEED = 2
47
+ FAILED = 3
48
+
49
+
50
+ class ApplicationState(IntEnum):
51
+ """Application state enumeration."""
52
+ ENABLED = 0
53
+ DISABLED = 1
54
+
55
+
56
+ class Shim(IntEnum):
57
+ """Shim type enumeration."""
58
+ LOG = 0
59
+ STDIO = 1
60
+ WASM = 2
61
+ SHELL = 3
62
+ GRPC = 4
63
+
64
+
65
+ class FlameErrorCode(IntEnum):
66
+ """Flame error code enumeration."""
67
+ INVALID_CONFIG = 0
68
+ INVALID_STATE = 1
69
+ INVALID_ARGUMENT = 2
70
+ INTERNAL = 3
71
+
72
+
73
+ class FlameError(Exception):
74
+ """Flame SDK error exception."""
75
+
76
+ def __init__(self, code: FlameErrorCode, message: str):
77
+ self.code = code
78
+ self.message = message
79
+ super().__init__(f"{message} (code: {code})")
80
+
81
+
82
+ @dataclass
83
+ class SessionAttributes:
84
+ """Attributes for creating a session."""
85
+ application: str
86
+ slots: int
87
+ common_data: Optional[bytes] = None
88
+
89
+
90
+ @dataclass
91
+ class ApplicationAttributes:
92
+ """Attributes for an application."""
93
+ name: str
94
+ shim: Shim
95
+ url: Optional[str] = None
96
+ command: Optional[str] = None
97
+ arguments: Optional[List[str]] = None
98
+ environments: Optional[List[str]] = None
99
+ working_directory: Optional[str] = None
100
+
101
+
102
+
103
+
104
+ @dataclass
105
+ class Task:
106
+ """Represents a computing task."""
107
+ id: TaskID
108
+ session_id: SessionID
109
+ state: TaskState
110
+ creation_time: datetime
111
+ input: Optional[bytes] = None
112
+ output: Optional[bytes] = None
113
+ completion_time: Optional[datetime] = None
114
+
115
+ def is_completed(self) -> bool:
116
+ """Check if the task is completed."""
117
+ return self.state in (TaskState.SUCCEED, TaskState.FAILED)
118
+
119
+
120
+ @dataclass
121
+ class Application:
122
+ """Represents a distributed application."""
123
+ id: ApplicationID
124
+ name: str
125
+ shim: Shim
126
+ state: ApplicationState
127
+ creation_time: datetime
128
+ url: Optional[str] = None
129
+ command: Optional[str] = None
130
+ arguments: Optional[List[str]] = None
131
+ environments: Optional[List[str]] = None
132
+ working_directory: Optional[str] = None
133
+
134
+
135
+ @dataclass
136
+ class FlameContext:
137
+ """Flame context configuration."""
138
+ name: str
139
+ endpoint: str
140
+
141
+ @classmethod
142
+ def default(cls) -> "FlameContext":
143
+ """Create a default Flame context."""
144
+ return cls(
145
+ name=DEFAULT_CONTEXT_NAME,
146
+ endpoint=DEFAULT_FLAME_ENDPOINT
147
+ )
148
+
149
+
150
+ class TaskInformer:
151
+ """Interface for task updates."""
152
+
153
+ def on_update(self, task: Task) -> None:
154
+ """Called when a task is updated."""
155
+ pass
156
+
157
+ def on_error(self, error: FlameError) -> None:
158
+ """Called when an error occurs."""
159
+ pass
flamepy/types_pb2.py ADDED
@@ -0,0 +1,95 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
3
+ # NO CHECKED-IN PROTOBUF GENCODE
4
+ # source: types.proto
5
+ # Protobuf Python Version: 6.31.1
6
+ """Generated protocol buffer code."""
7
+ from google.protobuf import descriptor as _descriptor
8
+ from google.protobuf import descriptor_pool as _descriptor_pool
9
+ from google.protobuf import runtime_version as _runtime_version
10
+ from google.protobuf import symbol_database as _symbol_database
11
+ from google.protobuf.internal import builder as _builder
12
+ _runtime_version.ValidateProtobufRuntimeVersion(
13
+ _runtime_version.Domain.PUBLIC,
14
+ 6,
15
+ 31,
16
+ 1,
17
+ '',
18
+ 'types.proto'
19
+ )
20
+ # @@protoc_insertion_point(imports)
21
+
22
+ _sym_db = _symbol_database.Default()
23
+
24
+
25
+
26
+
27
+ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0btypes.proto\x12\x05\x66lame\"B\n\x08Metadata\x12\n\n\x02id\x18\x01 \x01(\t\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x12\n\x05owner\x18\x03 \x01(\tH\x00\x88\x01\x01\x42\x08\n\x06_owner\"\xbf\x01\n\rSessionStatus\x12\"\n\x05state\x18\x01 \x01(\x0e\x32\x13.flame.SessionState\x12\x15\n\rcreation_time\x18\x02 \x01(\x03\x12\x1c\n\x0f\x63ompletion_time\x18\x03 \x01(\x03H\x00\x88\x01\x01\x12\x0f\n\x07pending\x18\x04 \x01(\x05\x12\x0f\n\x07running\x18\x05 \x01(\x05\x12\x0f\n\x07succeed\x18\x06 \x01(\x05\x12\x0e\n\x06\x66\x61iled\x18\x07 \x01(\x05\x42\x12\n\x10_completion_time\"[\n\x0bSessionSpec\x12\x13\n\x0b\x61pplication\x18\x02 \x01(\t\x12\r\n\x05slots\x18\x03 \x01(\x05\x12\x18\n\x0b\x63ommon_data\x18\x04 \x01(\x0cH\x00\x88\x01\x01\x42\x0e\n\x0c_common_data\"t\n\x07Session\x12!\n\x08metadata\x18\x01 \x01(\x0b\x32\x0f.flame.Metadata\x12 \n\x04spec\x18\x02 \x01(\x0b\x32\x12.flame.SessionSpec\x12$\n\x06status\x18\x03 \x01(\x0b\x32\x14.flame.SessionStatus\"v\n\nTaskStatus\x12\x1f\n\x05state\x18\x01 \x01(\x0e\x32\x10.flame.TaskState\x12\x15\n\rcreation_time\x18\x02 \x01(\x03\x12\x1c\n\x0f\x63ompletion_time\x18\x03 \x01(\x03H\x00\x88\x01\x01\x42\x12\n\x10_completion_time\"\\\n\x08TaskSpec\x12\x12\n\nsession_id\x18\x02 \x01(\t\x12\x12\n\x05input\x18\x03 \x01(\x0cH\x00\x88\x01\x01\x12\x13\n\x06output\x18\x04 \x01(\x0cH\x01\x88\x01\x01\x42\x08\n\x06_inputB\t\n\x07_output\"k\n\x04Task\x12!\n\x08metadata\x18\x01 \x01(\x0b\x32\x0f.flame.Metadata\x12\x1d\n\x04spec\x18\x02 \x01(\x0b\x32\x0f.flame.TaskSpec\x12!\n\x06status\x18\x03 \x01(\x0b\x32\x11.flame.TaskStatus\"R\n\x11\x41pplicationStatus\x12&\n\x05state\x18\x01 \x01(\x0e\x32\x17.flame.ApplicationState\x12\x15\n\rcreation_time\x18\x02 \x01(\x03\"*\n\x0b\x45nvironment\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t\"{\n\x11\x41pplicationSchema\x12\x12\n\x05input\x18\x01 \x01(\tH\x00\x88\x01\x01\x12\x13\n\x06output\x18\x02 \x01(\tH\x01\x88\x01\x01\x12\x18\n\x0b\x63ommon_data\x18\x03 \x01(\tH\x02\x88\x01\x01\x42\x08\n\x06_inputB\t\n\x07_outputB\x0e\n\x0c_common_data\"\xaf\x03\n\x0f\x41pplicationSpec\x12\x19\n\x04shim\x18\x01 \x01(\x0e\x32\x0b.flame.Shim\x12\x18\n\x0b\x64\x65scription\x18\x02 \x01(\tH\x00\x88\x01\x01\x12\x0e\n\x06labels\x18\x03 \x03(\t\x12\x12\n\x05image\x18\x04 \x01(\tH\x01\x88\x01\x01\x12\x14\n\x07\x63ommand\x18\x05 \x01(\tH\x02\x88\x01\x01\x12\x11\n\targuments\x18\x06 \x03(\t\x12(\n\x0c\x65nvironments\x18\x07 \x03(\x0b\x32\x12.flame.Environment\x12\x1e\n\x11working_directory\x18\x08 \x01(\tH\x03\x88\x01\x01\x12\x1a\n\rmax_instances\x18\t \x01(\x05H\x04\x88\x01\x01\x12\x1a\n\rdelay_release\x18\n \x01(\x03H\x05\x88\x01\x01\x12-\n\x06schema\x18\x0b \x01(\x0b\x32\x18.flame.ApplicationSchemaH\x06\x88\x01\x01\x42\x0e\n\x0c_descriptionB\x08\n\x06_imageB\n\n\x08_commandB\x14\n\x12_working_directoryB\x10\n\x0e_max_instancesB\x10\n\x0e_delay_releaseB\t\n\x07_schema\"\x80\x01\n\x0b\x41pplication\x12!\n\x08metadata\x18\x01 \x01(\x0b\x32\x0f.flame.Metadata\x12$\n\x04spec\x18\x02 \x01(\x0b\x32\x16.flame.ApplicationSpec\x12(\n\x06status\x18\x03 \x01(\x0b\x32\x18.flame.ApplicationStatus\"H\n\x0c\x45xecutorSpec\x12\x0c\n\x04node\x18\x01 \x01(\t\x12*\n\x06resreq\x18\x02 \x01(\x0b\x32\x1a.flame.ResourceRequirement\"5\n\x0e\x45xecutorStatus\x12#\n\x05state\x18\x01 \x01(\x0e\x32\x14.flame.ExecutorState\"w\n\x08\x45xecutor\x12!\n\x08metadata\x18\x01 \x01(\x0b\x32\x0f.flame.Metadata\x12!\n\x04spec\x18\x02 \x01(\x0b\x32\x13.flame.ExecutorSpec\x12%\n\x06status\x18\x03 \x01(\x0b\x32\x15.flame.ExecutorStatus\"/\n\x0bSessionList\x12 \n\x08sessions\x18\x01 \x03(\x0b\x32\x0e.flame.Session\";\n\x0f\x41pplicationList\x12(\n\x0c\x61pplications\x18\x01 \x03(\x0b\x32\x12.flame.Application\"2\n\x13ResourceRequirement\x12\x0b\n\x03\x63pu\x18\x01 \x01(\x04\x12\x0e\n\x06memory\x18\x02 \x01(\x04\"\n\n\x08NodeSpec\"$\n\x08NodeInfo\x12\x0c\n\x04\x61rch\x18\x01 \x01(\t\x12\n\n\x02os\x18\x02 \x01(\t\"\xab\x01\n\nNodeStatus\x12\x1f\n\x05state\x18\x01 \x01(\x0e\x32\x10.flame.NodeState\x12,\n\x08\x63\x61pacity\x18\x02 \x01(\x0b\x32\x1a.flame.ResourceRequirement\x12/\n\x0b\x61llocatable\x18\x03 \x01(\x0b\x32\x1a.flame.ResourceRequirement\x12\x1d\n\x04info\x18\x04 \x01(\x0b\x32\x0f.flame.NodeInfo\"k\n\x04Node\x12!\n\x08metadata\x18\x01 \x01(\x0b\x32\x0f.flame.Metadata\x12\x1d\n\x04spec\x18\x02 \x01(\x0b\x32\x0f.flame.NodeSpec\x12!\n\x06status\x18\x03 \x01(\x0b\x32\x11.flame.NodeStatus\"?\n\x06Result\x12\x13\n\x0breturn_code\x18\x01 \x01(\x05\x12\x14\n\x07message\x18\x02 \x01(\tH\x00\x88\x01\x01\x42\n\n\x08_message\"\x0e\n\x0c\x45mptyRequest*$\n\x0cSessionState\x12\x08\n\x04Open\x10\x00\x12\n\n\x06\x43losed\x10\x01*>\n\tTaskState\x12\x0b\n\x07Pending\x10\x00\x12\x0b\n\x07Running\x10\x01\x12\x0b\n\x07Succeed\x10\x02\x12\n\n\x06\x46\x61iled\x10\x03*9\n\x04Shim\x12\x07\n\x03Log\x10\x00\x12\t\n\x05Stdio\x10\x01\x12\x08\n\x04Wasm\x10\x02\x12\t\n\x05Shell\x10\x03\x12\x08\n\x04Grpc\x10\x04*-\n\x10\x41pplicationState\x12\x0b\n\x07\x45nabled\x10\x00\x12\x0c\n\x08\x44isabled\x10\x01*\xb4\x01\n\rExecutorState\x12\x13\n\x0f\x45xecutorUnknown\x10\x00\x12\x10\n\x0c\x45xecutorVoid\x10\x01\x12\x10\n\x0c\x45xecutorIdle\x10\x02\x12\x13\n\x0f\x45xecutorBinding\x10\x03\x12\x11\n\rExecutorBound\x10\x04\x12\x15\n\x11\x45xecutorUnbinding\x10\x05\x12\x15\n\x11\x45xecutorReleasing\x10\x06\x12\x14\n\x10\x45xecutorReleased\x10\x07*1\n\tNodeState\x12\x0b\n\x07Unknown\x10\x00\x12\t\n\x05Ready\x10\x01\x12\x0c\n\x08NotReady\x10\x02\x42&Z$github.com/flame-sh/flame/sdk/go/rpcb\x06proto3')
28
+
29
+ _globals = globals()
30
+ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
31
+ _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'types_pb2', _globals)
32
+ if not _descriptor._USE_C_DESCRIPTORS:
33
+ _globals['DESCRIPTOR']._loaded_options = None
34
+ _globals['DESCRIPTOR']._serialized_options = b'Z$github.com/flame-sh/flame/sdk/go/rpc'
35
+ _globals['_SESSIONSTATE']._serialized_start=2462
36
+ _globals['_SESSIONSTATE']._serialized_end=2498
37
+ _globals['_TASKSTATE']._serialized_start=2500
38
+ _globals['_TASKSTATE']._serialized_end=2562
39
+ _globals['_SHIM']._serialized_start=2564
40
+ _globals['_SHIM']._serialized_end=2621
41
+ _globals['_APPLICATIONSTATE']._serialized_start=2623
42
+ _globals['_APPLICATIONSTATE']._serialized_end=2668
43
+ _globals['_EXECUTORSTATE']._serialized_start=2671
44
+ _globals['_EXECUTORSTATE']._serialized_end=2851
45
+ _globals['_NODESTATE']._serialized_start=2853
46
+ _globals['_NODESTATE']._serialized_end=2902
47
+ _globals['_METADATA']._serialized_start=22
48
+ _globals['_METADATA']._serialized_end=88
49
+ _globals['_SESSIONSTATUS']._serialized_start=91
50
+ _globals['_SESSIONSTATUS']._serialized_end=282
51
+ _globals['_SESSIONSPEC']._serialized_start=284
52
+ _globals['_SESSIONSPEC']._serialized_end=375
53
+ _globals['_SESSION']._serialized_start=377
54
+ _globals['_SESSION']._serialized_end=493
55
+ _globals['_TASKSTATUS']._serialized_start=495
56
+ _globals['_TASKSTATUS']._serialized_end=613
57
+ _globals['_TASKSPEC']._serialized_start=615
58
+ _globals['_TASKSPEC']._serialized_end=707
59
+ _globals['_TASK']._serialized_start=709
60
+ _globals['_TASK']._serialized_end=816
61
+ _globals['_APPLICATIONSTATUS']._serialized_start=818
62
+ _globals['_APPLICATIONSTATUS']._serialized_end=900
63
+ _globals['_ENVIRONMENT']._serialized_start=902
64
+ _globals['_ENVIRONMENT']._serialized_end=944
65
+ _globals['_APPLICATIONSCHEMA']._serialized_start=946
66
+ _globals['_APPLICATIONSCHEMA']._serialized_end=1069
67
+ _globals['_APPLICATIONSPEC']._serialized_start=1072
68
+ _globals['_APPLICATIONSPEC']._serialized_end=1503
69
+ _globals['_APPLICATION']._serialized_start=1506
70
+ _globals['_APPLICATION']._serialized_end=1634
71
+ _globals['_EXECUTORSPEC']._serialized_start=1636
72
+ _globals['_EXECUTORSPEC']._serialized_end=1708
73
+ _globals['_EXECUTORSTATUS']._serialized_start=1710
74
+ _globals['_EXECUTORSTATUS']._serialized_end=1763
75
+ _globals['_EXECUTOR']._serialized_start=1765
76
+ _globals['_EXECUTOR']._serialized_end=1884
77
+ _globals['_SESSIONLIST']._serialized_start=1886
78
+ _globals['_SESSIONLIST']._serialized_end=1933
79
+ _globals['_APPLICATIONLIST']._serialized_start=1935
80
+ _globals['_APPLICATIONLIST']._serialized_end=1994
81
+ _globals['_RESOURCEREQUIREMENT']._serialized_start=1996
82
+ _globals['_RESOURCEREQUIREMENT']._serialized_end=2046
83
+ _globals['_NODESPEC']._serialized_start=2048
84
+ _globals['_NODESPEC']._serialized_end=2058
85
+ _globals['_NODEINFO']._serialized_start=2060
86
+ _globals['_NODEINFO']._serialized_end=2096
87
+ _globals['_NODESTATUS']._serialized_start=2099
88
+ _globals['_NODESTATUS']._serialized_end=2270
89
+ _globals['_NODE']._serialized_start=2272
90
+ _globals['_NODE']._serialized_end=2379
91
+ _globals['_RESULT']._serialized_start=2381
92
+ _globals['_RESULT']._serialized_end=2444
93
+ _globals['_EMPTYREQUEST']._serialized_start=2446
94
+ _globals['_EMPTYREQUEST']._serialized_end=2460
95
+ # @@protoc_insertion_point(module_scope)
@@ -0,0 +1,24 @@
1
+ # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
2
+ """Client and server classes corresponding to protobuf-defined services."""
3
+ import grpc
4
+ import warnings
5
+
6
+
7
+ GRPC_GENERATED_VERSION = '1.74.0'
8
+ GRPC_VERSION = grpc.__version__
9
+ _version_not_supported = False
10
+
11
+ try:
12
+ from grpc._utilities import first_version_is_lower
13
+ _version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
14
+ except ImportError:
15
+ _version_not_supported = True
16
+
17
+ if _version_not_supported:
18
+ raise RuntimeError(
19
+ f'The grpc package installed is at version {GRPC_VERSION},'
20
+ + f' but the generated code in types_pb2_grpc.py depends on'
21
+ + f' grpcio>={GRPC_GENERATED_VERSION}.'
22
+ + f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
23
+ + f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
24
+ )
@@ -0,0 +1,177 @@
1
+ Metadata-Version: 2.4
2
+ Name: flamepy
3
+ Version: 0.3.0
4
+ Summary: Python SDK for Flame distributed engine
5
+ Author-email: XFLOPS Authors <support@xflops.io>
6
+ Project-URL: Homepage, https://xflops.io
7
+ Project-URL: Repository, https://github.com/xflops/flame
8
+ Project-URL: Issues, https://github.com/xflops/flame/issues
9
+ Keywords: distributed computing,flame,sdk
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Requires-Python: >=3.8
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: grpcio>=1.50.0
22
+ Requires-Dist: grpcio-tools>=1.50.0
23
+ Requires-Dist: protobuf>=4.21.0
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
26
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
27
+ Requires-Dist: black>=22.0.0; extra == "dev"
28
+ Requires-Dist: isort>=5.0.0; extra == "dev"
29
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
30
+ Dynamic: license-file
31
+
32
+ # Flame Python SDK
33
+
34
+ Python SDK for the Flame distributed computing framework.
35
+
36
+ ## Installation
37
+
38
+ ```bash
39
+ pip install flamepy
40
+ ```
41
+
42
+ ## Quick Start
43
+
44
+ ```python
45
+ import asyncio
46
+ from flamepy import SessionAttributes, connect
47
+
48
+ async def main():
49
+ # Connect to Flame service
50
+ conn = await connect("http://localhost:8080")
51
+ # Create a session
52
+ session = await conn.create_session(SessionAttributes(
53
+ application="flmlog",
54
+ slots=2,
55
+ common_data=b"shared data"
56
+ ))
57
+
58
+ # Create and run a task
59
+ task = await session.create_task(b"task input data")
60
+
61
+ # Watch task progress
62
+ async for update in session.watch_task(task.id):
63
+ print(f"Task {task.id}: {update.state}")
64
+ if update.is_completed():
65
+ break
66
+
67
+ # Close session
68
+ await session.close()
69
+ await conn.close()
70
+
71
+ if __name__ == "__main__":
72
+ asyncio.run(main())
73
+ ```
74
+
75
+ ## API Reference
76
+
77
+ ### Connection
78
+
79
+ The main entry point for connecting to Flame services.
80
+
81
+ ```python
82
+ from flamepy import connect
83
+
84
+ # Connect to a Flame service
85
+ conn = await connect("http://localhost:8080")
86
+ ```
87
+
88
+ ### Session
89
+
90
+ Represents a computing session with distributed resources.
91
+
92
+ ```python
93
+ # Create a session
94
+ session = await conn.create_session(SessionAttributes(
95
+ application="my-app",
96
+ slots=2
97
+ ))
98
+
99
+ # List sessions
100
+ sessions = await conn.list_sessions()
101
+
102
+ # Close a session
103
+ await session.close()
104
+ ```
105
+
106
+ ### Task
107
+
108
+ Represents individual computing tasks within a session.
109
+
110
+ ```python
111
+ # Create a task
112
+ task = await session.create_task(b"input data")
113
+
114
+ # Get task status
115
+ task = await session.get_task(task.id)
116
+
117
+ # Watch task progress
118
+ async for update in session.watch_task(task.id):
119
+ print(f"Task state: {update.state}")
120
+ if update.is_completed():
121
+ break
122
+ ```
123
+
124
+ ### Application
125
+
126
+ Manage distributed applications.
127
+
128
+ ```python
129
+ # Register an application
130
+ await conn.register_application("my-app", {
131
+ "shim": Shim.SHELL,
132
+ "command": "python",
133
+ "arguments": ["script.py"]
134
+ })
135
+
136
+ # List applications
137
+ apps = await conn.list_applications()
138
+ ```
139
+
140
+ ## Error Handling
141
+
142
+ The SDK provides custom exception types for different error scenarios:
143
+
144
+ ```python
145
+ from flamepy import FlameError, FlameErrorCode
146
+
147
+ try:
148
+ session = await conn.create_session(attrs)
149
+ except FlameError as e:
150
+ if e.code == FlameErrorCode.INVALID_CONFIG:
151
+ print("Configuration error:", e.message)
152
+ elif e.code == FlameErrorCode.INVALID_STATE:
153
+ print("State error:", e.message)
154
+ ```
155
+
156
+ ## Development
157
+
158
+ To set up the development environment:
159
+
160
+ ```bash
161
+ # Clone the repository
162
+ git clone https://github.com/flame-sh/flame.git
163
+ cd flame/sdk/python
164
+
165
+ # Install in development mode
166
+ pip install -e .[dev]
167
+
168
+ # Run tests
169
+ pytest
170
+
171
+ # Format code
172
+ black flamepy/
173
+ isort flamepy/
174
+
175
+ # Type checking
176
+ mypy flamepy/
177
+ ```
@@ -0,0 +1,16 @@
1
+ flamepy/__init__.py,sha256=PMuzND37jkn5K1jayDlglru-qt4YKzPwLoPyi4OfcCo,1357
2
+ flamepy/client.py,sha256=QwjWb-A2mAONO15JKcp-aPPtudkyd4kW4Clm_Hfba2Y,16252
3
+ flamepy/frontend_pb2.py,sha256=19qOu_MlpLIKDijKa6YDG4_obhskFpgao5retIzKwWw,5690
4
+ flamepy/frontend_pb2_grpc.py,sha256=3nsBRYtMH1bfovAGsj7lr5oPpHOAMCMra72P-We9aPA,27069
5
+ flamepy/service.py,sha256=uD9lCGFp_2phSD4ltgGRHT07QahCGiNzqs47lk0cTPU,6394
6
+ flamepy/shim_pb2.py,sha256=rdLpx-801R9h7s5aq6AAtuptbFFjOOZGYRw30SJE4Gc,2818
7
+ flamepy/shim_pb2_grpc.py,sha256=ECumxSqSB4QRZKFbKadiqQ6DHvB0hJjkxpAA7TM80jM,6679
8
+ flamepy/test_flame.py,sha256=V3924vcFbh1k5srK3l4IegXcmoYWcA4P24vBv3YXMrE,6070
9
+ flamepy/types.py,sha256=R5OdQzNm9x7b14nwECY85lXdjOVhLFZHuZTnQntDt3s,3717
10
+ flamepy/types_pb2.py,sha256=_lD5RTAoFqWBKukG8MVxVrUtLe_Uc0xOOqWjSXme3nk,9546
11
+ flamepy/types_pb2_grpc.py,sha256=EPv87wCc-6BNJ2xTNcb9d3ictDerK5cBt7qhd7EmJiQ,886
12
+ flamepy-0.3.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
13
+ flamepy-0.3.0.dist-info/METADATA,sha256=-yTAG5A2zDP_nlJJmkZRMvUmvoCy10QeaG6C-4de4Zc,3958
14
+ flamepy-0.3.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
15
+ flamepy-0.3.0.dist-info/top_level.txt,sha256=q0Ya0PnT5plH3njeZDSUfwSS_j6YJmTs3isV3wNYzR8,8
16
+ flamepy-0.3.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+