ansys-bdm-api 0.5.dev0__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.
- ansys/bdm/api/__init__.py +62 -0
- ansys/bdm/api/entity_handle.py +98 -0
- ansys/bdm/api/iasync_entity_writer.py +71 -0
- ansys/bdm/api/iasync_storage_scope.py +605 -0
- ansys/bdm/api/ientity_writer.py +70 -0
- ansys/bdm/api/istorage_scope.py +602 -0
- ansys/bdm/api/istorage_scope_factory.py +135 -0
- ansys/bdm/api/py.typed +0 -0
- ansys/bdm/api/recursive_dictionary.py +132 -0
- ansys/bdm/api/storage_exceptions.py +45 -0
- ansys/bdm/base/__init__.py +15 -0
- ansys/bdm/base/base_async_storage_scope.py +92 -0
- ansys/bdm/base/base_storage_scope.py +80 -0
- ansys/bdm/base/encoder.py +89 -0
- ansys/bdm/base/py.typed +0 -0
- ansys_bdm_api-0.5.dev0.dist-info/METADATA +171 -0
- ansys_bdm_api-0.5.dev0.dist-info/RECORD +20 -0
- ansys_bdm_api-0.5.dev0.dist-info/WHEEL +4 -0
- ansys_bdm_api-0.5.dev0.dist-info/licenses/AUTHORS +12 -0
- ansys_bdm_api-0.5.dev0.dist-info/licenses/LICENSE +202 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Copyright (C) 2026 ANSYS, Inc. and/or its affiliates.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
#
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
|
|
17
|
+
"""
|
|
18
|
+
TODO: package documentation
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
try:
|
|
22
|
+
import importlib.metadata as importlib_metadata
|
|
23
|
+
except ModuleNotFoundError:
|
|
24
|
+
import importlib_metadata # type: ignore
|
|
25
|
+
|
|
26
|
+
__version__ = importlib_metadata.version(f"{__name__.replace('.', '-')}") # type: ignore
|
|
27
|
+
# Ignore "module level import not at top of file" errors
|
|
28
|
+
from .entity_handle import NO_ENTITY as NO_ENTITY
|
|
29
|
+
from .entity_handle import EntityHandle as EntityHandle
|
|
30
|
+
from .iasync_entity_writer import IAsyncEntityWriter as IAsyncEntityWriter
|
|
31
|
+
from .iasync_storage_scope import IAsyncReadStorageScope as IAsyncReadStorageScope
|
|
32
|
+
from .iasync_storage_scope import IAsyncStorageScope as IAsyncStorageScope
|
|
33
|
+
from .ientity_writer import IEntityWriter as IEntityWriter
|
|
34
|
+
from .istorage_scope import IReadStorageScope as IReadStorageScope
|
|
35
|
+
from .istorage_scope import IStorageScope as IStorageScope
|
|
36
|
+
from .istorage_scope_factory import IReadStorageScopeFactory as IReadStorageScopeFactory
|
|
37
|
+
from .istorage_scope_factory import IStorageScopeFactory as IStorageScopeFactory
|
|
38
|
+
from .recursive_dictionary import (
|
|
39
|
+
RecursiveDictionaryOfEntityHandles as RecursiveDictionaryOfEntityHandles,
|
|
40
|
+
)
|
|
41
|
+
from .recursive_dictionary import validate_path_component as validate_path_component
|
|
42
|
+
from .storage_exceptions import (
|
|
43
|
+
CannotGenerateStreamForDirectoryError as CannotGenerateStreamForDirectoryError,
|
|
44
|
+
)
|
|
45
|
+
from .storage_exceptions import (
|
|
46
|
+
EntityNotFoundInBlobStorageError as EntityNotFoundInBlobStorageError,
|
|
47
|
+
)
|
|
48
|
+
from .storage_exceptions import (
|
|
49
|
+
EntityWriterHasNotCompletedWritingDataError as EntityWriterHasNotCompletedWritingDataError,
|
|
50
|
+
)
|
|
51
|
+
from .storage_exceptions import (
|
|
52
|
+
EntityWriterHasWrittenDataError as EntityWriterHasWrittenDataError,
|
|
53
|
+
)
|
|
54
|
+
from .storage_exceptions import (
|
|
55
|
+
EntityWriterIsNotWritingDataError as EntityWriterIsNotWritingDataError,
|
|
56
|
+
)
|
|
57
|
+
from .storage_exceptions import (
|
|
58
|
+
InvalidContextError as InvalidContextError,
|
|
59
|
+
)
|
|
60
|
+
from .storage_exceptions import (
|
|
61
|
+
NotFoundInLocalStorageRootError as NotFoundInLocalStorageRootError,
|
|
62
|
+
)
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# Copyright (C) 2026 ANSYS, Inc. and/or its affiliates.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
#
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
|
|
17
|
+
from uuid import UUID
|
|
18
|
+
|
|
19
|
+
from pydantic import BaseModel
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class EntityHandle(BaseModel, frozen=True):
|
|
23
|
+
"""
|
|
24
|
+
A handle to a entity stored by a BDM provider and the associated lightweight data about it.
|
|
25
|
+
|
|
26
|
+
This lightweight, immutable object is intended to be easy to serialize and pass around across processes,
|
|
27
|
+
services, and hosts. The actual behavior of the entity contents is up to the :class:`IStorageScope` or
|
|
28
|
+
:class:`IAsyncStorageScope`.
|
|
29
|
+
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
is_blob: bool
|
|
33
|
+
"""True if this entity refers to a blob. False if it refers to a collection of blobs."""
|
|
34
|
+
original_name: str | None = None
|
|
35
|
+
"""
|
|
36
|
+
The original filename of the entity.
|
|
37
|
+
|
|
38
|
+
This is just the filename and does not include the path. May be `None` or empty if not known.
|
|
39
|
+
May not refer to a file on the local system.
|
|
40
|
+
"""
|
|
41
|
+
entity_id: UUID
|
|
42
|
+
"""
|
|
43
|
+
A unique id that identifies the entity.
|
|
44
|
+
|
|
45
|
+
Typically this value is a new, random Guid created at the moment that the
|
|
46
|
+
:class:`Entityandle` is created from contents such as a file on disk. It should
|
|
47
|
+
be preserved across clone and save/load operations. It is not guaranteed to be
|
|
48
|
+
the same value if you read the same contents into an BlobHandle twice.
|
|
49
|
+
|
|
50
|
+
The UUID '00000000-0000-0000-0000-000000000000' is reserved for :data:`NO_ENTITY`.
|
|
51
|
+
"""
|
|
52
|
+
opaque_identifier: str
|
|
53
|
+
"""
|
|
54
|
+
A custom identifier that the :class:`IStorageScope` can use to identify the
|
|
55
|
+
handle. Opaque as each BDM system may have its own form for this field. Consumers
|
|
56
|
+
are not to assume anything about this field, even if it looks parseable.
|
|
57
|
+
"""
|
|
58
|
+
mime_type: str | None = None
|
|
59
|
+
"""
|
|
60
|
+
The mime type of the data, if it is known. None otherwise.
|
|
61
|
+
"""
|
|
62
|
+
encoding: str | None = None
|
|
63
|
+
"""
|
|
64
|
+
The Internet Assigned Numbers Authority (IANA) registered encoding name used for textual data.
|
|
65
|
+
|
|
66
|
+
This may be None if not known and should not be set for binary mime types.
|
|
67
|
+
|
|
68
|
+
This encoding name may be passed to other languages and implementations. IANA registered
|
|
69
|
+
encoding names MUST be used.
|
|
70
|
+
"""
|
|
71
|
+
size: int | None = None
|
|
72
|
+
"""
|
|
73
|
+
Size of the data in bytes, if known.
|
|
74
|
+
|
|
75
|
+
Size must be None if is_blob is False.
|
|
76
|
+
|
|
77
|
+
Note that 0 is a valid blob size and has a different meaning than None.
|
|
78
|
+
"""
|
|
79
|
+
|
|
80
|
+
def __eq__( # pyright: ignore[reportIncompatibleMethodOverride]
|
|
81
|
+
self,
|
|
82
|
+
__value: object,
|
|
83
|
+
/,
|
|
84
|
+
) -> bool:
|
|
85
|
+
return isinstance(__value, EntityHandle) and self.opaque_identifier == __value.opaque_identifier
|
|
86
|
+
|
|
87
|
+
def __hash__(self) -> int:
|
|
88
|
+
return self.opaque_identifier.__hash__()
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
# TODO: Documentation on a module constant doesn't appear to be working.
|
|
92
|
+
#: A constant empty EntityHandle which means no content or metadata has been assigned.
|
|
93
|
+
NO_ENTITY: EntityHandle = EntityHandle(
|
|
94
|
+
is_blob=True,
|
|
95
|
+
original_name="",
|
|
96
|
+
entity_id=UUID(int=0),
|
|
97
|
+
opaque_identifier="",
|
|
98
|
+
)
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Copyright (C) 2026 ANSYS, Inc. and/or its affiliates.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
#
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
|
|
17
|
+
from types import TracebackType
|
|
18
|
+
from typing import Protocol
|
|
19
|
+
|
|
20
|
+
from anyio.abc import ByteSendStream
|
|
21
|
+
|
|
22
|
+
from ansys.bdm.api.entity_handle import EntityHandle
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class IAsyncEntityWriter(Protocol):
|
|
26
|
+
"""
|
|
27
|
+
An object used to create a new entity from a stream of data.
|
|
28
|
+
|
|
29
|
+
Instances are created from :func:`IAsyncStorageScope.begin_store()`
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
async def __aenter__(self) -> "IAsyncEntityWriter":
|
|
33
|
+
"""Start writing data that will comprise an entity."""
|
|
34
|
+
# deliberately not implemented
|
|
35
|
+
...
|
|
36
|
+
|
|
37
|
+
async def __aexit__(
|
|
38
|
+
self,
|
|
39
|
+
__exc_type: type[BaseException] | None, # noqa: PYI063
|
|
40
|
+
__exc_value: BaseException | None,
|
|
41
|
+
__traceback: TracebackType | None,
|
|
42
|
+
) -> None:
|
|
43
|
+
"""
|
|
44
|
+
Finish collecting data and store entity.
|
|
45
|
+
|
|
46
|
+
This method will throw an exception if __enter__ has not been called.
|
|
47
|
+
"""
|
|
48
|
+
# deliberately not implemented
|
|
49
|
+
...
|
|
50
|
+
|
|
51
|
+
@property
|
|
52
|
+
def stream(self) -> ByteSendStream:
|
|
53
|
+
"""
|
|
54
|
+
Return object that can be written to, which will be stored as the entity.
|
|
55
|
+
|
|
56
|
+
This method will throw an exception if __enter__ has not been called.
|
|
57
|
+
|
|
58
|
+
This method will throw an exception if __exit__ has been called.
|
|
59
|
+
"""
|
|
60
|
+
# deliberately not implemented
|
|
61
|
+
...
|
|
62
|
+
|
|
63
|
+
@property
|
|
64
|
+
def handle(self) -> EntityHandle:
|
|
65
|
+
"""
|
|
66
|
+
Return the entity created by this object.
|
|
67
|
+
|
|
68
|
+
This method will throw an exception if __exit__ has not been called.
|
|
69
|
+
"""
|
|
70
|
+
# deliberately not implemented
|
|
71
|
+
...
|