Name | nshconfig-extra JSON |
Version |
0.3.0
JSON |
| download |
home_page | None |
Summary | None |
upload_time | 2024-09-06 00:43:46 |
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/a2/88/28d1b4ef225b08516ba5418088a4e5c95a2fdac15696b0baede2b0c538ae/nshconfig_extra-0.3.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.3.0",
"project_urls": {
"homepage": "https://github.com/nimashoghi/nshconfig-extra"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d49f81cb357d91ee9b65786cb0a742ff7674e12dc4246cc1515d20b428f233ba",
"md5": "5153fc4beff550f5f17e7080fa806ceb",
"sha256": "cc6980331f8cfae9ce9c8ebd96e723533931f72996c3b8f745b6804659dba1fa"
},
"downloads": -1,
"filename": "nshconfig_extra-0.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5153fc4beff550f5f17e7080fa806ceb",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.10",
"size": 3867,
"upload_time": "2024-09-06T00:43:45",
"upload_time_iso_8601": "2024-09-06T00:43:45.709640Z",
"url": "https://files.pythonhosted.org/packages/d4/9f/81cb357d91ee9b65786cb0a742ff7674e12dc4246cc1515d20b428f233ba/nshconfig_extra-0.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a28828d1b4ef225b08516ba5418088a4e5c95a2fdac15696b0baede2b0c538ae",
"md5": "1644b824d2e2180fceda59e4cb40b41d",
"sha256": "d8d47b4557022718f48bcae1c7a3c1a5c08e6b5ce473c22cb51661c0240161c5"
},
"downloads": -1,
"filename": "nshconfig_extra-0.3.0.tar.gz",
"has_sig": false,
"md5_digest": "1644b824d2e2180fceda59e4cb40b41d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.10",
"size": 3313,
"upload_time": "2024-09-06T00:43:46",
"upload_time_iso_8601": "2024-09-06T00:43:46.646816Z",
"url": "https://files.pythonhosted.org/packages/a2/88/28d1b4ef225b08516ba5418088a4e5c95a2fdac15696b0baede2b0c538ae/nshconfig_extra-0.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-06 00:43:46",
"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"
}