Package: basalt
Basalt - Graph Storage API for C++ and PythonBasalt is a graph storage API powered by RocksDB persistent
key-value store for fast storage like NVMe technologies.Documentation is currently hosted on GitHub: [https://bluebrain.github.io/basalt]Development stageThe C++ and Python APIs of Basalt are stable already, but substantial additions might come in the future. Thus this library development status is still beta.UsagePythonGraph Topology APIclassPLInfluences(basalt.GraphTopology):"""A directed graph where vertices are programming languages."""directed(True)classVertex(Enum):LANGUAGE=1# Declare a vertex typevertex("language",Vertex.LANGUAGE)# Declare a directed edge between 2 programming languages# to represent how they relate.edge(Vertex.LANGUAGE,Vertex.LANGUAGE,name="influenced",plural="influenced")@classmethoddefload_from_dbpedia(cls):# [...]g=PLInfluences.load_from_dbpedia("/path/on/disk")# Iterate over all vertices of type "languages"forlanguageing.languages:print(language.id,language.data())# Iterate over all vertices connected to vertex `language`# through the `influenced` edge type.forinfluencedinlanguage.influenced:print("  ",influenced.data())Low-level Python bindings# Load or initialize a graph on diskg=basalt.UndirectedGraph("/path/on/disk")# Add one vertex of type 0 and identifier 1g.vertices.add((0,1))# Insert 10 vertices at once# (10, 0), (10, 1), ... (10, 10)g.vertices.add(numpy.full((10,),1,dtype=numpy.int32),# typesnumpy.arange(10,dtype=numpy.int64))# ids# Connect 2 verticesg.edges.add((0,1),(1,0))# Connect vertex (0, 1) to several vertices at once# (0,1)->(1,0), (0,1)->(1,1), ... (0,1)->(1,9)g.edges.add((0,1),numpy.full((9,),1,dtype=numpy.int32),numpy.arange(9,dtype=numpy.int64)# Commit changes on diskg.commit()C++ API// Load or initialize a graph on diskbasalt::UndirectedGraphg("/path/on/disk");// Add one vertex of type 0 and identifier 1g.vertices().insert({0,1});// Add one vertex of type 0 and identifier 2g.vertices().insert({0,2});// Iterate over verticesfor(constauto&vertex:g.vertices()){std::clog<<vertex<<'\n';}// Connect both verticesg.edges().insert({0,1},{0,2}));for(constauto&edge:g.edges()){std::clog<<edge.first<<" -> "<<edge.second<<'\n';}// Commit changes on diskg.commit();InstallationC++ APIConan packageThis repository provides aConanpackage to ease integration into your existing projects.CMakeIt is also possible to build and install the library using CMake, seebuild sectionbelow.Python APIPypiPython bindings of Basalt are available onPypi.Blue Brain 5 supercomputerBasalt is currently released as module on Blue Brain 5 supercomputer:$modulepurge
$./gpfs/bbp.cscs.ch/apps/hpc/jenkins/config/modules.sh
$moduleloadpy-basalt
$python3
Python3.6.3(default,Oct32017,07:47:49)[GCC6.4.0]onlinux
Type"help","copyright","credits"or"license"formoreinformation.
>>>importbasalt
>>>basalt.__version__'0.2.2'>>>basalt.__rocksdb_version__'5.17.2'Manual build and installation instructionsRequirementsCMakebuild system, version 3.5.1 or higher.RocksDB, a persistent key-value store,
version 4.1.1 or higher.Python 3, version 3.5 or higher.Getting the codeThis repository grabs a few third-party libraries asgit modules.
To clone them when you clone basalt, usegit clone --recursiveoption.If you have already cloned basalt, you can get the git submodules with
the command:git submodule update --recursive --initBuilding the library 101C++ Library onlyTo build the basalt C++ shared library and run the tests:cd/path/to/basalt
mkdirbuildpushdbuild
cmake..CTEST_OUTPUT_ON_FAILURE=1makealltestTo install the library:pushdbuild
cmake-DCMAKE_INSTALL_PREFIX=/usr/local.
makeallinstallPython 3 bindingsTo build and run the tests:cd/path/to/basalt
python3setup.pytestTo install the package:withpip:pip3 install -U .withdistutils:python3 setup.py installto create binary tarballs:most simple:python3 setup.py bdistwheel:pip3 install wheel; python3 setup.py bdist_wheelrelocatable archive:python3 setup.py bdist_dumb --relativeCMake variables and targetsMain CMake variables:Basalt_FORMATTING:BOOL: provide the build targetclang-formatto check C++ code formattingBasalt_STATIC_ANALYSIS:BOOL: provide the build targetclang-tidyto perform static analysis of the C++ codeBasalt_ARCH: value given to the-mcompiler option. "native" for instanceBasalt_PRECOMMIT:BOOL: Enable automatic checks before git commitsBasalt_CXX_OPTIMIZE:BOOL: Compile C++ with optimizationBasalt_CXX_SYMBOLS:BOOL: Compile C++ with debug symbolsBasalt_CXX_WARNINGS:BOOL=ON: Compile C++ with warningsFor a more detailed list, please refer to fileCMakeCache.txtin CMake build directory.CMake targets:basalt: build the pure C++ library (without Python bindings)_basalt: build the C++ library with Python bindingsunit-tests: build a C++ executable testing the C++ pure libraryall: build the 3 targets abovetest: execute the tests. It is recommended to execute the commandctest --output-on-failure -VVinsteadinstall: install the pure C++ library and the CMake configuration required to easily use basalt
in another CMake projectPython setuptools commandsHere are the main Python  setuptools commands available.build: build native librarytest: build and test the package. It also executes the C++ unit-tests as well as the code snippets in the Sphinx documentation.install: install the Python packagedoctest: execute the code snippets in the Sphinx documentationbuild_sphinx: build the Sphinx documentationFor instance:python3 setup.py build_sphinxFiles Layout├── basalt ................... python code of the package
├── cmake
│   └── hpc-coding-conventions git module for C++ code guidelines
├── dev ...................... development related scripts
├── doc ...................... sphinx documentation source code
├── include
│   └── basalt ............... public headers of the C++ library
├── README.md ................ that's me!
├── src
│   ├── basalt ............... C++ library implementation
│   └── third_party .......... C++ libraries (mostly as git modules)
└── tests
    ├── benchmarks ........... scripts to execute before creating a git tag
    ├── py ................... python unit-tests
    └── unit ................. C++ unit-tests using Catch2Embedded third-partiesExternal libraries are including either by copy/paste or git submodules
insrc/third_partydirectory.Catch2:
modern, C++-native, header-only, test framework for unit-tests, TDD
and BDD unit-test library.fmt: A modern formatting library(not part of CMake build yet)pybind11: Seamless operability between C++11 and PythonSpdLog: Fast C++ logging library.ContributingIf you want to improve the project or you see any issue, every contribution is welcome.
Please checkcontribution guidelinesfor more information.