Skip to content
This repository has been archived by the owner on Jan 9, 2025. It is now read-only.

Commit

Permalink
feat: use camelCase in JSON files (#158)
Browse files Browse the repository at this point in the history
Because:

- Currently, our JSON files are a mix of camelCase, snake_case, and
kebab-case, which is not consistent.

This commit:

- Uses camelCase in JSON files.
- Simplify `ComponentConfig` struct since most of the fields are not
used in the component package.

Note:

- We don't change the JSON keys of `properties` in this PR. We'll use
kebab-case for them and address this in another PR.
  • Loading branch information
donch1989 authored Jun 14, 2024
1 parent bca54ee commit ecf4dd9
Show file tree
Hide file tree
Showing 31 changed files with 160 additions and 162 deletions.
18 changes: 9 additions & 9 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,21 +275,21 @@ component.

```json
{
"available_tasks": [
"availableTasks": [
"TASK_GREET"
],
"custom": false,
"documentation_url": "https://www.instill.tech/docs/component/operator/hello",
"documentationUrl": "https://www.instill.tech/docs/component/operator/hello",
"icon": "assets/hello.svg",
"id": "hello",
"public": true,
"spec": {},
"title": "Hello",
"uid": "e05d3d71-779c-45f8-904d-e90a050ca3b2",
"version": "0.1.0",
"source_url": "https://github.com/instill-ai/component/blob/main/operator/hello/v0",
"sourceUrl": "https://github.com/instill-ai/component/blob/main/operator/hello/v0",
"description": "'Hello, world' operator used as a template for adding components",
"release_stage": "RELEASE_STAGE_ALPHA"
"releaseStage": "RELEASE_STAGE_ALPHA"
}
```

Expand All @@ -304,21 +304,21 @@ This file defines the component properties:
- **`spec`** contains the parameters required to configure the component and
that are independent from its tasks. E.g., the API token of a vendor. In
general, only AI, data or application components need such parameters.
- **`available_tasks`** defines the tasks the component can perform.
- **`availableTasks`** defines the tasks the component can perform.
- When a component is created in a pipeline, one of the tasks has to be
selected, i.e., a configured component can only execute one task.
- Task configurations are defined in `tasks.json`.
- **`documentation_url`** points to the official documentation of the component.
- **`documentationUrl`** points to the official documentation of the component.
- **`icon`** is the local path to the icon that will be displayed in the Console
when creating the component. If left blank, a placeholder icon will be shown.
- **`version`** must be a [SemVer](https://semver.org/) string. It is encouraged
to keep a [tidy version history](#sane-version-control).
- **`source_url`** points to the codebase that implements the component. This
- **`sourceUrl`** points to the codebase that implements the component. This
will be used by the documentation generation tool and also will be part of the
[component definition
list](https://openapi.instill.tech/reference/pipelinepublicservice_listcomponentdefinitions)
endpoint.
- **`release_stage`** describes the release stage of the component.
- **`releaseStage`** describes the release stage of the component.
Unimplemented stages (`RELEASE_STAGE_COMING_SOON` or
`RELEASE_STAGE_OPEN_FOR_CONTRIBUTION`) will hide the component from the
console (i.e. they can't be used in pipelines) but they will appear in the
Expand Down Expand Up @@ -771,7 +771,7 @@ Semantic Versioning guidelines.
It is recommended to start a component at `v0.1.0`. A major version 0 is
intended for rapid development.

The `release_stage` property in `definition.json` indicates the stability of a
The `releaseStage` property in `definition.json` indicates the stability of a
component.

- A component skeleton (with only the minimal configuration files and a dummy
Expand Down
12 changes: 6 additions & 6 deletions ai/archetypeai/v0/config/definition.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"available_tasks": [
"availableTasks": [
"TASK_DESCRIBE",
"TASK_SUMMARIZE",
"TASK_UPLOAD_FILE"
],
"custom": false,
"documentation_url": "https://www.instill.tech/docs/component/ai/archetypeai",
"documentationUrl": "https://www.instill.tech/docs/component/ai/archetypeai",
"icon": "assets/archetype-ai.svg",
"icon_url": "",
"iconUrl": "",
"id": "archetype-ai",
"public": true,
"title": "Archetype AI",
Expand All @@ -16,8 +16,8 @@
"type": "COMPONENT_TYPE_AI",
"uid": "e414a1f8-5fdf-4292-b050-9f9176254a4b",
"vendor": "Archetype AI",
"vendor_attributes": {},
"vendorAttributes": {},
"version": "0.1.0",
"source_url": "https://github.com/instill-ai/component/blob/main/ai/archetypeai/v0",
"release_stage": "RELEASE_STAGE_ALPHA"
"sourceUrl": "https://github.com/instill-ai/component/blob/main/ai/archetypeai/v0",
"releaseStage": "RELEASE_STAGE_ALPHA"
}
12 changes: 6 additions & 6 deletions ai/huggingface/v0/config/definition.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"available_tasks": [
"availableTasks": [
"TASK_TEXT_GENERATION",
"TASK_FILL_MASK",
"TASK_SUMMARIZATION",
Expand All @@ -19,9 +19,9 @@
"TASK_AUDIO_CLASSIFICATION"
],
"custom": false,
"documentation_url": "https://www.instill.tech/docs/component/ai/huggingface",
"documentationUrl": "https://www.instill.tech/docs/component/ai/huggingface",
"icon": "assets/hugging-face.svg",
"icon_url": "",
"iconUrl": "",
"id": "hugging-face",
"public": true,
"title": "Hugging Face",
Expand All @@ -30,8 +30,8 @@
"type": "COMPONENT_TYPE_AI",
"uid": "0255ef87-33ce-4f88-b9db-8897f8c17233",
"vendor": "Hugging Face",
"vendor_attributes": {},
"vendorAttributes": {},
"version": "0.1.1",
"source_url": "https://github.com/instill-ai/component/blob/main/ai/huggingface/v0",
"release_stage": "RELEASE_STAGE_ALPHA"
"sourceUrl": "https://github.com/instill-ai/component/blob/main/ai/huggingface/v0",
"releaseStage": "RELEASE_STAGE_ALPHA"
}
12 changes: 6 additions & 6 deletions ai/instill/v0/config/definition.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"available_tasks": [
"availableTasks": [
"TASK_CLASSIFICATION",
"TASK_INSTANCE_SEGMENTATION",
"TASK_KEYPOINT",
Expand All @@ -13,9 +13,9 @@
"TASK_IMAGE_TO_IMAGE"
],
"custom": false,
"documentation_url": "https://www.instill.tech/docs/component/ai/instill",
"documentationUrl": "https://www.instill.tech/docs/component/ai/instill",
"icon": "assets/instill-model.svg",
"icon_url": "",
"iconUrl": "",
"id": "instill-model",
"public": true,
"title": "Instill Model",
Expand All @@ -24,8 +24,8 @@
"type": "COMPONENT_TYPE_AI",
"uid": "ddcf42c3-4c30-4c65-9585-25f1c89b2b48",
"vendor": "Instill",
"vendor_attributes": {},
"vendorAttributes": {},
"version": "0.1.0",
"source_url": "https://github.com/instill-ai/component/blob/main/ai/instill/v0",
"release_stage": "RELEASE_STAGE_ALPHA"
"sourceUrl": "https://github.com/instill-ai/component/blob/main/ai/instill/v0",
"releaseStage": "RELEASE_STAGE_ALPHA"
}
10 changes: 5 additions & 5 deletions ai/openai/v0/config/definition.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"available_tasks": [
"availableTasks": [
"TASK_TEXT_GENERATION",
"TASK_TEXT_EMBEDDINGS",
"TASK_SPEECH_RECOGNITION",
Expand All @@ -9,16 +9,16 @@
"custom": false,
"documentation_url": "https://www.instill.tech/docs/component/ai/openai",
"icon": "assets/openai.svg",
"icon_url": "",
"iconUrl": "",
"id": "openai",
"public": true,
"title": "OpenAI",
"description": "Connect the AI models served on the OpenAI Platform",
"type": "COMPONENT_TYPE_AI",
"uid": "9fb6a2cb-bff5-4c69-bc6d-4538dd8e3362",
"vendor": "OpenAI",
"vendor_attributes": {},
"vendorAttributes": {},
"version": "0.1.1",
"source_url": "https://github.com/instill-ai/component/blob/main/ai/openai/v0",
"release_stage": "RELEASE_STAGE_ALPHA"
"sourceUrl": "https://github.com/instill-ai/component/blob/main/ai/openai/v0",
"releaseStage": "RELEASE_STAGE_ALPHA"
}
12 changes: 6 additions & 6 deletions ai/stabilityai/v0/config/definition.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"available_tasks": [
"availableTasks": [
"TASK_TEXT_TO_IMAGE",
"TASK_IMAGE_TO_IMAGE"
],
"custom": false,
"documentation_url": "https://www.instill.tech/docs/component/ai/stabilityai",
"documentationUrl": "https://www.instill.tech/docs/component/ai/stabilityai",
"icon": "assets/stability-ai.svg",
"icon_url": "",
"iconUrl": "",
"id": "stability-ai",
"public": true,
"title": "Stability AI",
Expand All @@ -15,8 +15,8 @@
"type": "COMPONENT_TYPE_AI",
"uid": "c86a95cc-7d32-4e22-a290-8c699f6705a4",
"vendor": "Stability AI",
"vendor_attributes": {},
"vendorAttributes": {},
"version": "0.1.0",
"source_url": "https://github.com/instill-ai/component/blob/main/ai/stabilityai/v0",
"release_stage": "RELEASE_STAGE_ALPHA"
"sourceUrl": "https://github.com/instill-ai/component/blob/main/ai/stabilityai/v0",
"releaseStage": "RELEASE_STAGE_ALPHA"
}
12 changes: 6 additions & 6 deletions application/googlesearch/v0/config/definition.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"available_tasks": [
"availableTasks": [
"TASK_SEARCH"
],
"custom": false,
"documentation_url": "https://www.instill.tech/docs/component/application/googlesearch",
"documentationUrl": "https://www.instill.tech/docs/component/application/googlesearch",
"icon": "assets/google-search.svg",
"icon_url": "",
"iconUrl": "",
"id": "google-search",
"public": true,
"title": "Google Search",
Expand All @@ -14,8 +14,8 @@
"type": "COMPONENT_TYPE_APPLICATION",
"uid": "2b1da686-878a-462c-b2c6-a9690199939c",
"vendor": "Google",
"vendor_attributes": {},
"vendorAttributes": {},
"version": "0.1.1",
"source_url": "https://github.com/instill-ai/component/blob/main/application/googlesearch/v0",
"release_stage": "RELEASE_STAGE_ALPHA"
"sourceUrl": "https://github.com/instill-ai/component/blob/main/application/googlesearch/v0",
"releaseStage": "RELEASE_STAGE_ALPHA"
}
12 changes: 6 additions & 6 deletions application/numbers/v0/config/definition.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"available_tasks": [
"availableTasks": [
"TASK_REGISTER"
],
"custom": false,
"documentation_url": "https://www.instill.tech/docs/component/application/numbers",
"documentationUrl": "https://www.instill.tech/docs/component/application/numbers",
"icon": "assets/numbers.svg",
"icon_url": "",
"iconUrl": "",
"id": "numbers",
"public": true,
"title": "Numbers Protocol",
Expand All @@ -14,8 +14,8 @@
"type": "COMPONENT_TYPE_APPLICATION",
"uid": "70d8664a-d512-4517-a5e8-5d4da81756a7",
"vendor": "Numbers Protocol",
"vendor_attributes": {},
"vendorAttributes": {},
"version": "0.1.0",
"source_url": "https://github.com/instill-ai/component/blob/main/application/numbers/v0",
"release_stage": "RELEASE_STAGE_ALPHA"
"sourceUrl": "https://github.com/instill-ai/component/blob/main/application/numbers/v0",
"releaseStage": "RELEASE_STAGE_ALPHA"
}
12 changes: 6 additions & 6 deletions application/restapi/v0/config/definition.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"available_tasks": [
"availableTasks": [
"TASK_GET",
"TASK_POST",
"TASK_PATCH",
Expand All @@ -9,9 +9,9 @@
"TASK_OPTIONS"
],
"custom": false,
"documentation_url": "https://www.instill.tech/docs/component/application/restapi",
"documentationUrl": "https://www.instill.tech/docs/component/application/restapi",
"icon": "assets/restapi.svg",
"icon_url": "",
"iconUrl": "",
"id": "restapi",
"public": true,
"title": "REST API",
Expand All @@ -20,8 +20,8 @@
"type": "COMPONENT_TYPE_APPLICATION",
"uid": "5ee55a5c-6e30-4c7a-80e8-90165a729e0a",
"vendor": "",
"vendor_attributes": {},
"vendorAttributes": {},
"version": "0.1.1",
"source_url": "https://github.com/instill-ai/component/blob/main/application/restapi/v0",
"release_stage": "RELEASE_STAGE_ALPHA"
"sourceUrl": "https://github.com/instill-ai/component/blob/main/application/restapi/v0",
"releaseStage": "RELEASE_STAGE_ALPHA"
}
12 changes: 6 additions & 6 deletions application/slack/v0/config/definition.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"available_tasks": [
"availableTasks": [
"TASK_READ_MESSAGE",
"TASK_WRITE_MESSAGE"
],
"custom": false,
"documentation_url": "https://www.instill.tech/docs/component/application/slack",
"documentationUrl": "https://www.instill.tech/docs/component/application/slack",
"icon": "assets/slack.svg",
"icon_url": "",
"iconUrl": "",
"id": "slack",
"public": true,
"title": "Slack",
Expand All @@ -15,8 +15,8 @@
"type": "COMPONENT_TYPE_APPLICATION",
"uid": "1e9f469e-da5e-46eb-8a89-23466627e3b5",
"vendor": "Slack",
"vendor_attributes": {},
"vendorAttributes": {},
"version": "0.1.0",
"source_url": "https://github.com/instill-ai/component/blob/main/application/slack/v0",
"release_stage": "RELEASE_STAGE_ALPHA"
"sourceUrl": "https://github.com/instill-ai/component/blob/main/application/slack/v0",
"releaseStage": "RELEASE_STAGE_ALPHA"
}
12 changes: 6 additions & 6 deletions application/website/v0/config/definition.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"available_tasks": [
"availableTasks": [
"TASK_SCRAPE_WEBSITE"
],
"custom": false,
"documentation_url": "https://www.instill.tech/docs/component/application/website",
"documentationUrl": "https://www.instill.tech/docs/component/application/website",
"icon": "assets/website.svg",
"icon_url": "",
"iconUrl": "",
"id": "website",
"public": true,
"title": "Website",
"description": "Scrape websites",
"type": "COMPONENT_TYPE_APPLICATION",
"uid": "98909958-db7d-4dfe-9858-7761904be17e",
"vendor": "",
"vendor_attributes": {},
"vendorAttributes": {},
"version": "0.1.1",
"source_url": "https://github.com/instill-ai/component/blob/main/application/website/v0",
"release_stage": "RELEASE_STAGE_ALPHA"
"sourceUrl": "https://github.com/instill-ai/component/blob/main/application/website/v0",
"releaseStage": "RELEASE_STAGE_ALPHA"
}
18 changes: 4 additions & 14 deletions base/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ func (c *Component) LoadDefinition(definitionJSONBytes, setupJSONBytes, tasksJSO
}

availableTasks := []string{}
for _, availableTask := range definitionJSON.(map[string]interface{})["available_tasks"].([]interface{}) {
for _, availableTask := range definitionJSON.(map[string]interface{})["availableTasks"].([]interface{}) {
availableTasks = append(availableTasks, availableTask.(string))
}

Expand Down Expand Up @@ -831,17 +831,7 @@ func ReadFromSecrets(key string, secrets map[string]any) string {
}

type ComponentConfig struct {
Type string `json:"type,omitempty"`
Task string `json:"task,omitempty"`
Input map[string]any `json:"input,omitempty"`
Condition *string `json:"condition,omitempty"`
Setup map[string]any `json:"setup,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
Definition *pb.ComponentDefinition `json:"definition,omitempty"`
}

func (c *ComponentConfig) IsComponent() {}

func (c *ComponentConfig) GetCondition() *string {
return c.Condition
Task string
Input map[string]any
Setup map[string]any
}
Loading

0 comments on commit ecf4dd9

Please sign in to comment.