Skip to content

Commit f4d06cb

Browse files
committed
[Python] Add pip package setup
1 parent 4996e2e commit f4d06cb

File tree

14 files changed

+207
-50
lines changed

14 files changed

+207
-50
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ prototyping algorithms on a local computer for later running on a powerful serve
4444
- [X] Wrapper for Python API
4545
- [ ] Wrapper syntax sugar
4646
- [ ] Tests for Python wrapper
47+
- [ ] Pip package
4748
- [ ] Code examples
4849
- [ ] User guide
4950
- [X] Unit Tests collection
50-
- [X] Dummy library implementation for testing
5151
- [ ] Publish built artifacts and shared libs
5252
- [ ] Publish stable source code archives
5353

@@ -65,7 +65,7 @@ prototyping algorithms on a local computer for later running on a powerful serve
6565

6666
### Cuda & Compiler Setup
6767

68-
> Skip thia section if you want to build library with only sequential backend
68+
> Skip this section if you want to build library with only sequential backend
6969
> without cuda backend support.
7070
7171
Before the CUDA setup process, validate your system NVIDIA driver with `nvidia-smi`
@@ -216,8 +216,8 @@ def transitive_closure(a: pycubool.Matrix):
216216
:return: The transitive closure adjacency matrix
217217
"""
218218
219-
t = a.dup() # Duplicate matrix where to store result
220-
total = 0 # Current number of values
219+
t = a.dup() # Duplicate matrix where to store result
220+
total = 0 # Current number of values
221221
222222
while total != t.nvals:
223223
total = t.nvals
@@ -263,7 +263,7 @@ cuBool
263263
## License
264264
265265
This project is licensed under MIT License. License text can be found in the
266-
[license file](https://github.com/JetBrains-Research/cuBool/blob/master/LICENSE).
266+
[license file](https://github.com/JetBrains-Research/cuBool/blob/master/LICENSE.md).
267267
268268
## Acknowledgments
269269

cubool/CMakeLists.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,4 +164,16 @@ if (CUBOOL_BUILD_TESTS)
164164

165165
message(STATUS "Add unit tests directory to the project")
166166
add_subdirectory(tests)
167-
endif()
167+
endif()
168+
169+
# todo: Different platforms has specific naming conventions
170+
set(LIBRARY_FILE_NAME "libcubool.so")
171+
172+
# Copy cubool library after build
173+
add_custom_command(
174+
TARGET cubool POST_BUILD
175+
COMMAND "${CMAKE_COMMAND}" -E
176+
copy
177+
"${CMAKE_BINARY_DIR}/cubool/${LIBRARY_FILE_NAME}"
178+
"${CMAKE_BINARY_DIR}/python/pycubool"
179+
COMMENT "Copy cubool lib into python folder")

cubool/tests/CMakeLists.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
add_executable(test_basic_cuda test_basic_cuda.cu)
2-
target_link_libraries(test_basic_cuda PUBLIC testing)
3-
target_compile_features(test_basic_cuda PUBLIC cxx_std_11)
4-
set_target_properties(test_basic_cuda PROPERTIES CXX_STANDARD 11)
5-
set_target_properties(test_basic_cuda PROPERTIES CXX_STANDARD_REQUIRED YES)
6-
set_target_properties(test_basic_cuda PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
1+
# add_executable(test_basic_cuda test_basic_cuda.cu)
2+
# target_link_libraries(test_basic_cuda PUBLIC testing)
3+
# target_compile_features(test_basic_cuda PUBLIC cxx_std_11)
4+
# set_target_properties(test_basic_cuda PROPERTIES CXX_STANDARD 11)
5+
# set_target_properties(test_basic_cuda PROPERTIES CXX_STANDARD_REQUIRED YES)
6+
# set_target_properties(test_basic_cuda PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
77

88
add_executable(test_library_api test_library_api.cpp)
99
target_link_libraries(test_library_api PUBLIC testing)

python/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020, 2021 JetBrains-Research
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

python/MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include LICENSE

python/README.md

Lines changed: 66 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,69 @@
1-
# Python Directory
1+
# pycubool
22

3-
This directory is intended to store python wrappers and other
4-
python utilities, required for using `cubool` library within
5-
testing infrastructure and etc.
3+
[![JB Research](https://jb.gg/badges/research-flat-square.svg)](https://research.jetbrains.org/)
4+
[![Ubuntu](https://github.com/JetBrains-Research/cuBool/workflows/Ubuntu/badge.svg?branch=master)](https://github.com/JetBrains-Research/cuBool/actions)
5+
[![License](https://img.shields.io/badge/license-MIT-orange)](https://github.com/JetBrains-Research/cuBool/blob/master/LICENSE)
66

7-
## Structure
7+
`pycubool` is a python wrapper for [cuBool](https://github.com/JetBrains-Research/cuBool) library.
8+
9+
**cuBool** is a linear Boolean algebra library primitives and operations for
10+
work with sparse matrices written on the NVIDIA CUDA platform. The primary
11+
goal of the library is implementation, testing and profiling algorithms for
12+
solving *formal-language-constrained problems*, such as *context-free*
13+
and *regular* path queries with various semantics for graph databases.
14+
The library provides C-compatible API, written in the GraphBLAS style,
15+
as well as python high-level wrapper with automated resources management and fancy syntax sugar.
16+
17+
**The primary library primitive** is a sparse boolean matrix. The library provides
18+
the most popular operations for matrix manipulation, such as construction from
19+
values, transpose, sub-matrix extraction, matrix-to-vector reduce, matrix-matrix
20+
element-wise addition, matrix-matrix multiplication and Kronecker product.
21+
22+
**As a fallback** library provides sequential backend for mentioned above operations
23+
for computations on CPU side only. This backend is selected automatically
24+
if Cuda compatible device is not presented in the system. This can be quite handy for
25+
prototyping algorithms on a local computer for later running on a powerful server.
26+
27+
## Example
28+
29+
The following Python code snippet demonstrates, how the `pycubool`
30+
wrapper can be used to compute the transitive closure problem for the
31+
directed graph within python environment:
32+
33+
```python
34+
import pycubool
35+
36+
def transitive_closure(a: pycubool.Matrix):
37+
"""
38+
Evaluates transitive closure for the provided
39+
adjacency matrix of the graph.
40+
41+
:param a: Adjacency matrix of the graph
42+
:return: The transitive closure adjacency matrix
43+
"""
44+
45+
t = a.dup() # Duplicate matrix where to store result
46+
total = 0 # Current number of values
47+
48+
while total != t.nvals:
49+
total = t.nvals
50+
t.mxm(t, out=t, accumulate=True) # t += t * t
51+
52+
return t
53+
```
54+
55+
## Directory structure
56+
57+
```
58+
pycubool
59+
├── docs - documents, text files and various helpful stuff
60+
├── demo - examples and basic programs
61+
├── pycubool - package with `cuBool` C API wrapper
62+
└── tests - tests for python wrapper
63+
```
64+
65+
## License
66+
67+
This project is licensed under MIT License. License text can be found in the
68+
[license file](https://github.com/JetBrains-Research/cuBool/blob/master/python/LICENSE.md).
869

9-
- `pycubool` - python wrapper for the `cubool c api`
10-
- `tests` - unit tests for pycubool wrapper

python/data/placeholder.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Replace me

python/demo/placeholder.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Replace me

python/pycubool/README.md

Lines changed: 0 additions & 29 deletions
This file was deleted.

python/pycubool/__init__.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
"""
2+
Entry point for `pycubool` package.
3+
pycubool is python wrapper for cuBool library.
4+
5+
The backend cuBool compiled library is initialized automatically
6+
on package import into runtime. State of the library is managed
7+
by the wrapper class. All resources are unloaded automatically on
8+
python runtime exit.
9+
10+
Exported primitives:
11+
- matrix (sparse matrix of boolean values)
12+
13+
For more information refer to:
14+
- cuBool project: https://github.com/JetBrains-Research/cuBool
15+
- bug tracker: https://github.com/JetBrains-Research/cuBool/issues
16+
17+
License:
18+
- MIT
19+
"""
20+
121
from .wrapper import *
222
from .matrix import *
323

0 commit comments

Comments
 (0)