proof-of-training


Nameproof-of-training JSON
Version 0.7.0 PyPI version JSON
download
home_pageNone
SummaryProof of Training SDK for submitting and verifying model training metadata on blockchain.
upload_time2024-10-24 08:17:50
maintainerNone
docs_urlNone
authorThomas
requires_python<4.0,>=3.11
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ProofOfTraining Python SDK

The ProofOfTraining Python SDK provides a convenient way to interact with the ProofOfTraining smart contract on the blockchain network. It allows you to submit and retrieve model metadata using the ProofOfTraining protocol.

## Installation

To install the ProofOfTraining Python SDK, use the following command:

```
pip install proof-of-training
```

## Usage

### Initializing the ProofOfTraining object

To start using the ProofOfTraining SDK, you need to create an instance of the `ProofOfTrain` class by providing the following parameters:

- `rpc_url`: The RPC URL of the blockchain network to connect for submitting and verifying metadata.
- `public_key`: The public key of the user, used to identify the sender of the transactions.
- `private_key`: The private key of the user, used for signing transactions to ensure security and authenticity.

```python
from proof_of_training import ProofOfTraining

rpc_url = "https://rpc.testnet.rss3.io"
public_key = "0x1234567890123456789012345678901234567890"
private_key = "your-private-key"

pot = ProofOfTraining(rpc_url, public_key, private_key)
```

### Submitting Model Metadata

To submit model metadata to the blockchain, use the `submit_proof` method of the `ProofOfTrain` object. This method takes the following parameters:

- `model_id`: The unique identifier of the model.
- `metadata`: An instance of `ModelMetadata` containing the model's metadata.
- `gas` (optional): The gas limit for the transaction (default: 500000).
- `gas_price` (optional): The gas price in gwei (default: 50).
- `wait_for_receipt` (optional): Whether to wait for the transaction to be confirmed (default: False).

```python
from proof_of_training import ModelMetadata

model_id = "your-model-id"
metadata = ModelMetadata(
    model_name="Model Name",
    model_md5="d4c2e8a2b3cb1a9c0a7b7f4c5a9a3b2e",
    model_url="https://huggingface.co/bert-base-uncased",
    dataset_url="https://huggingface.co/datasets/glue",
    training_params={"epochs": 3, "batch_size": 32},
    training_date="2024-05-27",
    model_version="1.0",
    author="Hugging Face",
    description="BERT base model, uncased version, trained on the GLUE dataset."
)

tx_hash = pot.submit_proof(model_id, metadata, wait_for_receipt=False)
print(f"Transaction hash: {tx_hash}")
```

If `wait_for_receipt` is set to `False` (which is the default), the `submit_proof` method will return the transaction hash. You can use this hash to track the status of the transaction later.

If `wait_for_receipt` is set to `True`, the method will wait for the transaction to be confirmed on the blockchain and return the transaction receipt.

```python
tx_receipt = pot.submit_proof(model_id, metadata, wait_for_receipt=True)
print(f"Transaction receipt: {tx_receipt}")
```

### Retrieving Model Metadata

To retrieve the metadata for a specific model from the blockchain, use the `get_proof` method of the `ProofOfTrain` object. This method takes the `model_id` parameter, which is the unique identifier of the model.

```python
model_id = "your-model-id"
metadata = pot.get_proof(model_id)

if metadata:
    print(f"Model ID: {model_id}")
    print(f"Model Name: {metadata.model_name}")
    print(f"Model MD5: {metadata.model_md5}")
    print(f"Model URL: {metadata.model_url}")
    print(f"Dataset URL: {metadata.dataset_url}")
    print(f"Training Params: {metadata.training_params}")
    print(f"Training Date: {metadata.training_date}")
    print(f"Model Version: {metadata.model_version}")
    print(f"Author: {metadata.author}")
    print(f"Description: {metadata.description}")
else:
    print(f"Model with ID {model_id} not found.")
```

## Error Handling

The SDK handles common errors that may occur during the interaction with the blockchain network. If an error occurs, an appropriate exception will be raised with a descriptive error message.

## License

This SDK is released under the [MIT License](LICENSE).

## Contributing

