diff --git a/docs/en/api_reference/error.md b/docs/en/api_reference/error.md index 4ad74bd659c630a3b742d57c197f943ee22dc942..2e702e4d31c5a2f96047acc426e166bb13ea4801 100644 --- a/docs/en/api_reference/error.md +++ b/docs/en/api_reference/error.md @@ -1,26 +1,26 @@ # Public Errors -## openmind_hub.utils.OMValidationError +## openmind_hub.OMValidationError Parameter validation failed. -## openmind_hub.utils.EntryNotFoundError +## openmind_hub.EntryNotFoundError The file does not exist. -## openmind_hub.utils.RepositoryNotFoundError +## openmind_hub.RepositoryNotFoundError The repository does not exist. -## openmind_hub.utils.RevisionNotFoundError +## openmind_hub.RevisionNotFoundError The branch or committed version does not exist. -## openmind_hub.utils.GatedRepoError +## openmind_hub.GatedRepoError Access to the repository is restricted. -## openmind_hub.utils.LocalEntryNotFoundError +## openmind_hub.LocalEntryNotFoundError The local file does not exist. @@ -28,6 +28,6 @@ The local file does not exist. Access to the trustlist is restricted. -## openmind_hub.utils.OmHubHTTPError +## openmind_hub.OmHubHTTPError -Parent class of all HTTP exceptions in the openMind Hub Client. +Parent class of all HTTP exceptions in openMind Hub Client. diff --git a/docs/en/api_reference/upload_api.md b/docs/en/api_reference/upload_api.md index f8e14afdb87630e9f52b473896ec9975c74e0c84..3d53a5083968b429ca3ee55cf0a35da8ca44fa61 100644 --- a/docs/en/api_reference/upload_api.md +++ b/docs/en/api_reference/upload_api.md @@ -22,7 +22,7 @@ upload_file( + **path_in_repo** (`str`): path for uploading files to the repository. + **repo_id** (`str`): target repository, in the format of *username*/*repository name*. For the username and repository name, letters, digits, dots (.), underscores (_), and hyphens (-) are allowed. + **token** (`str`, *optional*): access token that has the write permission on the target repository. This parameter is required when this method is used separately. -+ **revision** (`str`, *optional*): branch to be uploaded. Letters, digits, underscores (_), and hyphens (-) are allowed. The default value is **main**. ++ **revision** (`str`, *optional*): branch to be uploaded. Letters, digits, underscores (_), and hyphens (-) are allowed. The default value is **None**. + **commit_message** (`str`, *optional*): commit message of the upload. The default value is **Upload {path_in_repo} with openMind hub**. + **commit_description** (`str`, *optional*): description of this commit. + **kwargs**: required only for compatibility with third-party components. @@ -54,7 +54,7 @@ upload_folder( + **commit_message** (`str`, *optional*): commit message of the upload. The default message is **Upload folder using openMind hub**. + **commit_description** (`str`, *optional*): description of this commit. + **token** (`str`, *optional*): access token that has the write permission on the target repository. This parameter is required when this method is used separately. -+ **revision** (`str`, *optional*): branch to be uploaded. Letters, digits, underscores (_), and hyphens (-) are allowed. The default value is **main**. ++ **revision** (`str`, *optional*): branch to be uploaded. Letters, digits, underscores (_), and hyphens (-) are allowed. The default value is **None**. + **allow_patterns** (`List[str]` or `str`, *optional*): only certain types of files can be uploaded. For example, `allow_patterns=["*.bin, *.py"]` indicates that only .bin and .py files can be uploaded. + **ignore_patterns** (`List[str]` or `str`, *optional*): Ignore the upload of a certain type of files. For example, `ignore_patterns="*.log"` indicates that all log files are ignored. + **num_threads** (`int`, *optional*): number of threads used for uploading. The default value is **5**. @@ -88,6 +88,6 @@ create_commit( + **commit_message** (`str`): commit message of the upload. + **commit_description** (`str`, *optional*): description of this commit. + **token** (`str`, *optional*): access token that has the write permission on the target repository. This parameter is required when this method is used separately. -+ **revision** (`str`, *optional*): branch to be uploaded. Letters, digits, underscores (_), and hyphens (-) are allowed. The default value is **main**. ++ **revision** (`str`, *optional*): branch to be uploaded. Letters, digits, underscores (_), and hyphens (-) are allowed. The default value is **None**. + **num_threads** (`int`, *optional*): number of threads used for uploading. The default value is **5**. + **kwargs**: required only for compatibility with third-party components. diff --git a/docs/en/api_reference/utils_api.md b/docs/en/api_reference/utils_api.md index 39b3163322c6074d3d06dc6b5785a7c9283555d1..480694bb8def616dcb5d181769744769f1f7ad9d 100644 --- a/docs/en/api_reference/utils_api.md +++ b/docs/en/api_reference/utils_api.md @@ -6,7 +6,7 @@ Throw an exception based on the status code of the response body. The following ```python import requests -from openmind_hub.utils import om_raise_for_status +from openmind_hub import om_raise_for_status metadata_url = 'https://modelers.cn/api/v1/file/PyTorch-NPU/t5_small/info?ref=main&path=file_not_exist' r = requests.get(metadata_url) @@ -21,7 +21,7 @@ om_raise_for_status(r, endpoint_name=None) Construct a request header. The following is an example: ```python -from openmind_hub.utils import build_om_headers +from openmind_hub import build_om_headers build_om_headers( token="xxxx", @@ -33,7 +33,132 @@ build_om_headers( ``` + **token** (`str`, *optional*): access token. -+ **is_write_action** (`bool`, *optional*): whether the operation is a write operation. If the value is **True**, `token` is mandatory. The default value is **False**. ++ **is_write_action** (`bool`, *optional*): whether the operation is a write operation. If the value is **True**, `token` is required. The default value is **False**. + **library_name** (`str`, *optional*): name of the library that initiates an external request. + **library_version** (`str`, *optional*): version of the library that initiates an external request. + **user_agent** (`str` or `Dict`, *optional*): information about the user who initiates an external request. + +## Logging Module APIs + +**Description** + +The default log level is **warning**. To change the log level, refer to the following content. + +**APIs** + +**get_logger** + +`get_logger(name=None)`: returns a logger object whose alias can be specified. If **name** is missing, a default root logger is returned. + +**Parameters** + +**name** (`str`, *optional*, defaults to **None**): a string that indicates the alias of a specified logger. + +**Example:** + +```python +from openmind_hub import get_logger + +root_logger = get_logger() + +print(root_logger.name) +``` + +**set_verbosity** + +`set_verbosity(verbosity: int)`: sets the level of the root logger. + +**Parameters** + +**verbosity** (`int`, *required*): log level to be set. + +**Example:** + +```python +from logging import INFO +from openmind_hub import set_verbosity + +set_verbosity(INFO) +``` + +**set_verbosity_info** + +`set_verbosity_info()`: sets the level of the root logger to **INFO**. + +**Example:** + +```python +from openmind_hub import set_verbosity_info + +set_verbosity_info() +``` + +**set_verbosity_warning** + +`set_verbosity_warning()`: sets the level of the root logger to **WARNING**. + +**Example:** + +```python +from openmind_hub import set_verbosity_warning + +set_verbosity_warning() +``` + +**set_verbosity_debug** + +`set_verbosity_debug()`: sets the level of the root logger to **DEBUG**. + +**Example:** + +```python +from openmind_hub import set_verbosity_debug + +set_verbosity_debug() +``` + +**set_verbosity_error** + +`set_verbosity_error()`: sets the level of the root logger to **ERROR**. + +**Example:** + +```python +from openmind_hub import set_verbosity_error + +set_verbosity_error() +``` + +## openmind_hub.replace_invalid_characters + +**Description** + +Filters input character strings by blocklist to prevent risks in logs, and returns the filtered character strings. The filtering rules are as follows: + +1. The following characters are removed: [ + "\r", + "\n", + "\t", + "\f", + "\v", + "\b", + "\u000A", + "\u000D", + "\u000C", + "\u000B", + "\u0008", + "\u007F", + "\u0009" + ] +2. Each time four consecutive spaces are identified, they are replaced with one space. + +**Parameters** + +**content** (`str`, *required*): character string to be filtered. +**allow_line_separator** (`bool`, *optional*, defaults to `False`): whether the newline (`\n`) is allowed in log information. + +**Prototype** + +```python +def replace_invalid_characters(content, allow_line_separator=False): +``` diff --git a/docs/en/basic_tutorial/third-party_platform.md b/docs/en/basic_tutorial/third-party_platform.md index 63814d7486ee5cc063c5efacb98d2277f0aa6ad7..2868dd5d8953e1b3dd4e7899c4388ad3bbe0eeda 100644 --- a/docs/en/basic_tutorial/third-party_platform.md +++ b/docs/en/basic_tutorial/third-party_platform.md @@ -1,8 +1,8 @@ # Interconnection with Third-party Communities -The openMind Hub Client can connect to multiple communities so that you can upload and download files in different communities. Currently, the following communities are interconnected: +openMind Hub Client can connect to multiple communities so that you can upload and download files in different communities. Currently, the following communities are interconnected: -+ [Modelers](https://modelers.cn)): By default, this community is connected. All open interfaces are supported. ++ [Modelers](https://modelers.cn): This community is connected by default. All open interfaces are supported. + [Openl](https://openi.pcl.ac.cn): Only some interfaces are supported, covering repository creation and model upload and download. + [GitCode](https://gitcode.com): Only some interfaces are supported, covering file upload and download, and file acquisition in a repository. + [Gitee AI](https://ai.gitee.com): Only download interfaces are supported. @@ -268,11 +268,11 @@ snapshot_download("owner/repo", token=token, revision="master") > The gitee AI community supports reading access tokens from environment variables or local files. If you use this method, you should take the initiative to prevent the security risks brought by this behavior. -## HuggingFace Community +## Hugging Face Community ### Adapted Interfaces and Differences -You can upload or download files, and create repositories or branches in the HuggingFace community. There is no obvious usage difference. +You can upload or download files, and create repositories or branches in the Hugging Face community. There is no obvious usage difference. + upload_file + upload_folder @@ -288,4 +288,4 @@ token = "xxx" snapshot_download("owner/repo", token=token) ``` -> The HuggingFace community supports reading access tokens from environment variables or local files. If you use this method, you should take the initiative to prevent the security risks brought by this behavior. +> The Hugging Face community supports reading access tokens from environment variables or local files. If you use this method, you should take the initiative to prevent the security risks brought by this behavior. diff --git a/docs/en/basic_tutorial/upload.md b/docs/en/basic_tutorial/upload.md index c6f72bdcd14d886e4668f5b63511263f9e48028a..b1f2a6a0d5a21f0141d60b0a8816151c596d4b1d 100644 --- a/docs/en/basic_tutorial/upload.md +++ b/docs/en/basic_tutorial/upload.md @@ -1,6 +1,6 @@ # Uploading Files -[Access tokens](../quick_start.md# access token) are required to upload files to a repository. +[Access tokens](../quick_start.md#access-token) are required to upload files to a repository. The openMind Hub Client controls file upload paths through blocklist and trustlist. The absolute path of a file cannot start with a path in the blocklist (except the default cache path `~/.cache/openmind`) and must be in the trustlist. The blacklist includes `["/etc", "/var", "/bin", "/boot", "/lib", "~/."]`. The default trustlist is `["/tmp", "~/"]` in Linux and `["~/", "D:", "E:", "F:"]` in Windows. You can configure the environment variable `HUB_WHITE_LIST_PATHS` (separate each path by commas) to configure the trustlist. In addition, the priority of the blocklist permission is higher than that of the trustlist permission. diff --git a/docs/en/developer_tutorial/trouble_shooting.md b/docs/en/developer_tutorial/trouble_shooting.md index 84438540651ad4081b1825f89e5c5d1dcc95ca6d..42963e4ac160557e82ba3a24e414475bec7acc9d 100644 --- a/docs/en/developer_tutorial/trouble_shooting.md +++ b/docs/en/developer_tutorial/trouble_shooting.md @@ -48,9 +48,9 @@ Solution 2: Manually configure the certificate of the Modelers community. 1. Download the certificate from Modelers Community. The following describes the procedure for downloading the certificate using Google Chrome. The procedure for downloading the certificate using other browsers is similar. In Windows, double-click the certificate to install it. In Linux, refer to the following procedure. - ![img.png](figures/certificate download 1.png) ![img_1.png](figures/certificate download 2.png) + ![img.png](figures/certificate_download_1.png) ![img_1.png](figures/certificate_download_2.png) - ![img_2.png](figures/certificate download 3.png) + ![img_2.png](figures/certificate_download_3.png) 2. Move the downloaded certificate to the `/usr/local/share/ca-certificates/` directory. 3. Run `update-ca-certificates`.