pyglove 0.4.5.dev202507110810__py3-none-any.whl → 0.4.5.dev202507122122__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.
- pyglove/core/coding/execution.py +3 -2
- pyglove/core/coding/permissions.py +17 -16
- pyglove/core/io/file_system_test.py +6 -6
- pyglove/core/symbolic/functor.py +3 -4
- pyglove/core/utils/docstr_utils_test.py +0 -1
- pyglove/core/utils/json_conversion.py +1 -0
- pyglove/core/utils/timing_test.py +1 -1
- {pyglove-0.4.5.dev202507110810.dist-info → pyglove-0.4.5.dev202507122122.dist-info}/METADATA +1 -1
- {pyglove-0.4.5.dev202507110810.dist-info → pyglove-0.4.5.dev202507122122.dist-info}/RECORD +12 -12
- {pyglove-0.4.5.dev202507110810.dist-info → pyglove-0.4.5.dev202507122122.dist-info}/WHEEL +0 -0
- {pyglove-0.4.5.dev202507110810.dist-info → pyglove-0.4.5.dev202507122122.dist-info}/licenses/LICENSE +0 -0
- {pyglove-0.4.5.dev202507110810.dist-info → pyglove-0.4.5.dev202507122122.dist-info}/top_level.txt +0 -0
pyglove/core/coding/execution.py
CHANGED
@@ -198,8 +198,9 @@ def sandbox_call(
|
|
198
198
|
except Exception as e: # pylint: disable=broad-exception-caught
|
199
199
|
q.put(e)
|
200
200
|
|
201
|
-
|
202
|
-
|
201
|
+
ctx = multiprocessing.get_context('fork')
|
202
|
+
q = ctx.Queue()
|
203
|
+
p = ctx.Process(
|
203
204
|
target=_call, args=tuple([q] + list(args)), kwargs=kwargs
|
204
205
|
)
|
205
206
|
try:
|
@@ -20,7 +20,23 @@ from typing import Optional
|
|
20
20
|
from pyglove.core import utils
|
21
21
|
|
22
22
|
|
23
|
-
class
|
23
|
+
class CodePermissionMeta(enum.EnumMeta):
|
24
|
+
|
25
|
+
@property
|
26
|
+
def BASIC(cls) -> 'CodePermission': # pylint: disable=invalid-name
|
27
|
+
"""Returns basic permissions."""
|
28
|
+
return cls.ASSIGN | cls.CALL # pytype: disable=attribute-error
|
29
|
+
|
30
|
+
@property
|
31
|
+
def ALL(cls) -> 'CodePermission': # pylint: disable=invalid-name
|
32
|
+
"""Returns all permissions."""
|
33
|
+
return (
|
34
|
+
cls.BASIC | cls.CONDITION | cls.LOOP | cls.EXCEPTION | # pytype: disable=attribute-error
|
35
|
+
cls.CLASS_DEFINITION | cls.FUNCTION_DEFINITION | cls.IMPORT # pytype: disable=attribute-error
|
36
|
+
)
|
37
|
+
|
38
|
+
|
39
|
+
class CodePermission(enum.Flag, metaclass=CodePermissionMeta):
|
24
40
|
"""Permissions for code execution."""
|
25
41
|
|
26
42
|
# Allows assignment.
|
@@ -47,21 +63,6 @@ class CodePermission(enum.Flag):
|
|
47
63
|
# Allows import.
|
48
64
|
IMPORT = enum.auto()
|
49
65
|
|
50
|
-
@classmethod
|
51
|
-
@property
|
52
|
-
def BASIC(cls) -> 'CodePermission': # pylint: disable=invalid-name
|
53
|
-
"""Returns basic permissions."""
|
54
|
-
return CodePermission.ASSIGN | CodePermission.CALL
|
55
|
-
|
56
|
-
@classmethod
|
57
|
-
@property
|
58
|
-
def ALL(cls) -> 'CodePermission': # pylint: disable=invalid-name
|
59
|
-
"""Returns all permissions."""
|
60
|
-
return (
|
61
|
-
CodePermission.BASIC | CodePermission.CONDITION | CodePermission.LOOP |
|
62
|
-
CodePermission.EXCEPTION | CodePermission.CLASS_DEFINITION |
|
63
|
-
CodePermission.FUNCTION_DEFINITION | CodePermission.IMPORT)
|
64
|
-
|
65
66
|
|
66
67
|
_TLS_CODE_RUN_PERMISSION = '__code_run_permission__'
|
67
68
|
|
@@ -22,7 +22,7 @@ from pyglove.core.io import file_system
|
|
22
22
|
class StdFileSystemTest(unittest.TestCase):
|
23
23
|
|
24
24
|
def test_file(self):
|
25
|
-
tmp_dir = tempfile.
|
25
|
+
tmp_dir = tempfile.mkdtemp()
|
26
26
|
fs = file_system.StdFileSystem()
|
27
27
|
|
28
28
|
file1 = os.path.join(tmp_dir, 'file1')
|
@@ -44,7 +44,7 @@ class StdFileSystemTest(unittest.TestCase):
|
|
44
44
|
self.assertFalse(fs.exists(file1))
|
45
45
|
|
46
46
|
def test_file_system(self):
|
47
|
-
tmp_dir = tempfile.
|
47
|
+
tmp_dir = tempfile.mkdtemp()
|
48
48
|
fs = file_system.StdFileSystem()
|
49
49
|
|
50
50
|
# Create a directory.
|
@@ -68,7 +68,7 @@ class StdFileSystemTest(unittest.TestCase):
|
|
68
68
|
# Test rm.
|
69
69
|
with self.assertRaises(FileNotFoundError):
|
70
70
|
fs.rm(os.path.join(dir_a, 'file2'))
|
71
|
-
with self.assertRaises(IsADirectoryError):
|
71
|
+
with self.assertRaises((IsADirectoryError, PermissionError)):
|
72
72
|
fs.rm(os.path.join(dir_a, 'b'))
|
73
73
|
|
74
74
|
# Test rmdir.
|
@@ -184,7 +184,7 @@ class MemoryFileSystemTest(unittest.TestCase):
|
|
184
184
|
class FileIoApiTest(unittest.TestCase):
|
185
185
|
|
186
186
|
def test_standard_filesystem(self):
|
187
|
-
file1 = os.path.join(tempfile.
|
187
|
+
file1 = os.path.join(tempfile.mkdtemp(), 'file1')
|
188
188
|
with self.assertRaises(FileNotFoundError):
|
189
189
|
file_system.readfile(file1)
|
190
190
|
self.assertIsNone(file_system.readfile(file1, nonexist_ok=True))
|
@@ -199,7 +199,7 @@ class FileIoApiTest(unittest.TestCase):
|
|
199
199
|
file_system.rm(file1)
|
200
200
|
self.assertFalse(file_system.path_exists(file1))
|
201
201
|
|
202
|
-
dir1 = os.path.join(tempfile.
|
202
|
+
dir1 = os.path.join(tempfile.mkdtemp(), 'dir1')
|
203
203
|
file_system.mkdir(dir1)
|
204
204
|
self.assertEqual(file_system.listdir(dir1), [])
|
205
205
|
file_system.mkdirs(os.path.join(dir1, 'a/b/c'))
|
@@ -208,7 +208,7 @@ class FileIoApiTest(unittest.TestCase):
|
|
208
208
|
self.assertEqual(sorted(file_system.listdir(dir1)), ['a', 'file2']) # pylint: disable=g-generic-assert
|
209
209
|
self.assertEqual( # pylint: disable=g-generic-assert
|
210
210
|
sorted(file_system.listdir(dir1, fullpath=True)),
|
211
|
-
['
|
211
|
+
[os.path.join(dir1, 'a'), os.path.join(dir1, 'file2')]
|
212
212
|
)
|
213
213
|
file_system.rmdir(os.path.join(dir1, 'a/b/c'))
|
214
214
|
file_system.rmdirs(os.path.join(dir1, 'a/b'))
|
pyglove/core/symbolic/functor.py
CHANGED
@@ -88,7 +88,6 @@ class Functor(pg_object.Object, utils.Functor):
|
|
88
88
|
#
|
89
89
|
|
90
90
|
@classmethod
|
91
|
-
@property
|
92
91
|
def is_subclassed_functor(cls) -> bool:
|
93
92
|
"""Returns True if this class is a subclassed Functor."""
|
94
93
|
return cls.auto_schema
|
@@ -96,7 +95,7 @@ class Functor(pg_object.Object, utils.Functor):
|
|
96
95
|
@classmethod
|
97
96
|
def _update_signatures_based_on_schema(cls):
|
98
97
|
# Update the return value of subclassed functors.
|
99
|
-
if cls.is_subclassed_functor: # pylint: disable=using-constant-test
|
98
|
+
if cls.is_subclassed_functor(): # pylint: disable=using-constant-test
|
100
99
|
private_call_signature = pg_typing.Signature.from_callable(
|
101
100
|
cls._call, auto_typing=True, auto_doc=True,
|
102
101
|
)
|
@@ -235,7 +234,7 @@ class Functor(pg_object.Object, utils.Functor):
|
|
235
234
|
|
236
235
|
# For subclassed Functor, we use thread-local storage for storing temporary
|
237
236
|
# member overrides from the arguments during functor call.
|
238
|
-
self._tls = threading.local() if self.is_subclassed_functor else None
|
237
|
+
self._tls = threading.local() if self.is_subclassed_functor() else None
|
239
238
|
|
240
239
|
def _sym_inferred(self, key: str, **kwargs: Any) -> Any:
|
241
240
|
"""Overrides method to allow member overrides during call."""
|
@@ -361,7 +360,7 @@ class Functor(pg_object.Object, utils.Functor):
|
|
361
360
|
args, kwargs = self._parse_call_time_overrides(*args, **kwargs)
|
362
361
|
signature = self.__signature__
|
363
362
|
|
364
|
-
if self.is_subclassed_functor:
|
363
|
+
if self.is_subclassed_functor():
|
365
364
|
for arg_spec, arg_value in zip(signature.args, args):
|
366
365
|
kwargs[arg_spec.name] = arg_value
|
367
366
|
|
@@ -624,6 +624,7 @@ def _method_to_json(f: types.MethodType) -> Dict[str, str]:
|
|
624
624
|
|
625
625
|
|
626
626
|
_SUPPORTED_ANNOTATIONS = {
|
627
|
+
typing.Annotated: 'typing.Annotated',
|
627
628
|
typing.Any: 'typing.Any',
|
628
629
|
typing.Sequence: 'typing.Sequence',
|
629
630
|
collections.abc.Sequence: 'typing.Sequence',
|
@@ -5,13 +5,13 @@ pyglove/core/logging_test.py,sha256=3z_c6wnxbqDbwUmSOAZzeDPXvzoweYL5QHUQVMJ5Xgo,
|
|
5
5
|
pyglove/core/coding/__init__.py,sha256=tuHIg19ZchtkOQbdFVTVLkUpBa5f1eo66XtnKw3lcIU,1645
|
6
6
|
pyglove/core/coding/errors.py,sha256=aP3Y4amBzOKdlb5JnESJ3kdoijQXbiBiPDMeA88LNrk,3310
|
7
7
|
pyglove/core/coding/errors_test.py,sha256=fwOR8vLiRvLadubsccyE19hLHj-kThlCQt88qmUYk9M,2311
|
8
|
-
pyglove/core/coding/execution.py,sha256=
|
8
|
+
pyglove/core/coding/execution.py,sha256=r-5C2bGXIeM9oZbz71dp1s_LFYR5pS_YYt4YCeL0erk,10963
|
9
9
|
pyglove/core/coding/execution_test.py,sha256=7V6hwShKiqpLR8jZl1tFvV3qV8QW5ZcEtBZ1rSOFPrc,9111
|
10
10
|
pyglove/core/coding/function_generation.py,sha256=2fCqcdcizVYtGYE6QGpw5m1kuH9Fp0OF4BjyJ4en6tw,1636
|
11
11
|
pyglove/core/coding/function_generation_test.py,sha256=kbSwmZF8Vog0R0OTSpuzPblEbMLoRJ1TigeIrwDhHS8,2161
|
12
12
|
pyglove/core/coding/parsing.py,sha256=JXTdzFS9iB5-JVi9_-rDFORj_EZEtr7In8HBGHp09no,4084
|
13
13
|
pyglove/core/coding/parsing_test.py,sha256=XB-bd2Huj36GKmvmFjp3jRwr7NqhRd1Ag-AGNxr_ekk,3575
|
14
|
-
pyglove/core/coding/permissions.py,sha256=
|
14
|
+
pyglove/core/coding/permissions.py,sha256=I1KXuXdg4-9whgXf86bxUfGjxPoReOFyu1-2ZFlExTk,2782
|
15
15
|
pyglove/core/coding/permissions_test.py,sha256=GTEnCClTZWdFmqHk3U5P8mzOmIINtUeEkeJZApnaWVI,2935
|
16
16
|
pyglove/core/detouring/__init__.py,sha256=ck_n2VSuU31HNVYQkbG4Zvnx90mNYtSVc2StN3rXbU8,1891
|
17
17
|
pyglove/core/detouring/class_detour.py,sha256=ejuUr7UfRU3l9PrDxD0dpKmt2iqdDU6liHdebA1jEfQ,13312
|
@@ -55,7 +55,7 @@ pyglove/core/hyper/object_template.py,sha256=YPALTV0mMULa7iuqnryTpA2wMsdyFZ_6g-R
|
|
55
55
|
pyglove/core/hyper/object_template_test.py,sha256=TEFX7LIqUvdCdJILnK_gP5xIgNJKzRnioUF0CGVBzcY,9105
|
56
56
|
pyglove/core/io/__init__.py,sha256=4ZT1a595DqQuLTNYc2JP_eCp_KesXvHmKRkr777bzpg,785
|
57
57
|
pyglove/core/io/file_system.py,sha256=E_kSi1Lqo31al4GJYywCzJT97X3ByW8Te4xVfAM93D4,13990
|
58
|
-
pyglove/core/io/file_system_test.py,sha256=
|
58
|
+
pyglove/core/io/file_system_test.py,sha256=mQdg4p8_D66sxRp_Hu2ILPvJa6PcR_y8q3NB0UCYjW8,8719
|
59
59
|
pyglove/core/io/sequence.py,sha256=XdVpPBuvhUnrTIWMUrak_qdcNdUJBpjgH5c1b5I3E2A,8873
|
60
60
|
pyglove/core/io/sequence_test.py,sha256=mnONyNG1M1sCae2tyI-tF8qns96htfZPKycthETPthU,4062
|
61
61
|
pyglove/core/patching/__init__.py,sha256=C1Q1cWPV74YL3eXbzGvc-8aPw1DR8EK6lRhQYDCwHek,2059
|
@@ -84,7 +84,7 @@ pyglove/core/symbolic/error_info.py,sha256=rqRwfmnEibMixaS2G-P0VhKjkZl79qjO6EUIt
|
|
84
84
|
pyglove/core/symbolic/error_info_test.py,sha256=y9HdGbvhQ6O4KB7Yv-N5N18k6v6nhiV_f-r1lTImHMo,3041
|
85
85
|
pyglove/core/symbolic/flags.py,sha256=a_8VZEhJjkt-zk1v3jCjlfNe7vEG2FqFfAC4l-gKrzg,12090
|
86
86
|
pyglove/core/symbolic/flags_test.py,sha256=JDJcm6dYTlnktFsdNFjQszmHXf9bZnhrXMxi_jUiKUA,5483
|
87
|
-
pyglove/core/symbolic/functor.py,sha256=
|
87
|
+
pyglove/core/symbolic/functor.py,sha256=AwE9GX2cO3QNihac1_ZN0sdG-TrWAJ5lXO2ZQ5GsJw4,26717
|
88
88
|
pyglove/core/symbolic/functor_test.py,sha256=9c5_7OBKNVNbYC7IaVQB6c5ks2v00qQ36oivyWiBbKA,31798
|
89
89
|
pyglove/core/symbolic/inferred.py,sha256=E4zgphg6NNZad9Fl3jdHQOMZeqEp9XHq5OUYqXEmwZQ,3178
|
90
90
|
pyglove/core/symbolic/inferred_test.py,sha256=G6uPykONcChvs6vZujXHSWaYfjewLTVBscMqzzKNty0,1270
|
@@ -140,14 +140,14 @@ pyglove/core/utils/common_traits_test.py,sha256=DIuZB_1xfmeTVfWnGOguDQcDAM_iGgBO
|
|
140
140
|
pyglove/core/utils/contextual.py,sha256=RxBQkDM2gB6QwZj_2oMels6oh-zQPGJJlinZbbqHuYQ,5148
|
141
141
|
pyglove/core/utils/contextual_test.py,sha256=OOcthquVyAekTqt1RyYcEMHaockMIokpbv4pSf13Nzs,3252
|
142
142
|
pyglove/core/utils/docstr_utils.py,sha256=5BY40kXozPKVGOB0eN8jy1P5_GHIzqFJ9FXAu_kzxaw,5119
|
143
|
-
pyglove/core/utils/docstr_utils_test.py,sha256=
|
143
|
+
pyglove/core/utils/docstr_utils_test.py,sha256=TBHNwvhGyyoEs7dNOv5bW7h3B_y2smDyoAR9uPDiidI,4179
|
144
144
|
pyglove/core/utils/error_utils.py,sha256=U9Ms3G1a_WUXaFgWccyPL7yOIf4k8Wi0nyXJ3yIaIfY,5264
|
145
145
|
pyglove/core/utils/error_utils_test.py,sha256=gnsEwFmgDNNVNvuQyhSWai8GDfLoCuX_DMqYow9Q2l4,2547
|
146
146
|
pyglove/core/utils/formatting.py,sha256=Wn4d933LQLhuMIfjdRJgpxOThCxBxQrkRBa6Z1-hL_I,15591
|
147
147
|
pyglove/core/utils/formatting_test.py,sha256=hhg-nL6DyE5A2QA92ALHK5QtfAYKfPpTbBARF-IT1j0,14241
|
148
148
|
pyglove/core/utils/hierarchical.py,sha256=jwB-0FhqOspAymAkvJphRhPTQEsoShmKupCZpU3Vip4,19690
|
149
149
|
pyglove/core/utils/hierarchical_test.py,sha256=f382DMJPa_bavJGGQDjuw-hWcafUg5bkQCPX-nbzeiI,21077
|
150
|
-
pyglove/core/utils/json_conversion.py,sha256=
|
150
|
+
pyglove/core/utils/json_conversion.py,sha256=fJ3zVvXJaoBf2OgUMYuYiSbRWuFg2PY82Vqzf9YohUc,26632
|
151
151
|
pyglove/core/utils/json_conversion_test.py,sha256=zA_cy7ixVL3sTf6i9BCXMlSH56Aa3JnjHnjyqYJ_9XU,11845
|
152
152
|
pyglove/core/utils/missing.py,sha256=9gslt1lXd1qSEIuAFxUWu30oD-YdYcnm13eau1S9uqY,1445
|
153
153
|
pyglove/core/utils/missing_test.py,sha256=D6-FuVEwCyJemUiPLcwLmwyptqI5Bx0Pfipc2juhKSE,1335
|
@@ -156,7 +156,7 @@ pyglove/core/utils/text_color_test.py,sha256=cZ2JQyTFtEhEeSQhuS1_hWHTD4Din2i4ypo
|
|
156
156
|
pyglove/core/utils/thread_local.py,sha256=i-CnyY3VREtLfAj4_JndBnsKuQLIgwG29ma8dAyRxbI,4839
|
157
157
|
pyglove/core/utils/thread_local_test.py,sha256=AOqsdNsA-cYMvJckqxb25ql3Y5kDW0qLfBW1cl85Bnw,6757
|
158
158
|
pyglove/core/utils/timing.py,sha256=gnHCA2IJ9DZ3Y0vb8ItB1Ap8ss8j_zN0OMUAdhoGy2Y,7550
|
159
|
-
pyglove/core/utils/timing_test.py,sha256=
|
159
|
+
pyglove/core/utils/timing_test.py,sha256=9N6yU6fPTiRb4ZNIhTVQewXdQ84S590U_Ayo8fJk2RI,5094
|
160
160
|
pyglove/core/utils/value_location.py,sha256=wAryIwQeEfrRddyGRk-KbLA7dnNDLhL-dSyFI9wIG5U,26756
|
161
161
|
pyglove/core/utils/value_location_test.py,sha256=X6Gih3IoYugziwXWH8VGz5bPeb3Kq0CfZxwbNVIsZJo,21338
|
162
162
|
pyglove/core/views/__init__.py,sha256=gll9ZBRYz4p_-LWOdzSR2a6UTWcJ8nR430trrP0yLCU,967
|
@@ -216,8 +216,8 @@ pyglove/ext/scalars/randoms.py,sha256=LkMIIx7lOq_lvJvVS3BrgWGuWl7Pi91-lA-O8x_gZs
|
|
216
216
|
pyglove/ext/scalars/randoms_test.py,sha256=nEhiqarg8l_5EOucp59CYrpO2uKxS1pe0hmBdZUzRNM,2000
|
217
217
|
pyglove/ext/scalars/step_wise.py,sha256=IDw3tuTpv0KVh7AN44W43zqm1-E0HWPUlytWOQC9w3Y,3789
|
218
218
|
pyglove/ext/scalars/step_wise_test.py,sha256=TL1vJ19xVx2t5HKuyIzGoogF7N3Rm8YhLE6JF7i0iy8,2540
|
219
|
-
pyglove-0.4.5.
|
220
|
-
pyglove-0.4.5.
|
221
|
-
pyglove-0.4.5.
|
222
|
-
pyglove-0.4.5.
|
223
|
-
pyglove-0.4.5.
|
219
|
+
pyglove-0.4.5.dev202507122122.dist-info/licenses/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
220
|
+
pyglove-0.4.5.dev202507122122.dist-info/METADATA,sha256=9Of9Q8sLEKiiTjQbDSq6WNu6FADgsB-ajBJ4QfPpII0,7089
|
221
|
+
pyglove-0.4.5.dev202507122122.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
222
|
+
pyglove-0.4.5.dev202507122122.dist-info/top_level.txt,sha256=wITzJSKcj8GZUkbq-MvUQnFadkiuAv_qv5qQMw0fIow,8
|
223
|
+
pyglove-0.4.5.dev202507122122.dist-info/RECORD,,
|
File without changes
|
{pyglove-0.4.5.dev202507110810.dist-info → pyglove-0.4.5.dev202507122122.dist-info}/licenses/LICENSE
RENAMED
File without changes
|
{pyglove-0.4.5.dev202507110810.dist-info → pyglove-0.4.5.dev202507122122.dist-info}/top_level.txt
RENAMED
File without changes
|