# Rudof Python bindings
The Python bindings for [rudof](https://rudof-project.github.io/) are called `pyrudof`. They are available at [pypi](https://pypi.org/project/pyrudof/).
For more information, you can access the [readthedocs documentation](https://pyrudof.readthedocs.io/en/latest/). We keep several tutorials about rudof as Jupyter notebooks in: [https://rudof-project.github.io/tutorials].
After compiling and installing this module, a Python library called `pyrudof` should be available.
## Build the development version
This module is based on [pyo3](https://pyo3.rs/) and [maturin](https://www.maturin.rs/).
To build and install the development version of `pyrudof` you need to clone this git repository, go to the `python` directory (the one this README is in) and run:
```
pip install maturin
```
followed by:
```sh
pip install .
```
If you are using `.env`, you can do the following:
```sh
python3 -m venv .venv
```
followed by:
```sh
source .venv/bin/activate
```
or
```sh
source .venv/bin/activate.fish
```
and once you do that, you can locally install que package as:
```sh
pip install -e .
```
## Running the tests
Go to the tests folder:
```sh
cd tests
```
and run:
```sh
python3 -m unittest discover -vvv
```
## Using rudof_generate
The `pyrudof` package includes bindings for `rudof_generate`, which allows you to generate synthetic RDF data from ShEx or SHACL schemas.
### Basic Example
```python
import pyrudof
# Create configuration
config = pyrudof.GeneratorConfig()
config.set_entity_count(100)
config.set_output_path("output.ttl")
config.set_output_format(pyrudof.OutputFormat.Turtle)
# Create generator
generator = pyrudof.DataGenerator(config)
# Load schema and generate data
generator.run("schema.shex")
```
### Configuration Options
The `GeneratorConfig` class provides many configuration options:
```python
config = pyrudof.GeneratorConfig()
# Generation parameters
config.set_entity_count(1000) # Number of entities to generate
config.set_seed(42) # Random seed for reproducibility
# Schema format
config.set_schema_format(pyrudof.SchemaFormat.ShEx) # or SchemaFormat.SHACL
# Output configuration
config.set_output_path("data.ttl")
config.set_output_format(pyrudof.OutputFormat.Turtle) # or OutputFormat.NTriples
config.set_compress(False) # Whether to compress output
config.set_write_stats(True) # Write generation statistics
# Cardinality strategy
config.set_cardinality_strategy(pyrudof.CardinalityStrategy.Balanced)
# Options: Minimum, Maximum, Random, Balanced
# Parallel processing
config.set_worker_threads(4) # Number of worker threads
config.set_batch_size(100) # Batch size for processing
config.set_parallel_writing(True) # Enable parallel file writing
config.set_parallel_file_count(4) # Number of output files (when parallel)
```
### Loading Schemas
You can load schemas in different ways:
```python
# Load ShEx schema
generator.load_shex_schema("schema.shex")
# Load SHACL schema
generator.load_shacl_schema("shapes.ttl")
# Auto-detect schema format
generator.load_schema_auto("schema_file")
# Then generate data
generator.generate()
```
### Complete Workflow
The `run()` method provides a convenient way to load a schema and generate data in one step:
```python
# Auto-detect format
generator.run("schema.shex")
# Specify format explicitly
generator.run_with_format("shapes.ttl", pyrudof.SchemaFormat.SHACL)
```
### Configuration Files
You can also load configuration from TOML or JSON files:
```python
# Load from TOML
config = pyrudof.GeneratorConfig.from_toml_file("config.toml")
# Load from JSON
config = pyrudof.GeneratorConfig.from_json_file("config.json")
# Save configuration
config.to_toml_file("saved_config.toml")
```
### Available Enums
- **SchemaFormat**: `ShEx`, `SHACL`
- **OutputFormat**: `Turtle`, `NTriples`
- **CardinalityStrategy**: `Minimum`, `Maximum`, `Random`, `Balanced`
For more examples, see the `examples/generate_example.py` file.
Raw data
{
"_id": null,
"home_page": "https://rudof-project.github.io/rudof",
"name": "pyrudof",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "rdf, linked-data, semantic-web, shex, shacl",
"author": "Jose Emilio Labra Gayo <labra@uniovi.es>, \u00c1ngel Iglesias Pr\u00e9stamo <angel.iglesias.prestamo@gmail.com>, Marc-Antoine Arnaud <marc-antoine.arnaud@luminvent.com>",
"author_email": "Jose Emilio Labra Gayo <labra@uniovi.es>, \u00c1ngel Iglesias Pr\u00e9stamo <angel.iglesias.prestamo@gmail.com>, Marc-Antoine Arnaud <marc-antoine.arnaud@luminvent.com>",
"download_url": null,
"platform": null,
"description": "# Rudof Python bindings\n\nThe Python bindings for [rudof](https://rudof-project.github.io/) are called `pyrudof`. They are available at [pypi](https://pypi.org/project/pyrudof/).\n\nFor more information, you can access the [readthedocs documentation](https://pyrudof.readthedocs.io/en/latest/). We keep several tutorials about rudof as Jupyter notebooks in: [https://rudof-project.github.io/tutorials].\n\nAfter compiling and installing this module, a Python library called `pyrudof` should be available. \n\n## Build the development version\n\nThis module is based on [pyo3](https://pyo3.rs/) and [maturin](https://www.maturin.rs/).\n\nTo build and install the development version of `pyrudof` you need to clone this git repository, go to the `python` directory (the one this README is in) and run:\n\n```\npip install maturin\n```\n\nfollowed by:\n\n```sh\npip install .\n```\n\nIf you are using `.env`, you can do the following:\n\n```sh\npython3 -m venv .venv\n```\n\nfollowed by: \n\n```sh\nsource .venv/bin/activate\n```\n\nor\n\n```sh\nsource .venv/bin/activate.fish\n```\n\nand once you do that, you can locally install que package as:\n\n```sh\npip install -e .\n```\n\n## Running the tests\n\nGo to the tests folder: \n\n```sh\ncd tests\n```\n\nand run: \n\n```sh\npython3 -m unittest discover -vvv\n```\n\n## Using rudof_generate\n\nThe `pyrudof` package includes bindings for `rudof_generate`, which allows you to generate synthetic RDF data from ShEx or SHACL schemas.\n\n### Basic Example\n\n```python\nimport pyrudof\n\n# Create configuration\nconfig = pyrudof.GeneratorConfig()\nconfig.set_entity_count(100)\nconfig.set_output_path(\"output.ttl\")\nconfig.set_output_format(pyrudof.OutputFormat.Turtle)\n\n# Create generator\ngenerator = pyrudof.DataGenerator(config)\n\n# Load schema and generate data\ngenerator.run(\"schema.shex\")\n```\n\n### Configuration Options\n\nThe `GeneratorConfig` class provides many configuration options:\n\n```python\nconfig = pyrudof.GeneratorConfig()\n\n# Generation parameters\nconfig.set_entity_count(1000) # Number of entities to generate\nconfig.set_seed(42) # Random seed for reproducibility\n\n# Schema format\nconfig.set_schema_format(pyrudof.SchemaFormat.ShEx) # or SchemaFormat.SHACL\n\n# Output configuration\nconfig.set_output_path(\"data.ttl\")\nconfig.set_output_format(pyrudof.OutputFormat.Turtle) # or OutputFormat.NTriples\nconfig.set_compress(False) # Whether to compress output\nconfig.set_write_stats(True) # Write generation statistics\n\n# Cardinality strategy\nconfig.set_cardinality_strategy(pyrudof.CardinalityStrategy.Balanced)\n# Options: Minimum, Maximum, Random, Balanced\n\n# Parallel processing\nconfig.set_worker_threads(4) # Number of worker threads\nconfig.set_batch_size(100) # Batch size for processing\nconfig.set_parallel_writing(True) # Enable parallel file writing\nconfig.set_parallel_file_count(4) # Number of output files (when parallel)\n```\n\n### Loading Schemas\n\nYou can load schemas in different ways:\n\n```python\n# Load ShEx schema\ngenerator.load_shex_schema(\"schema.shex\")\n\n# Load SHACL schema\ngenerator.load_shacl_schema(\"shapes.ttl\")\n\n# Auto-detect schema format\ngenerator.load_schema_auto(\"schema_file\")\n\n# Then generate data\ngenerator.generate()\n```\n\n### Complete Workflow\n\nThe `run()` method provides a convenient way to load a schema and generate data in one step:\n\n```python\n# Auto-detect format\ngenerator.run(\"schema.shex\")\n\n# Specify format explicitly\ngenerator.run_with_format(\"shapes.ttl\", pyrudof.SchemaFormat.SHACL)\n```\n\n### Configuration Files\n\nYou can also load configuration from TOML or JSON files:\n\n```python\n# Load from TOML\nconfig = pyrudof.GeneratorConfig.from_toml_file(\"config.toml\")\n\n# Load from JSON\nconfig = pyrudof.GeneratorConfig.from_json_file(\"config.json\")\n\n# Save configuration\nconfig.to_toml_file(\"saved_config.toml\")\n```\n\n### Available Enums\n\n- **SchemaFormat**: `ShEx`, `SHACL`\n- **OutputFormat**: `Turtle`, `NTriples`\n- **CardinalityStrategy**: `Minimum`, `Maximum`, `Random`, `Balanced`\n\nFor more examples, see the `examples/generate_example.py` file.\n",
"bugtrack_url": null,
"license": "MIT OR Apache-2.0",
"summary": "Python bindings for Rudof",
"version": "0.1.135",
"project_urls": {
"Homepage": "https://rudof-project.github.io/rudof",
"Source Code": "https://github.com/rudof-project/rudof"
},
"split_keywords": [
"rdf",
" linked-data",
" semantic-web",
" shex",
" shacl"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "ea31ba4cf71fcc30276fae257cc21030ff1dbe0bfe705bf149f09141696de0e1",
"md5": "88b51befe11727938dffe7f642d1b81f",
"sha256": "2822872f223f291791787558d40ece2da2d492073cf885b34992d5459cb7fc12"
},
"downloads": -1,
"filename": "pyrudof-0.1.135-cp37-abi3-macosx_10_12_x86_64.whl",
"has_sig": false,
"md5_digest": "88b51befe11727938dffe7f642d1b81f",
"packagetype": "bdist_wheel",
"python_version": "cp37",
"requires_python": null,
"size": 8670533,
"upload_time": "2025-10-28T10:13:27",
"upload_time_iso_8601": "2025-10-28T10:13:27.752340Z",
"url": "https://files.pythonhosted.org/packages/ea/31/ba4cf71fcc30276fae257cc21030ff1dbe0bfe705bf149f09141696de0e1/pyrudof-0.1.135-cp37-abi3-macosx_10_12_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "e9e480e4812d4d73474231d4ad6a0fc57a42d68598e221eac29700947bf99a66",
"md5": "617fe9e5aba547cda66c9650ec13e30b",
"sha256": "fc53c3ef5ab455c736f14febf08c2c095f357d49fb67116cae33c95dc9a024f7"
},
"downloads": -1,
"filename": "pyrudof-0.1.135-cp37-abi3-macosx_11_0_arm64.whl",
"has_sig": false,
"md5_digest": "617fe9e5aba547cda66c9650ec13e30b",
"packagetype": "bdist_wheel",
"python_version": "cp37",
"requires_python": null,
"size": 8262808,
"upload_time": "2025-10-28T10:13:30",
"upload_time_iso_8601": "2025-10-28T10:13:30.107116Z",
"url": "https://files.pythonhosted.org/packages/e9/e4/80e4812d4d73474231d4ad6a0fc57a42d68598e221eac29700947bf99a66/pyrudof-0.1.135-cp37-abi3-macosx_11_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "38a17f76c990f5c971b2638d0f437a599cede0f97d1f77f0c78a6c87750cd637",
"md5": "83ebdc9664b781d7cd99806ff1aa8c22",
"sha256": "5ccba2fcac75091aeb828470da7428716f3b75a0e54b389b773788768252d7b5"
},
"downloads": -1,
"filename": "pyrudof-0.1.135-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
"has_sig": false,
"md5_digest": "83ebdc9664b781d7cd99806ff1aa8c22",
"packagetype": "bdist_wheel",
"python_version": "cp37",
"requires_python": null,
"size": 11610365,
"upload_time": "2025-10-28T10:13:31",
"upload_time_iso_8601": "2025-10-28T10:13:31.543032Z",
"url": "https://files.pythonhosted.org/packages/38/a1/7f76c990f5c971b2638d0f437a599cede0f97d1f77f0c78a6c87750cd637/pyrudof-0.1.135-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "0344907dc0e33d899b6ba66acc239fea116f07d810fab35aa914fe894d114f12",
"md5": "6487217c0e6c10d8b99a314e8d15cfac",
"sha256": "817dc5f540ccd388e8e9e6d2fae6c52a1bff58007547b47589033babead333b1"
},
"downloads": -1,
"filename": "pyrudof-0.1.135-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"has_sig": false,
"md5_digest": "6487217c0e6c10d8b99a314e8d15cfac",
"packagetype": "bdist_wheel",
"python_version": "cp37",
"requires_python": null,
"size": 11327540,
"upload_time": "2025-10-28T10:13:33",
"upload_time_iso_8601": "2025-10-28T10:13:33.887638Z",
"url": "https://files.pythonhosted.org/packages/03/44/907dc0e33d899b6ba66acc239fea116f07d810fab35aa914fe894d114f12/pyrudof-0.1.135-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "4076581df9fbcb2838999ad733520f0be9964d82cc060566b1573ae7c2121c18",
"md5": "76a07f5abb187cc3a6f2a4311f28d419",
"sha256": "b4cea7e9f0de227e8bac6a23c3726ce8c44a327bb8a892a91de132b93c59c191"
},
"downloads": -1,
"filename": "pyrudof-0.1.135-cp37-abi3-win_amd64.whl",
"has_sig": false,
"md5_digest": "76a07f5abb187cc3a6f2a4311f28d419",
"packagetype": "bdist_wheel",
"python_version": "cp37",
"requires_python": null,
"size": 7819050,
"upload_time": "2025-10-28T10:13:35",
"upload_time_iso_8601": "2025-10-28T10:13:35.979585Z",
"url": "https://files.pythonhosted.org/packages/40/76/581df9fbcb2838999ad733520f0be9964d82cc060566b1573ae7c2121c18/pyrudof-0.1.135-cp37-abi3-win_amd64.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-28 10:13:27",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "rudof-project",
"github_project": "rudof",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pyrudof"
}