proof-of-train


Nameproof-of-train JSON
Version 0.3.0 PyPI version JSON
download
home_pageNone
SummaryProof of Train SDK for submitting and verifying model training metadata on blockchain.
upload_time2024-05-27 02:35:12
maintainerNone
docs_urlNone
authorThomas
requires_python<4.0,>=3.12
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ProofOfTrain Python SDK

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

## Installation

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

```
pip install proof-of-train
```

## Usage

### Initializing the ProofOfTrain object

To start using the ProofOfTrain 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_train import ProofOfTrain

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

pot = ProofOfTrain(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_confirmation` (optional): Whether to wait for the transaction to be confirmed (default: False).

```python
from proof_of_train 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_confirmation=False)
print(f"Transaction hash: {tx_hash}")
```

If `wait_for_confirmation` 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_confirmation` 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_confirmation=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 ProofOfTrain 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-train",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.12",
    "maintainer_email": null,
    "keywords": null,
    "author": "Thomas",
    "author_email": "wxy_000000@qq.com",
    "download_url": "https://files.pythonhosted.org/packages/2d/b9/0f8f042d273ac2e49f1a9ec7b81d770f435c131bb79e809e65c259d7d441/proof_of_train-0.3.0.tar.gz",
    "platform": null,
    "description": "# ProofOfTrain Python SDK\n\nThe ProofOfTrain Python SDK provides a convenient way to interact with the ProofOfTrain smart contract on the blockchain network. It allows you to submit and retrieve model metadata using the ProofOfTrain protocol.\n\n## Installation\n\nTo install the ProofOfTrain Python SDK, use the following command:\n\n```\npip install proof-of-train\n```\n\n## Usage\n\n### Initializing the ProofOfTrain object\n\nTo start using the ProofOfTrain 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_train import ProofOfTrain\n\nrpc_url = \"https://rpc.testnet.rss3.io\"\npublic_key = \"0x1234567890123456789012345678901234567890\"\nprivate_key = \"your-private-key\"\n\npot = ProofOfTrain(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_confirmation` (optional): Whether to wait for the transaction to be confirmed (default: False).\n\n```python\nfrom proof_of_train 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_confirmation=False)\nprint(f\"Transaction hash: {tx_hash}\")\n```\n\nIf `wait_for_confirmation` 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_confirmation` 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_confirmation=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 ProofOfTrain 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 Train SDK for submitting and verifying model training metadata on blockchain.",
    "version": "0.3.0",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c682e91e57b8c3d07aaf69ad6856749a09d5628ba05ab24775909b6d457eae59",
                "md5": "fb2c1b92c057c1757bc5ebeca26b666f",
                "sha256": "887443ef4f58bbf25601b19386990b324f942c590b54469a8ff017353b652730"
            },
            "downloads": -1,
            "filename": "proof_of_train-0.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fb2c1b92c057c1757bc5ebeca26b666f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.12",
            "size": 5958,
            "upload_time": "2024-05-27T02:35:10",
            "upload_time_iso_8601": "2024-05-27T02:35:10.579011Z",
            "url": "https://files.pythonhosted.org/packages/c6/82/e91e57b8c3d07aaf69ad6856749a09d5628ba05ab24775909b6d457eae59/proof_of_train-0.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2db90f8f042d273ac2e49f1a9ec7b81d770f435c131bb79e809e65c259d7d441",
                "md5": "21b92dc3b1a3ea3c0dc0ec328ff4ee99",
                "sha256": "bfdf9b14ae5303a5e1d1e63e10fb6876342f0136a13e8c972aef255bcbcbe820"
            },
            "downloads": -1,
            "filename": "proof_of_train-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "21b92dc3b1a3ea3c0dc0ec328ff4ee99",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.12",
            "size": 5307,
            "upload_time": "2024-05-27T02:35:12",
            "upload_time_iso_8601": "2024-05-27T02:35:12.307403Z",
            "url": "https://files.pythonhosted.org/packages/2d/b9/0f8f042d273ac2e49f1a9ec7b81d770f435c131bb79e809e65c259d7d441/proof_of_train-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-27 02:35:12",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "proof-of-train"
}
        
Elapsed time: 0.32127s