### Install Dependencies
Source: https://github.com/milvus-io/web-content/blob/master/scripts/README.md
Installs project dependencies using npm. Run this command from the `scripts` directory.
```bash
cd scripts
npm ci
```
--------------------------------
### Install Python Test Prerequisites
Source: https://github.com/milvus-io/web-content/blob/master/community/site/en/communityArticles/contributor_group/contributing_test.md
Install the necessary Python packages for PyMilvus ORM testing using the requirements.txt file. Ensure you are in the correct directory.
```bash
pip install -r requirements.txt
```
--------------------------------
### Link Examples to Request Tabs with x-target-request
Source: https://github.com/milvus-io/web-content/blob/master/scripts/apifox-docs/CUSTOM_ATTRIBUTES.md
The `x-target-request` attribute links an example to a specific request tab. The `RestSpecs` component filters examples by matching this value to the currently selected tab.
```json
{
"examples": {
"success": {
"value": { "code": 0 },
"x-target-request": "OPTION 1"
}
}
}
```
--------------------------------
### Filter Examples by Language with x-target-lang
Source: https://github.com/milvus-io/web-content/blob/master/scripts/apifox-docs/CUSTOM_ATTRIBUTES.md
Use `x-target-lang` to filter examples by language. This attribute is utilized in components like `ExampleResponses`, `ExampleRequests`, and `chooseParamExample`.
```json
{
"examples": {
"en": {
"value": { "name": "cluster-1" },
"x-target-lang": "en-US"
}
}
}
```
--------------------------------
### Link Examples to Response Tabs with x-target-response
Source: https://github.com/milvus-io/web-content/blob/master/scripts/apifox-docs/CUSTOM_ATTRIBUTES.md
The `x-target-response` attribute links an example to a specific response tab. The `RestSpecs` component filters examples by matching this value to the currently selected tab.
```json
{
"examples": {
"success": {
"value": { "code": 0 },
"x-target-response": "OPTION 1"
}
}
}
```
--------------------------------
### Example x-base-url-target Usage
Source: https://github.com/milvus-io/web-content/blob/master/scripts/apifox-docs/CUSTOM_ATTRIBUTES.md
This JSON snippet demonstrates how to use the `x-base-url-target` attribute to target specific base URLs. It's meaningful for operations that also define `x-base-urls` with `key` fields.
```json
{
"name": "clusterId",
"in": "query",
"x-base-url-target": ["on-demand-compute"]
}
```
--------------------------------
### Milvus Project OWNERS File Example
Source: https://github.com/milvus-io/web-content/blob/master/community/site/en/communityArticles/contributor_group/owners.md
This YAML file defines reviewers, approvers, and labels for automatic PR tagging. It's used to manage code review assignments and approvals.
```yaml
# order by contributions
reviewers:
- DragonDriver
- czs007
- FluorineDog
- godchen0212
- neza2017
- xiaocai2333
approvers:
- czs007
- neza2017
- scsven
labels:
- component/proxy
```
--------------------------------
### Example Request Body for Creating Collection
Source: https://github.com/milvus-io/web-content/blob/master/scripts/apifox-docs/templates/en-US/reference.md
This JSON object represents a typical request body for creating a collection in Milvus. It includes collection name, dimension, and metric type.
```json
{
"collectionName": "my_collection",
"dimension": 8,
"metricType": "L2"
}
```
--------------------------------
### Example Response Body for Successful Operation
Source: https://github.com/milvus-io/web-content/blob/master/scripts/apifox-docs/templates/en-US/reference.md
This JSON object indicates a successful API operation. The 'code' field is 0, signifying no errors.
```json
{
"code": 0,
"message": "Success"
}
```
--------------------------------
### Fetch SDK Documentation using npm Scripts
Source: https://github.com/milvus-io/web-content/blob/master/scripts/README.md
Run these npm scripts to fetch SDK documentation for various languages and versions. These are shortcuts for common SDK manual publishing tasks.
```bash
npm run fetch-sdk-docs:pymilvus:v2.6
```
```bash
npm run fetch-sdk-docs:java:v2.6
```
```bash
npm run fetch-sdk-docs:node:v2.6
```
```bash
npm run fetch-sdk-docs:go:v2.6
```
```bash
npm run fetch-sdk-docs:cpp:v2.6
```
--------------------------------
### Initialize Partition Wrapper
Source: https://github.com/milvus-io/web-content/blob/master/community/site/en/communityArticles/contributor_group/contributing_test.md
Initializes a partition wrapper with specified properties. Used for setting up partition-related tests.
```python
partition_w = self.init_partition_wrap(collection_w, partition_name, check_task=CheckTasks.check_partition_property, check_items={"name": partition_name, "description": description, "is_empty": True, "num_entities": 0})
```
--------------------------------
### Create Partition Object (Default Initialization)
Source: https://github.com/milvus-io/web-content/blob/master/community/site/en/communityArticles/contributor_group/contributing_test.md
Use `self.init_partition_wrap()` to create a new partition object when multiple instances are needed. This method returns the newly created object.
```python
# create partition -Call the default initialization method
partition_w = self.init_partition_wrap()
assert partition_w.is_empty
```
--------------------------------
### Publish All Documents in a Manual
Source: https://github.com/milvus-io/web-content/blob/master/scripts/README.md
Use this command to publish every document within a specified manual. Ensure you have a config.json file and specify the manual name.
```bash
node lark-docs/index.js -c config.json -m pymilvus-v2.6.x --all
```
--------------------------------
### Get Vector by ID
Source: https://github.com/milvus-io/web-content/blob/master/scripts/apifox-docs/templates/en-US/reference.md
Retrieves a specific vector from a collection using its unique ID.
```APIDOC
## GET /v1/vectors/{collectionName}/{id}
### Description
Retrieves a specific vector from a collection by its ID.
### Method
GET
### Endpoint
/v1/vectors/{collectionName}/{id}
### Parameters
#### Path Parameters
- **collectionName** (string) - Required - The name of the collection to retrieve the vector from.
- **id** (string) - Required - The unique ID of the vector to retrieve.
#### Query Parameters
- No query parameters required
#### Header Parameters
- No header parameters required
## Response
### Response Body
```json
{
"code": 0,
"msg": "string",
"data": {
"id": "string",
"vector": []
}
}
```
| Property | Description |
|----------|---------------------------------------------------------------------------------------------------------------------------------------------|
| __code__ | **integer**
Indicates whether the request succeeds.
- `0`: The request succeeds.
- Others: Some error occurs.
|
| __msg__ | **string**
A message indicating the result of the operation. |
| __data__ | **object**
Contains the retrieved vector data. |
| __data.id__ | **string**
The ID of the vector. |
| __data.vector__ | **array**
The vector embedding. |
```
--------------------------------
### Partition Initialization Method Signature
Source: https://github.com/milvus-io/web-content/blob/master/community/site/en/communityArticles/contributor_group/contributing_test.md
Defines the signature for the `init_partition` method, showing its parameters including optional `check_task` and `check_items` for custom validation.
```python
def init_partition(self, collection, name, description="", check_task=None, check_items=None, **kwargs)
```
--------------------------------
### Example Response Body for Error
Source: https://github.com/milvus-io/web-content/blob/master/scripts/apifox-docs/templates/en-US/reference.md
This JSON object represents an error response from the API. The 'code' field is non-zero, and a 'message' field provides error details.
```json
{
"code": -1,
"message": "Collection already exists"
}
```
--------------------------------
### Configure Feishu/Lark Manuals
Source: https://github.com/milvus-io/web-content/blob/master/scripts/README.md
Defines configuration for importing Feishu/Lark manuals. Specify base token, table ID, source type, language, and output targets.
```json
{
"milvus": {
"manuals": {
"pymilvus-v2.6.x": {
"base": "BASE_TOKEN:TABLE_ID",
"sourceType": "drive",
"language": "python",
"targets": {
"outputDir": "API_Reference/pymilvus/v2.6.x",
"imageDir": "assets"
},
"images": {
"alt_texts": []
}
}
}
}
}
```
--------------------------------
### Create Directories from List
Source: https://github.com/milvus-io/web-content/blob/master/pymilvus-fs.md
Creates a directory structure based on a provided list of directory paths. Ensures uniqueness of paths and sets permissions to 0744. Requires the 'fs' module.
```javascript
const createDirs = (list) => {
fs.mkdirSync("./output", 0744);
const uniq = [...new Set(list)];
uniq.forEach((dirPath) => {
fs.mkdirSync(`./output/${dirPath}`, 0744);
});
};
```
--------------------------------
### Initialize API Wrappers
Source: https://github.com/milvus-io/web-content/blob/master/community/site/en/communityArticles/contributor_group/contributing_test.md
Initializes various API wrappers used for interacting with Milvus functionalities. These are typically set up in the base test class.
```python
self.connection_wrap = ApiConnectionsWrapper()
self.utility_wrap = ApiUtilityWrapper()
self.collection_wrap = ApiCollectionWrapper()
self.partition_wrap = ApiPartitionWrapper()
self.index_wrap = ApiIndexWrapper()
self.collection_schema_wrap = ApiCollectionSchemaWrapper()
self.field_schema_wrap = ApiFieldSchemaWrapper()
```
--------------------------------
### Publish a Single Document by Title
Source: https://github.com/milvus-io/web-content/blob/master/scripts/README.md
Publish a specific document by its title within a manual. This command requires the config file, manual name, document title, and the output path for the generated Markdown.
```bash
node lark-docs/index.js -c config.json -m guides -d "Install Milvus" -o getstarted/install_milvus.md
```
--------------------------------
### Configure Git User Information
Source: https://github.com/milvus-io/web-content/blob/master/community/site/en/communityArticles/contributor_group/making_your_first_contributions.md
Set your GitHub ID and email for Git commits. This is required for your first Git usage.
```bash
git config --global user.name ""
git config --global user.email
```
--------------------------------
### Clone Milvus Repository
Source: https://github.com/milvus-io/web-content/blob/master/community/site/en/communityArticles/contributor_group/making_your_first_contributions.md
Download a copy of the Milvus repository to your local machine. Replace the placeholder with your GitHub ID.
```bash
git clone https://github.com//milvus.git
```
--------------------------------
### Generate Default REST API Entry
Source: https://github.com/milvus-io/web-content/blob/master/scripts/README.md
Use this command to generate the default REST API documentation entry. No specific configuration is provided.
```bash
node fetch-restful-docs.js
```
--------------------------------
### Execute File Operations
Source: https://github.com/milvus-io/web-content/blob/master/pymilvus-fs.md
Orchestrates the directory creation and file copying process using the previously defined functions. Assumes 'dirList' and 'fileList' have been populated.
```javascript
createDirs(dirList);
copyFile(fileList);
```
--------------------------------
### Configure REST API Entries
Source: https://github.com/milvus-io/web-content/blob/master/scripts/README.md
Configures the generation of REST API reference documentation from Apifox. Specify the OpenAPI specification path, language, target, and output directory.
```json
{
"apifox": {
"restful": {
"milvus-v3.0.x": {
"specifications": "scripts/apifox-docs/meta/openapi",
"lang": "en-US",
"target": "milvus",
"targets": {
"outputDir": "API_Reference_MDX/milvus-restful/v3.0.x"
}
}
}
}
}
```
--------------------------------
### Create Collection
Source: https://github.com/milvus-io/web-content/blob/master/scripts/apifox-docs/templates/en-US/reference.md
Creates a new collection with specified properties. This is the first step before creating indexes or inserting data.
```APIDOC
## POST /v1/collections
### Description
Creates a new collection.
### Method
POST
### Endpoint
/v1/collections
### Parameters
#### Path Parameters
- No path parameters required
#### Query Parameters
- No query parameters required
#### Header Parameters
- No header parameters required
### Request Body
```json
{
"collectionName": "string",
"dimension": "integer",
"metricType": "string"
}
```
| Parameter | Description |
|------------------|-------------------------------------------------------------------------------------------|
| __collectionName__ | **string** (required)
The name of the collection to be created. |
| __dimension__ | **integer** (required)
The dimension of the vector embeddings. |
| __metricType__ | **string** (required)
The similarity metric type (e.g., L2, IP, COSINE). |
## Response
### Response Body
```json
{
"code": 0,
"msg": "string"
}
```
| Property | Description |
|----------|---------------------------------------------------------------------------------------------------------------------------------------------|
| __code__ | **integer**
Indicates whether the request succeeds.
- `0`: The request succeeds.
- Others: Some error occurs.
|
| __msg__ | **string**
A message indicating the result of the operation. |
```
--------------------------------
### Create Partition Object (Direct Encapsulated Call)
Source: https://github.com/milvus-io/web-content/blob/master/community/site/en/communityArticles/contributor_group/contributing_test.md
Use `self.partition_wrap` for direct calls to the encapsulated object when a single instance is sufficient. This avoids unnecessary object creation.
```python
# create partition -Directly call the encapsulated object
self.partition_wrap.init_partition(collection=collection_name, name=partition_name)
assert self.partition_wrap.is_empty
```
--------------------------------
### Run Focused Tests
Source: https://github.com/milvus-io/web-content/blob/master/scripts/README.md
Execute specific tests from the current directory. This includes tests for shared synchronization, SDK documentation generation, and general test files.
```bash
npm run test:shared-sync
npm run test:sdk-docs-gen
node --test test/*.test.js apifox-docs/*.test.js
```
--------------------------------
### Create a New Git Branch
Source: https://github.com/milvus-io/web-content/blob/master/community/site/en/communityArticles/contributor_group/making_your_first_contributions.md
Create and switch to a new branch for your contributions. Use a descriptive name for the branch.
```bash
cd milvus
git checkout -b
```
--------------------------------
### Run Milvus Integration Tests
Source: https://github.com/milvus-io/web-content/blob/master/community/site/en/communityArticles/contributor_group/contributing_to_milvus.md
Execute integration tests for Milvus. Ensure all smoke tests are included.
```bash
pytest --tags=smoke .
```
--------------------------------
### Environment Variables for Feishu/Lark Publishing
Source: https://github.com/milvus-io/web-content/blob/master/scripts/README.md
Set these environment variables for Feishu/Lark publishing. API credentials are required for publishing. Optional variables are used for image and OpenAPI uploads.
```bash
FEISHU_HOST=https://open.feishu.cn
APP_ID=...
APP_SECRET=...
IMAGE_BED_URL=https://zdoc-images.s3.us-west-2.amazonaws.com
```
--------------------------------
### Basic Variable Declaration
Source: https://github.com/milvus-io/web-content/blob/master/test/example.mdx
Demonstrates a simple JavaScript variable declaration within an MDX file.
```javascript
const a = "test"
```
--------------------------------
### RESTful API Reference
Source: https://github.com/milvus-io/web-content/blob/master/scripts/apifox-docs/templates/reference.mdx
This section details the available RESTful API endpoints, their corresponding HTTP methods, and expected parameters for interacting with Milvus.
```APIDOC
## RESTful API Reference
### Description
This section details the available RESTful API endpoints, their corresponding HTTP methods, and expected parameters for interacting with Milvus.
### Method
{{ page_method }}
### Endpoint
{{ page_url }}
### Parameters
This section would typically detail Path Parameters, Query Parameters, and Request Body fields if they were explicitly defined in the source. The provided source does not specify these details.
### Request Example
This section would typically include a request example if provided in the source.
### Response
#### Success Response
This section would typically detail the success response schema if provided in the source.
#### Response Example
This section would typically include a response example if provided in the source.
```
--------------------------------
### Test Dropped Collection Partition Creation
Source: https://github.com/milvus-io/web-content/blob/master/community/site/en/communityArticles/contributor_group/contributing_test.md
Tests the scenario of creating a partition in a collection that has been dropped. This test is expected to raise an exception.
```python
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.parametrize("partition_name", [cf.gen_unique_str(prefix)])
def test_partition_dropped_collection(self, partition_name):
"""
target: verify create partition against a dropped collection
method: 1. create collection1
2. drop collection1
3. create partition in collection1
expected: 1. raise exception
"""
# create collection
collection_w = self.init_collection_wrap()
# drop collection
collection_w.drop()
# create partition failed
self.partition_wrap.init_partition(collection_w.collection, partition_name, check_task=CheckTasks.err_res, check_items={ct.err_code: 1, ct.err_msg: "can't find collection"})
```
--------------------------------
### Generate Named REST API Entry
Source: https://github.com/milvus-io/web-content/blob/master/scripts/README.md
Use this command to generate a REST API documentation entry with a specific name, such as a version.
```bash
node fetch-restful-docs.js -e milvus-v3.0.x
```
--------------------------------
### Push Changes to GitHub
Source: https://github.com/milvus-io/web-content/blob/master/community/site/en/communityArticles/contributor_group/making_your_first_contributions.md
Upload your local branch and commits to your forked repository on GitHub. Ensure your fork is synced before pushing.
```bash
git push origin
```
--------------------------------
### Stage Modified Files
Source: https://github.com/milvus-io/web-content/blob/master/community/site/en/communityArticles/contributor_group/making_your_first_contributions.md
Add specific files or all modified files to the staging area before committing. Replace placeholders with actual filenames.
```bash
git add
```
--------------------------------
### Run Milvus End-to-End Tests
Source: https://github.com/milvus-io/web-content/blob/master/community/site/en/communityArticles/contributor_group/contributing_to_milvus.md
Execute the complete set of functional test cases for Milvus.
```bash
pytest .
```
--------------------------------
### Publish All Children Under a Parent Document
Source: https://github.com/milvus-io/web-content/blob/master/scripts/README.md
Recursively publish all child documents under a given parent document title within a manual. This is useful for publishing entire sections of documentation.
```bash
node lark-docs/index.js -c config.json -m guides -d "Get Started" --recursive
```
--------------------------------
### List Collections
Source: https://github.com/milvus-io/web-content/blob/master/scripts/apifox-docs/templates/en-US/reference.md
Retrieves a list of all existing collections in the Milvus instance.
```APIDOC
## GET /v1/collections
### Description
Lists all existing collections.
### Method
GET
### Endpoint
/v1/collections
### Parameters
#### Path Parameters
- No path parameters required
#### Query Parameters
- No query parameters required
#### Header Parameters
- No header parameters required
## Response
### Response Body
```json
{
"code": 0,
"msg": "string",
"data": {
"collections": [
{
"name": "string",
"description": "string"
}
]
}
}
```
| Property | Description |
|----------|---------------------------------------------------------------------------------------------------------------------------------------------|
| __code__ | **integer**
Indicates whether the request succeeds.
- `0`: The request succeeds.
- Others: Some error occurs.
|
| __msg__ | **string**
A message indicating the result of the operation. |
| __data__ | **object**
Contains the list of collections. |
| __data.collections__ | **array**
A list of collection objects. |
| __data.collections[].name__ | **string**
The name of the collection. |
| __data.collections[].description__ | **string**
The description of the collection. |
```
--------------------------------
### Execute E2E Kubernetes Test Cases
Source: https://github.com/milvus-io/web-content/blob/master/community/site/en/communityArticles/contributor_group/contributing_test.md
Run end-to-end regression test cases using the e2e-k8s.sh script. The KinD environment is automatically cleaned up by default.
```bash
./e2e-k8s.sh
```
```bash
./e2e-k8s.sh --skip-cleanup
```
```bash
./e2e-k8s.sh --skip-cleanup --skip-test --manual
```
```bash
./e2e-k8s.sh --help
```
```bash
kind export logs .
```
--------------------------------
### Custom Tag Descriptions and Milvus Name Overrides
Source: https://github.com/milvus-io/web-content/blob/master/scripts/apifox-docs/CUSTOM_ATTRIBUTES.md
Use `descriptions.json` to provide custom descriptions for tag groups and override Milvus-specific names. This helps in organizing and presenting API documentation clearly.
```json
[
{
"name": "cloud-meta",
"description": "Endpoints for retrieving cloud provider and region metadata.",
"milvus": {
"name": "cloud-meta"
}
}
]
```
--------------------------------
### x-i18n for Summary and Description
Source: https://github.com/milvus-io/web-content/blob/master/scripts/apifox-docs/CUSTOM_ATTRIBUTES.md
Provides localized translations for `summary` and `description` in Chinese (`zh-CN`). Used by `refGen.js` at build time and `RestSpecs` at runtime.
```json
{
"summary": "List Cloud Providers",
"x-i18n": {
"zh-CN": {
"summary": "查看云服务提供商",
"description": "本接口可列出所有可用的云服务商相关信息。"
}
}
}
```
--------------------------------
### Override REST API Generation Config
Source: https://github.com/milvus-io/web-content/blob/master/scripts/README.md
This command allows overriding default configuration values for REST API documentation generation directly from the command line. It specifies the source directory for API definitions, the language, the target name, and the output directory.
```bash
node fetch-restful-docs.js \
-s scripts/apifox-docs/meta/openapi \
-l en-US \
-t milvus \
-o API_Reference_MDX/milvus-restful/v3.0.x
```
--------------------------------
### Configure Test Log Path
Source: https://github.com/milvus-io/web-content/blob/master/community/site/en/communityArticles/contributor_group/contributing_test.md
Set the environment variable CI_LOG_PATH to customize the directory where test logs will be stored. This allows for better organization of test output.
```bash
export CI_LOG_PATH=/tmp/ci_logs/test/
```
--------------------------------
### Reusable x-base-urls Definition
Source: https://github.com/milvus-io/web-content/blob/master/scripts/apifox-docs/CUSTOM_ATTRIBUTES.md
Defines custom base URLs once in the components section for reuse across multiple operations. This promotes consistency and simplifies maintenance.
```json
{
"components": {
"x-base-urls": {
"ZillizVectorV2": [
{
"key": "cluster",
"label": "Cluster Endpoint",
"...": "..."
}
]
}
}
}
```
--------------------------------
### Copy Files Recursively
Source: https://github.com/milvus-io/web-content/blob/master/pymilvus-fs.md
Recursively copies files to the output directory. Handles nested file structures and includes error handling for the copy operation. Requires the 'fs' module.
```javascript
const copyFile = (fileList) => {
for (file of fileList) {
if (typeof file === "object") {
copyFile(file);
} else {
fs.copyFile(file, `./output/${file}`, (err) => {
if (err) throw err;
});
}
}
};
```
--------------------------------
### Create Index
Source: https://github.com/milvus-io/web-content/blob/master/scripts/apifox-docs/templates/en-US/reference.md
Creates an index on a specified field within a collection to accelerate search operations.
```APIDOC
## POST /v1/indexes
### Description
Creates an index on a specified field within a collection.
### Method
POST
### Endpoint
/v1/indexes
### Parameters
#### Path Parameters
- No path parameters required
#### Query Parameters
- No query parameters required
#### Header Parameters
- No header parameters required
### Request Body
```json
{
"collectionName": "string",
"fieldName": "string",
"indexType": "string",
"params": {},
"indexName": "string"
}
```
| Parameter | Description |
|------------------|-------------------------------------------------------------------------------------------|
| __collectionName__ | **string** (required)
The name of the collection where the index will be created. |
| __fieldName__ | **string** (required)
The name of the field to index. |
| __indexType__ | **string** (required)
The type of index to create (e.g., FLAT, IVF_FLAT). |
| __params__ | **object** (required)
Index-specific parameters. |
| __indexName__ | **string** (optional)
The name of the index. If not provided, a default name will be generated. |
## Response
### Response Body
```json
{
"code": 0,
"msg": "string"
}
```
| Property | Description |
|----------|---------------------------------------------------------------------------------------------------------------------------------------------|
| __code__ | **integer**
Indicates whether the request succeeds.
- `0`: The request succeeds.
- Others: Some error occurs.
|
| __msg__ | **string**
A message indicating the result of the operation. |
```
--------------------------------
### Execute Pytest Test Cases
Source: https://github.com/milvus-io/web-content/blob/master/community/site/en/communityArticles/contributor_group/contributing_test.md
Run specific test files using the python3 -m pytest command. The -W ignore flag suppresses warnings during execution.
```bash
python3 -W ignore -m pytest
```