1
0
mirror of https://github.com/oceanprotocol/docs.git synced 2024-06-29 00:58:02 +02:00

Issue #1004 specify consumer parameters type and required (#1005)

* Update consumerParameters section of DDO spec, specify type/required
This commit is contained in:
David Hunt-Mateo 2022-05-26 10:36:07 -04:00 committed by GitHub
parent 17f0c7c01e
commit 3cfd49cb36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -444,82 +444,71 @@ Example:
#### Consumer Parameters #### Consumer Parameters
Sometimes, the asset needs additional input data before downloading a dataset or running an algorithm. Sometimes, the asset needs additional input data before downloading or running a Compute-to-Data job.
Examples: Examples:
- The publisher needs to know the sampling interval before the buyer downloads it. Suppose the dataset URL is `https://example.com/mydata`. The publisher defines a field called `sampling` and asks the buyer to enter a value. This parameter is then added to the URL of the published dataset as query parameters: `https://example.com/mydata?sampling=10`. - The publisher needs to know the sampling interval before the buyer downloads it. Suppose the dataset URL is `https://example.com/mydata`. The publisher defines a field called `sampling` and asks the buyer to enter a value. This parameter is then added to the URL of the published dataset as query parameters: `https://example.com/mydata?sampling=10`.
- An algorithm that needs to know the number of iterations it should perform. In this case, the algorithm publisher defines a field called `iterations`. The buyer needs to enter a value for the `iterations` parameter. Later, this value is stored in a specific location in the Computer-to-Data pod for the algorithm to read and use it. - An algorithm that needs to know the number of iterations it should perform. In this case, the algorithm publisher defines a field called `iterations`. The buyer needs to enter a value for the `iterations` parameter. Later, this value is stored in a specific location in the Compute-to-Data pod for the algorithm to read and use it.
It's an array of elements, each element object defines a field. The `consumerParameters` is an array of objects. Each object defines a field and has the following structure:
An element looks like:
```json | Attribute | Type | Required | Description |
{ | ----------------- | --------------------------------------------------- | -------- | -------------------------------------------------------------------------- |
"name": "hometown", | **`name`** | `string` | **✓** | The parameter name (this is sent as HTTP param or key towards algo) |
"type": "text", | **`type`** | `string` | **✓** | The field type (text, number, boolean, select) |
"label": "Hometown", | **`label`** | `string` | **✓** | The field label which is displayed |
"required": true, | **`required`** | `boolean` | **✓** | If customer input for this field is mandatory. |
"description": "What is your hometown?", | **`description`** | `string` | **✓** | The field description. |
"default": "Nowhere", | **`default`** | `string`, `number`, or `boolean` | **✓** | The field default value. For select types, `string` key of default option. |
"options": [] | **`options`** | Array of `option` | | For select types, a list of options. |
}
```
where: Each `option` is an `object` containing a single key:value pair where the key is the option name, and the value is the option value.
- name = defines the parameter name (this is sent as HTTP param or key towards algo)
- type = defines the form type (text, number, select, boolean)
- label = defines the label which is displayed
- required = if this field is mandatory to have a consumer input.
- default = default value
- description = description of this element
- options = for select types, a list of options
Example: Example:
```json ```json
[ [
{ {
"name":"hometown", "name": "hometown",
"type": "text", "type": "text",
"label": "Hometown", "label": "Hometown",
"required": true, "required": true,
"default": "Nowhere" "description": "What is your hometown?",
"description":"What is your hometown?" "default": "Nowhere"
}, },
{ {
"name":"age", "name":"age",
"type": "number", "type": "number",
"label": "Age", "label": "Age",
"required": false, "required": false,
"default": 0 "description":"Please fill your age",
"description":"Please fill your age" "default": 0
}, },
{ {
"name":"developer", "name":"developer",
"type": "boolean", "type": "boolean",
"label": "Developer", "label": "Developer",
"required": false, "required": false,
"default": false "description":"Are you a developer?",
"description":"Are you a developer?" "default": false
}, },
{ {
"name":"preference", "name":"languagePreference",
"type": "select", "type": "select",
"label": "Date", "label": "Language",
"required": false, "required": false,
"default": "nodejs" "description": "Do you like NodeJs or Python",
"options": [ "default": "nodejs",
{ "options": [
"nodejs" : "I love NodeJs" {
}, "nodejs" : "I love NodeJs"
{ },
"python" : "I love Python" {
} "python" : "I love Python"
], }
"description": "Do you like NodeJs or Python" ]
}, }
] ]
``` ```
@ -527,10 +516,10 @@ Algorithms will have access to a JSON file located at /data/inputs/algoCustomDat
```json ```json
{ {
"surname": "John", "hometown": "São Paulo",
"age": 10, "age": 10,
"developer": false, "developer": true,
"preference": "nodejs" "languagePreference": "nodejs"
} }
``` ```