| Name | nshconfig-extra JSON |
| Version |
0.4.0
JSON |
| download |
| home_page | None |
| Summary | None |
| upload_time | 2024-10-22 14:18:57 |
| maintainer | None |
| docs_url | None |
| author | Nima Shoghi |
| requires_python | <4.0,>=3.10 |
| license | None |
| keywords |
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
# nshconfig-extra
`nshconfig-extra` is a collection of additional configuration types for the [nshconfig](https://github.com/nimashoghi/nshconfig) library. It extends the functionality of `nshconfig` by providing support for some additional custom configuration types, such as `HFPath` for working with Hugging Face paths and URLs.
## Installation
To install `nshconfig-extra`, use the following command:
```bash
pip install nshconfig-extra
```
If you want to use the this library with optional dependencies, you can install the extra dependencies using the following command:
```bash
pip install nshconfig-extra[extra]
```
## Usage
### HFPath
The `HFPath` configuration type allows you to define and work with Hugging Face paths and URLs seamlessly. It provides methods for parsing Hugging Face paths and URLs and downloading the corresponding files.
#### Parsing Hugging Face Paths
To parse a Hugging Face path, use the `HFPath.from_hf_path()` method:
```python
from nshconfig_extra import HFPath
path = HFPath.from_hf_path("user/repo@branch/path/to/file")
```
The path should be in the format `{user}/{repo}@{branch}/{path/to/file}`. If the branch is not specified, the default branch "main" will be used. If the file path is not specified, an empty string will be used.
#### Parsing Hugging Face URLs
To parse a Hugging Face URL, use the `HFPath.from_hf_url()` method:
```python
from nshconfig_extra import HFPath
path = HFPath.from_hf_url("https://huggingface.co/user/repo/resolve/branch/path/to/file")
```
The URL should be a valid Hugging Face URL pointing to a specific file in a repository.
#### Downloading Files
Once you have an `HFPath` instance, you can download the corresponding file using the `download()` method:
```python
local_path = path.download()
```
The `download()` method will download the file if it doesn't exist locally and return the local path to the downloaded file.
## Contributing
Contributions to `nshconfig-extra` are welcome! If you encounter any issues or have suggestions for improvement, please open an issue or submit a pull request on the [GitHub repository](https://github.com/nimashoghi/nshconfig-extra).
## License
`nshconfig-extra` is open-source software licensed under the [MIT License](LICENSE).
## Acknowledgements
`nshconfig-extra` (and `nshconfig`) are heavily dependent on the [Pydantic](https://pydantic-docs.helpmanual.io/) library for defining and validating configuration types.
Raw data
{
"_id": null,
"home_page": null,
"name": "nshconfig-extra",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.10",
"maintainer_email": null,
"keywords": null,
"author": "Nima Shoghi",
"author_email": "nimashoghi@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/30/12/41e5039bcdc8253e78525ce88c0f4d660fec90f6b6c659615078730be138/nshconfig_extra-0.4.0.tar.gz",
"platform": null,
"description": "# nshconfig-extra\n\n`nshconfig-extra` is a collection of additional configuration types for the [nshconfig](https://github.com/nimashoghi/nshconfig) library. It extends the functionality of `nshconfig` by providing support for some additional custom configuration types, such as `HFPath` for working with Hugging Face paths and URLs.\n\n## Installation\n\nTo install `nshconfig-extra`, use the following command:\n\n```bash\npip install nshconfig-extra\n```\n\nIf you want to use the this library with optional dependencies, you can install the extra dependencies using the following command:\n\n```bash\npip install nshconfig-extra[extra]\n```\n\n## Usage\n\n### HFPath\n\nThe `HFPath` configuration type allows you to define and work with Hugging Face paths and URLs seamlessly. It provides methods for parsing Hugging Face paths and URLs and downloading the corresponding files.\n\n#### Parsing Hugging Face Paths\n\nTo parse a Hugging Face path, use the `HFPath.from_hf_path()` method:\n\n```python\nfrom nshconfig_extra import HFPath\n\npath = HFPath.from_hf_path(\"user/repo@branch/path/to/file\")\n```\n\nThe path should be in the format `{user}/{repo}@{branch}/{path/to/file}`. If the branch is not specified, the default branch \"main\" will be used. If the file path is not specified, an empty string will be used.\n\n#### Parsing Hugging Face URLs\n\nTo parse a Hugging Face URL, use the `HFPath.from_hf_url()` method:\n\n```python\nfrom nshconfig_extra import HFPath\n\npath = HFPath.from_hf_url(\"https://huggingface.co/user/repo/resolve/branch/path/to/file\")\n```\n\nThe URL should be a valid Hugging Face URL pointing to a specific file in a repository.\n\n#### Downloading Files\n\nOnce you have an `HFPath` instance, you can download the corresponding file using the `download()` method:\n\n```python\nlocal_path = path.download()\n```\n\nThe `download()` method will download the file if it doesn't exist locally and return the local path to the downloaded file.\n\n## Contributing\n\nContributions to `nshconfig-extra` are welcome! If you encounter any issues or have suggestions for improvement, please open an issue or submit a pull request on the [GitHub repository](https://github.com/nimashoghi/nshconfig-extra).\n\n## License\n\n`nshconfig-extra` is open-source software licensed under the [MIT License](LICENSE).\n\n## Acknowledgements\n\n`nshconfig-extra` (and `nshconfig`) are heavily dependent on the [Pydantic](https://pydantic-docs.helpmanual.io/) library for defining and validating configuration types.\n",
"bugtrack_url": null,
"license": null,
"summary": null,
"version": "0.4.0",
"project_urls": {
"homepage": "https://github.com/nimashoghi/nshconfig-extra"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ae12a496e95c93bae3ce7a98bac1aec1b545febafab92422b9ebe599a8930a04",
"md5": "3f5ffee1d8160fa5c48c66063c0ece8e",
"sha256": "8f3632d886a3959b7ae41a5c117a8dabd62674937c54bdc6cc29d9615f19e568"
},
"downloads": -1,
"filename": "nshconfig_extra-0.4.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3f5ffee1d8160fa5c48c66063c0ece8e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.10",
"size": 3900,
"upload_time": "2024-10-22T14:18:56",
"upload_time_iso_8601": "2024-10-22T14:18:56.582965Z",
"url": "https://files.pythonhosted.org/packages/ae/12/a496e95c93bae3ce7a98bac1aec1b545febafab92422b9ebe599a8930a04/nshconfig_extra-0.4.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "301241e5039bcdc8253e78525ce88c0f4d660fec90f6b6c659615078730be138",
"md5": "cf6f4b837e6a07857deceb2269c1e2eb",
"sha256": "76aa3543e9be00bb3b853cda600795d8598d8c42f230056167d7e98355b12cee"
},
"downloads": -1,
"filename": "nshconfig_extra-0.4.0.tar.gz",
"has_sig": false,
"md5_digest": "cf6f4b837e6a07857deceb2269c1e2eb",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.10",
"size": 3326,
"upload_time": "2024-10-22T14:18:57",
"upload_time_iso_8601": "2024-10-22T14:18:57.399420Z",
"url": "https://files.pythonhosted.org/packages/30/12/41e5039bcdc8253e78525ce88c0f4d660fec90f6b6c659615078730be138/nshconfig_extra-0.4.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-22 14:18:57",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "nimashoghi",
"github_project": "nshconfig-extra",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "nshconfig-extra"
}