blaxel 0.1.14rc48__py3-none-any.whl → 0.1.14rc49__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,55 @@
1
+ import argparse
2
+ import os
3
+ import sys
4
+ import asyncio
5
+ from typing import Any, Dict, Callable
6
+ import requests
7
+
8
+ class BlJob:
9
+ def get_arguments(self) -> Dict[str, Any]:
10
+ if not os.getenv('BL_EXECUTION_DATA_URL'):
11
+ parser = argparse.ArgumentParser()
12
+ # Parse known args, ignore unknown
13
+ args, unknown = parser.parse_known_args()
14
+ # Convert to dict and include unknown args
15
+ args_dict = vars(args)
16
+ # Add unknown args to dict
17
+ for i in range(0, len(unknown), 2):
18
+ if i + 1 < len(unknown):
19
+ key = unknown[i].lstrip('-')
20
+ args_dict[key] = unknown[i + 1]
21
+ return args_dict
22
+
23
+ response = requests.get(os.getenv('BL_EXECUTION_DATA_URL'))
24
+ data = response.json()
25
+ tasks = data.get('tasks', [])
26
+ return tasks[self.index] if self.index < len(tasks) else {}
27
+
28
+ @property
29
+ def index_key(self) -> str:
30
+ return os.getenv('BL_EXECUTION_INDEX_KEY', 'TASK_INDEX')
31
+
32
+ @property
33
+ def index(self) -> int:
34
+ index_value = os.getenv(self.index_key)
35
+ return int(index_value) if index_value else 0
36
+
37
+ def start(self, func: Callable):
38
+ """
39
+ Run a job defined in a function, it's run in the current process.
40
+ Handles both async and sync functions.
41
+ Arguments are passed as keyword arguments to the function.
42
+ """
43
+ try:
44
+ parsed_args = self.get_arguments()
45
+ if asyncio.iscoroutinefunction(func):
46
+ asyncio.run(func(**parsed_args))
47
+ else:
48
+ func(**parsed_args)
49
+ sys.exit(0)
50
+ except Exception as error:
51
+ print('Job execution failed:', error, file=sys.stderr)
52
+ sys.exit(1)
53
+
54
+ # Create a singleton instance
55
+ bl_job = BlJob()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: blaxel
3
- Version: 0.1.14rc48
3
+ Version: 0.1.14rc49
4
4
  Summary: Add your description here
5
5
  Author-email: cploujoux <cploujoux@blaxel.ai>
6
6
  License-File: LICENSE
@@ -270,6 +270,7 @@ blaxel/instrumentation/log.py,sha256=4tGyvLg6r4DbjqJfajYbbZ1toUzF4Q4H7kHVqYWFAEA
270
270
  blaxel/instrumentation/manager.py,sha256=jVwVasyMI6tu0zv27DVYOaN57nXYuHFJ8QzJQKaNoK4,8880
271
271
  blaxel/instrumentation/map.py,sha256=zZoiUiQHmik5WQZ4VCWNARSa6ppMi0r7D6hlb41N-Mg,1589
272
272
  blaxel/instrumentation/span.py,sha256=X2lwfu_dyxwQTMQJT2vbXOrbVSChEhjRLc413QOxQJM,3244
273
+ blaxel/jobs/__init__.py,sha256=r4p2tYz8fCKzDGynLTq55KFSjdSIxhxjnarQf4hdMWI,1838
273
274
  blaxel/mcp/__init__.py,sha256=KednMrtuc4Y0O3lv7u1Lla54FCk8UX9c1k0USjL3Ahk,69
274
275
  blaxel/mcp/client.py,sha256=cFFXfpKXoMu8qTUly2ejF0pX2iBQkSNAxqwvDV1V6xY,4979
275
276
  blaxel/mcp/server.py,sha256=GIldtA_NgIc2dzd7ZpPvpbhpIt_7AfKu5yS_YJ0bDGg,7310
@@ -340,7 +341,7 @@ blaxel/tools/llamaindex.py,sha256=-gQ-C9V_h9a11J4ItsbWjXrCJOg0lRKsb98v9rVsNak,71
340
341
  blaxel/tools/openai.py,sha256=GuFXkj6bXEwldyVr89jEsRAi5ihZUVEVe327QuWiGNs,653
341
342
  blaxel/tools/pydantic.py,sha256=CvnNbAG_J4yBtA-XFI4lQrq3FYKjNd39hu841vZT004,1801
342
343
  blaxel/tools/types.py,sha256=YPCGJ4vZDhqR0X2H_TWtc5chQScsC32nGTQdRKJlO8Y,707
343
- blaxel-0.1.14rc48.dist-info/METADATA,sha256=V8dnLg7IzMcr9dO9vLzcHEbUYLTBtr_zh8wV2eN3A7g,11776
344
- blaxel-0.1.14rc48.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
345
- blaxel-0.1.14rc48.dist-info/licenses/LICENSE,sha256=p5PNQvpvyDT_0aYBDgmV1fFI_vAD2aSV0wWG7VTgRis,1069
346
- blaxel-0.1.14rc48.dist-info/RECORD,,
344
+ blaxel-0.1.14rc49.dist-info/METADATA,sha256=bHnlyUsxdqIUhNObViKa-vYfKSwQ8Ge2NB0Me_pC4zg,11776
345
+ blaxel-0.1.14rc49.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
346
+ blaxel-0.1.14rc49.dist-info/licenses/LICENSE,sha256=p5PNQvpvyDT_0aYBDgmV1fFI_vAD2aSV0wWG7VTgRis,1069
347
+ blaxel-0.1.14rc49.dist-info/RECORD,,