Contributions to the ProofOfTraining Python SDK are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the [GitHub repository](https://github.com/RSS3-Network/pot).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "proof-of-training",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.11",
    "maintainer_email": null,
    "keywords": null,
    "author": "Thomas",
    "author_email": "wxy_000000@qq.com",
    "download_url": "https://files.pythonhosted.org/packages/cb/34/3ed81c4df2eaa2b72fba7d331c8637c506c4f8665a310cc542649a0c7dbb/proof_of_training-0.7.0.tar.gz",
    "platform": null,
    "description": "# ProofOfTraining Python SDK\n\nThe ProofOfTraining Python SDK provides a convenient way to interact with the ProofOfTraining smart contract on the blockchain network. It allows you to submit and retrieve model metadata using the ProofOfTraining protocol.\n\n## Installation\n\nTo install the ProofOfTraining Python SDK, use the following command:\n\n```\npip install proof-of-training\n```\n\n## Usage\n\n### Initializing the ProofOfTraining object\n\nTo start using the ProofOfTraining SDK, you need to create an instance of the `ProofOfTrain` class by providing the following parameters:\n\n- `rpc_url`: The RPC URL of the blockchain network to connect for submitting and verifying metadata.\n- `public_key`: The public key of the user, used to identify the sender of the transactions.\n- `private_key`: The private key of the user, used for signing transactions to ensure security and authenticity.\n\n```python\nfrom proof_of_training import ProofOfTraining\n\nrpc_url = \"https://rpc.testnet.rss3.io\"\npublic_key = \"0x1234567890123456789012345678901234567890\"\nprivate_key = \"your-private-key\"\n\npot = ProofOfTraining(rpc_url, public_key, private_key)\n```\n\n### Submitting Model Metadata\n\nTo submit model metadata to the blockchain, use the `submit_proof` method of the `ProofOfTrain` object. This method takes the following parameters:\n\n- `model_id`: The unique identifier of the model.\n- `metadata`: An instance of `ModelMetadata` containing the model's metadata.\n- `gas` (optional): The gas limit for the transaction (default: 500000).\n- `gas_price` (optional): The gas price in gwei (default: 50).\n- `wait_for_receipt` (optional): Whether to wait for the transaction to be confirmed (default: False).\n\n```python\nfrom proof_of_training import ModelMetadata\n\nmodel_id = \"your-model-id\"\nmetadata = ModelMetadata(\n    model_name=\"Model Name\",\n    model_md5=\"d4c2e8a2b3cb1a9c0a7b7f4c5a9a3b2e\",\n    model_url=\"https://huggingface.co/bert-base-uncased\",\n    dataset_url=\"https://huggingface.co/datasets/glue\",\n    training_params={\"epochs\": 3, \"batch_size\": 32},\n    training_date=\"2024-05-27\",\n    model_version=\"1.0\",\n    author=\"Hugging Face\",\n    description=\"BERT base model, uncased version, trained on the GLUE dataset.\"\n)\n\ntx_hash = pot.submit_proof(model_id, metadata, wait_for_receipt=False)\nprint(f\"Transaction hash: {tx_hash}\")\n```\n\nIf `wait_for_receipt` is set to `False` (which is the default), the `submit_proof` method will return the transaction hash. You can use this hash to track the status of the transaction later.\n\nIf `wait_for_receipt` is set to `True`, the method will wait for the transaction to be confirmed on the blockchain and return the transaction receipt.\n\n```python\ntx_receipt = pot.submit_proof(model_id, metadata, wait_for_receipt=True)\nprint(f\"Transaction receipt: {tx_receipt}\")\n```\n\n### Retrieving Model Metadata\n\nTo retrieve the metadata for a specific model from the blockchain, use the `get_proof` method of the `ProofOfTrain` object. This method takes the `model_id` parameter, which is the unique identifier of the model.\n\n```python\nmodel_id = \"your-model-id\"\nmetadata = pot.get_proof(model_id)\n\nif metadata:\n    print(f\"Model ID: {model_id}\")\n    print(f\"Model Name: {metadata.model_name}\")\n    print(f\"Model MD5: {metadata.model_md5}\")\n    print(f\"Model URL: {metadata.model_url}\")\n    print(f\"Dataset URL: {metadata.dataset_url}\")\n    print(f\"Training Params: {metadata.training_params}\")\n    print(f\"Training Date: {metadata.training_date}\")\n    print(f\"Model Version: {metadata.model_version}\")\n    print(f\"Author: {metadata.author}\")\n    print(f\"Description: {metadata.description}\")\nelse:\n    print(f\"Model with ID {model_id} not found.\")\n```\n\n## Error Handling\n\nThe SDK handles common errors that may occur during the interaction with the blockchain network. If an error occurs, an appropriate exception will be raised with a descriptive error message.\n\n## License\n\nThis SDK is released under the [MIT License](LICENSE).\n\n## Contributing\n\nContributions to the ProofOfTraining Python SDK are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the [GitHub repository](https://github.com/RSS3-Network/pot).\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Proof of Training SDK for submitting and verifying model training metadata on blockchain.",
    "version": "0.7.0",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1cc9faafb0022ded50a0c91b69ee32a2b8b62cb6f12edb9447b40395176b1a1c",
                "md5": "6157fdf78350524d37d080c07e83e2e1",
                "sha256": "8f2d22cc77f7ff090138f79f621c348f2389c054537333afbba15e66b4f7aee0"
            },
            "downloads": -1,
            "filename": "proof_of_training-0.7.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6157fdf78350524d37d080c07e83e2e1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.11",
            "size": 6329,
            "upload_time": "2024-10-24T08:17:48",
            "upload_time_iso_8601": "2024-10-24T08:17:48.534698Z",
            "url": "https://files.pythonhosted.org/packages/1c/c9/faafb0022ded50a0c91b69ee32a2b8b62cb6f12edb9447b40395176b1a1c/proof_of_training-0.7.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cb343ed81c4df2eaa2b72fba7d331c8637c506c4f8665a310cc542649a0c7dbb",
                "md5": "d954c68a3f0c89378d65f6c20b478e15",
                "sha256": "0de6950c7987b41a4b715437cdb3f8a4b97d96184221486ea5fda2cd87a1915c"
            },
            "downloads": -1,
            "filename": "proof_of_training-0.7.0.tar.gz",
            "has_sig": false,
            "md5_digest": "d954c68a3f0c89378d65f6c20b478e15",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.11",
            "size": 5592,
            "upload_time": "2024-10-24T08:17:50",
            "upload_time_iso_8601": "2024-10-24T08:17:50.021924Z",
            "url": "https://files.pythonhosted.org/packages/cb/34/3ed81c4df2eaa2b72fba7d331c8637c506c4f8665a310cc542649a0c7dbb/proof_of_training-0.7.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-24 08:17:50",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "proof-of-training"
}
        
Elapsed time: 0.34430s