This is the durable NetworkX wrapper
Project description
Durable NetworkX
Introduction
Durable NetworkX is an extension to the popular Python package NetworkX, providing persistence capabilities for graph objects. By seamlessly integrating with NetworkX, Durable NetworkX offers users the ability to not only perform complex graph operations but also to store and manage graph data across sessions, ensuring data durability and easy retrieval.
Why use Durable NetworkX?
-
Integrated Experience with NetworkX: If you are already familiar with NetworkX, integrating Durable NetworkX is straightforward. You can perform all the graph operations that NetworkX provides while also enjoying the added persistence capabilities of Durable NetworkX.
-
Data Durability: With Durable NetworkX, you no longer need to worry about losing your graph data after your Python session ends. Your graph data will persist, allowing you to load it in subsequent sessions, making it ideal for long-term projects and research.
-
Versatile Storage Options: Durable NetworkX offers multiple storage manager implementations, including
LocalFileStorageManager
for storing on the local filesystem andS3StorageManager
for storing on Amazon S3. This flexibility ensures that you can choose the storage solution that best fits your project needs. -
Easy Management of Graph Instances: With the ability to create new instances, use existing ones, and delete instances, managing your graph datasets becomes hassle-free. This is especially beneficial for projects that deal with multiple graph datasets.
-
Storage Efficiency: Durable NetworkX uses the GraphML format for storage, ensuring that your graph data is stored in a structured and efficient manner, which is also widely supported for interoperability with other graph processing tools.
-
Scalable: Leveraging cloud storage solutions like Amazon S3 means that as your data grows, you can easily scale your storage without worrying about infrastructure.
-
Enhanced Data Security: By using storage solutions like Amazon S3, you can benefit from the built-in security measures provided by these platforms, ensuring your graph data remains protected.
How to Use Durable NetworkX?
- Installation: You can add in your project
pip install durable-network-x
Or, if you are using poetry
poetry add durable-network-x
-
Initialization:
from durable_network_x.storage_managers.local_file_storage_manager import LocalFileStorageManager from durable_network_x import DurableNetworkX storage_manager = LocalFileStorageManager(root_dir="/path/to/store/data") durable_graph = DurableNetworkX(storage_manager=storage_manager)
-
Creating a New Graph Instance:
durable_graph.new(instance_id="my_graph")
-
Working with the Graph: All the operations you can perform on a NetworkX graph, you can perform on the
graph
property of the Durable NetworkX instance.g = durable_graph.graph g.add_node(1)
-
Saving Changes: After performing operations, save the graph.
durable_graph.save()
-
Loading an Existing Graph:
durable_graph.use(instance_id="my_graph")
-
Deleting a Graph Instance:
durable_graph.delete()
Using Amazon S3 as a Storage
To use Amazon S3, simply use the S3StorageManager
.
from durable_network_x.storage_managers.local_file_storage_manager import S3StorageManager
# Initialize a storage manager with the desired S3 bucket and credentials
storage_manager = S3StorageManager(bucket_name="my-s3-bucket", aws_access_key_id="YOUR_AWS_KEY", aws_secret_access_key="YOUR_AWS_SECRET")
# The rest of the operations remain the same
Extending with Custom Storage Managers
Users can also define their own storage managers by inheriting from the StorageManager
class and implementing the required methods (read
, write
, delete
, and exists
).
from durable_network_x.storage_managers import StorageManager
Contributing
If you would like to contribute to durable-network-x
, please fork the repository, make your changes, and submit a pull request. I appreciate all contributions and feedback!
License
Enjoy using durable-network-x
and have fun building durable graph applications!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for durable_network_x-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b856fc96c62e31f453d3bc857663c4d527efe88d015945b9528b6854de75659 |
|
MD5 | 4d604cd4b2e411993f38a85ae35c10d3 |
|
BLAKE2b-256 | 0ee222656fb58c3f0afb97fd70026594b0d8669ef724b7cf0e36ff2d4ecf41be |