Skip to content

Commit ce61640

Browse files
committed
Python: Cleanup __init__.py for public consumption
Cleans up what is imported in __init__.py to not pollute the namespace when a user imports 'hipfile'.
1 parent b5c14d7 commit ce61640

2 files changed

Lines changed: 25 additions & 17 deletions

File tree

python/hipfile/__init__.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
1-
from hipfile._hipfile import * # noqa: F401,F403
21
from hipfile._hipfile import (
32
# Constants
4-
VERSION_MAJOR,
5-
VERSION_MINOR,
6-
VERSION_PATCH,
7-
BASE_ERR,
8-
# Error Macros
9-
is_hipfile_err,
10-
hipfile_errstr,
11-
is_hip_drv_err,
12-
hip_drv_err,
3+
VERSION_MAJOR as _VERSION_MAJOR,
4+
VERSION_MINOR as _VERSION_MINOR,
5+
VERSION_PATCH as _VERSION_PATCH
136
)
14-
from hipfile.buffer import(
7+
from hipfile.buffer import (
158
Buffer
169
)
1710
from hipfile.driver import (
@@ -32,4 +25,15 @@
3225
get_version
3326
)
3427

35-
__version__ = f"{VERSION_MAJOR}.{VERSION_MINOR}.{VERSION_PATCH}"
28+
__all__ = [
29+
"__version__",
30+
"Driver",
31+
"FileHandle",
32+
"Buffer",
33+
"HipFileException",
34+
"FileHandleType",
35+
"OpError",
36+
"driver_get_properties",
37+
"get_version"
38+
]
39+
__version__ = f"{_VERSION_MAJOR}.{_VERSION_MINOR}.{_VERSION_PATCH}"

python/main.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33
import pathlib
44
import stat
55

6-
from hipfile.buffer import Buffer
7-
from hipfile.driver import Driver
8-
from hipfile.enums import FileHandleType
9-
from hipfile.file import FileHandle
10-
from hipfile.properties import driver_get_properties, get_version
116
from hipfile.hipMalloc import hipFree, hipMalloc
127

8+
from hipfile import (
9+
Driver,
10+
FileHandle,
11+
Buffer,
12+
FileHandleType,
13+
driver_get_properties,
14+
get_version
15+
)
16+
1317
hipfile_version = get_version()
1418

1519
input_path = pathlib.Path("/mnt/ais/ext4/random_2MiB.bin")

0 commit comments

Comments
 (0)