jax-pyjit 0.0.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.
@@ -0,0 +1,39 @@
1
+ Metadata-Version: 2.1
2
+ Name: jax-pyjit
3
+ Version: 0.0.1
4
+ Summary: JIT python bindings including the client and data access objects
5
+ License: Apache-2.0
6
+ Author: Matthew Gerring
7
+ Author-email: matthew.gerring@jax.org
8
+ Requires-Python: >=3.11
9
+ Classifier: License :: OSI Approved :: Apache Software License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Requires-Dist: requests (>=2.32.5,<3.0.0)
14
+ Description-Content-Type: text/markdown
15
+
16
+ # JAX Image Tools (JIT) Python API 'pyjit'
17
+
18
+ ## Introduction
19
+ The pyjit package contains code common to jit tools, mostly DL and AI tools.
20
+ There are common dao packages which each tool consumes to reduce code copying.
21
+ These are required
22
+
23
+ ## Quick Start
24
+ ### Install
25
+
26
+ poetry add pyjit
27
+
28
+
29
+ ### Usage for Common Tools
30
+
31
+ from jax.pyjit.dao import StorageKey
32
+ This provides an easy way to create json objects used with the JIT server.
33
+
34
+ ### Usage of JIT Client
35
+ pyjit will also contain a requests-based client one day similar to the JIT Shell.
36
+
37
+
38
+
39
+
@@ -0,0 +1,23 @@
1
+ # JAX Image Tools (JIT) Python API 'pyjit'
2
+
3
+ ## Introduction
4
+ The pyjit package contains code common to jit tools, mostly DL and AI tools.
5
+ There are common dao packages which each tool consumes to reduce code copying.
6
+ These are required
7
+
8
+ ## Quick Start
9
+ ### Install
10
+
11
+ poetry add pyjit
12
+
13
+
14
+ ### Usage for Common Tools
15
+
16
+ from jax.pyjit.dao import StorageKey
17
+ This provides an easy way to create json objects used with the JIT server.
18
+
19
+ ### Usage of JIT Client
20
+ pyjit will also contain a requests-based client one day similar to the JIT Shell.
21
+
22
+
23
+
@@ -0,0 +1,26 @@
1
+ [tool.poetry]
2
+ name = "jax-pyjit"
3
+ version = "0.0.1"
4
+ description = "JIT python bindings including the client and data access objects"
5
+ authors = ["Matthew Gerring <matthew.gerring@jax.org>"]
6
+ license = "Apache-2.0"
7
+ readme = "README.md"
8
+
9
+ # Tell Poetry to include the jax package from src/
10
+ packages = [
11
+ { include = "jax", from = "src" }
12
+ ]
13
+
14
+ [tool.poetry.dependencies]
15
+ python = ">=3.11"
16
+ requests = ">=2.32.5,<3.0.0"
17
+
18
+ [tool.poetry.group.dev.dependencies]
19
+ ruff = ">=0.13.2,<0.14.0"
20
+ black = ">=25.9.0,<26.0.0"
21
+ pytest = "^8.4.2"
22
+ pytest-cov = "^7.0.0"
23
+
24
+ [build-system]
25
+ requires = ["poetry-core>=2.0.0,<3.0.0"]
26
+ build-backend = "poetry.core.masonry.api"
File without changes
@@ -0,0 +1,94 @@
1
+ from dataclasses import dataclass, field
2
+ from typing import List, Optional, Any
3
+ from pathlib import Path
4
+ from enum import Enum
5
+
6
+ import os
7
+
8
+
9
+ class State:
10
+ SUBMITTED: str = "SUBMITTED"
11
+ RUNNING: str = "RUNNING"
12
+ COMPLETE: str = "COMPLETE"
13
+ ERROR: str = "ERROR"
14
+ NONE: str = "NONE"
15
+ CANCELLED: str = "CANCELLED"
16
+
17
+
18
+ @dataclass
19
+ class AbstractStatus:
20
+ """
21
+ Based on cimg-api/org.jax.cimg.api.evt.AbstractStatus
22
+ which we use in Image Tools.
23
+ These fields are shared across multiple tools.
24
+ Do not change them.
25
+ """
26
+ message: Optional[str] = None
27
+ state: str = State.NONE
28
+ complete: float = 0
29
+ errorStack: Optional[str] = None
30
+ workflowId: Optional[str] = None
31
+ results: List[str] = field(default_factory=lambda: [""])
32
+ submissionInput: Optional[str] = None
33
+ userName: Optional[str] = None
34
+
35
+
36
+ class Protocol(str, Enum):
37
+ GS = "GS"
38
+ S3 = "S3"
39
+ NIO = "NIO"
40
+
41
+ @dataclass
42
+ class StorageKey:
43
+
44
+ bucket: str
45
+ object: str
46
+ protocol: str = Protocol.GS
47
+ endpoint: Optional[str] = None
48
+ test: Optional[bool] = False
49
+
50
+ def to_uri(self, create=False) -> str:
51
+ if self._is_local():
52
+ file_path: str = None
53
+ if self.endpoint is None:
54
+ file_path: str = "{}/{}".format(self.bucket, self.object)
55
+ else:
56
+ file_path: str = "{}/{}/{}".format(
57
+ self.endpoint, self.bucket, self.object
58
+ )
59
+
60
+ NIO_STORAGE_ROOT: str = os.getenv("NIO_STORAGE_ROOT", None)
61
+ if NIO_STORAGE_ROOT:
62
+ file_path = "{}/{}".format(NIO_STORAGE_ROOT, file_path)
63
+
64
+ # Remove double slashes
65
+ file_path = file_path.replace("//", "/")
66
+
67
+ if create:
68
+ path: Path = Path(file_path)
69
+ os.makedirs(path.parent, exist_ok=True)
70
+ path.touch(exist_ok=True)
71
+ return file_path
72
+ else:
73
+ return f"{self.protocol.lower()}://{self.bucket}/{self.object}"
74
+
75
+ def _is_local(self) -> bool:
76
+ if self.protocol == Protocol.NIO:
77
+ return True
78
+ if self.test:
79
+ return True
80
+
81
+ USE_NIO_STORAGE: bool = bool(os.getenv("USE_NIO_STORAGE", None))
82
+ if USE_NIO_STORAGE:
83
+ return True
84
+ return False
85
+
86
+
87
+ @dataclass
88
+ class Input:
89
+ image: StorageKey
90
+ request: Any
91
+ result: Optional[Any] = None
92
+
93
+ def emptyKey() -> StorageKey:
94
+ return StorageKey("", "", test=True)