Skip to content

Commit

Permalink
fix(model): change configuration from struct to string (#72)
Browse files Browse the repository at this point in the history
Because

- We can safely use string to replace `google.protobuf.Struct` for now, as `google.protobuf.FieldMask` just doesn’t work with `google.protobuf.Struct` at all. Another thing is that we store a JSON struct type in the database as `JSONB` and its GORM mapping is `datatypes.JSON` which is nothing but `[]byte` (i.e., a string).

This commit

- update configuration in model and model_instance from ` google.protobuf.Struct` to string
  • Loading branch information
xiaofei-du authored May 16, 2022
1 parent 2f7dfab commit 77b02ea
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 146 deletions.
4 changes: 3 additions & 1 deletion instill/connector/v1alpha/connector_definition.proto
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ message GetSourceConnectorDefinitionRequest {
type : "api.instill.tech/SourceConnectorDefinition"
},
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
field_configuration : {path_param_name : "source_connector_definition.name"}
field_configuration : {
path_param_name : "source_connector_definition.name"
}
}
];
// SourceConnectorDefinition resource view (default is DEFINITION_VIEW_BASIC)
Expand Down
12 changes: 5 additions & 7 deletions instill/model/v1alpha/model.proto
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@ message Model {
(google.api.field_behavior) = IMMUTABLE,
(google.api.resource_reference).type = "api.instill.tech/ModelDefinition"
];
// Model configuration represents the configuration JSON object that has been
// Model configuration represents the configuration JSON string that has been
// validated using the `model_spec` JSON schema of a ModelDefinition
google.protobuf.Struct configuration = 6
[ (google.api.field_behavior) = IMMUTABLE ];
string configuration = 6 [ (google.api.field_behavior) = IMMUTABLE ];
// Model visibility including public or private
Visibility visibility = 7 [ (google.api.field_behavior) = OUTPUT_ONLY ];
// Model owner
Expand Down Expand Up @@ -122,11 +121,10 @@ message ModelInstance {
(google.api.field_behavior) = OUTPUT_ONLY,
(google.api.resource_reference).type = "api.instill.tech/ModelDefinition"
];
// Model instance configuration represents the JSON configuration that has
// been validated using the `model_instance_spec` JSON schema of a
// Model instance configuration represents the configuration JSON string that
// has been validated using the `model_instance_spec` JSON schema of a
// ModelDefinition
google.protobuf.Struct configuration = 7
[ (google.api.field_behavior) = OUTPUT_ONLY ];
string configuration = 7 [ (google.api.field_behavior) = OUTPUT_ONLY ];
// Model instance create time
google.protobuf.Timestamp create_time = 8
[ (google.api.field_behavior) = OUTPUT_ONLY ];
Expand Down
Loading

0 comments on commit 77b02ea

Please sign in to comment.