feat: added visibility to parameters

This commit is contained in:
Andrey Melnikov
2020-07-30 12:52:03 -07:00
parent e99e66590a
commit fc89727b80
6 changed files with 30 additions and 5 deletions

View File

@@ -3,7 +3,7 @@
"info": { "info": {
"title": "Onepanel", "title": "Onepanel",
"description": "Onepanel API", "description": "Onepanel API",
"version": "0.12.0", "version": "0.12.0b3",
"contact": { "contact": {
"name": "Onepanel project", "name": "Onepanel project",
"url": "https://github.com/onepanelio/core" "url": "https://github.com/onepanelio/core"
@@ -3152,6 +3152,9 @@
"type": "boolean", "type": "boolean",
"format": "boolean" "format": "boolean"
}, },
"visibility": {
"type": "string"
},
"options": { "options": {
"type": "array", "type": "array",
"items": { "items": {

View File

@@ -36,7 +36,8 @@ type Parameter struct {
DisplayName string `protobuf:"bytes,4,opt,name=displayName,proto3" json:"displayName,omitempty"` DisplayName string `protobuf:"bytes,4,opt,name=displayName,proto3" json:"displayName,omitempty"`
Hint string `protobuf:"bytes,5,opt,name=hint,proto3" json:"hint,omitempty"` Hint string `protobuf:"bytes,5,opt,name=hint,proto3" json:"hint,omitempty"`
Required bool `protobuf:"varint,6,opt,name=required,proto3" json:"required,omitempty"` Required bool `protobuf:"varint,6,opt,name=required,proto3" json:"required,omitempty"`
Options []*ParameterOption `protobuf:"bytes,7,rep,name=options,proto3" json:"options,omitempty"` Visibility string `protobuf:"bytes,7,opt,name=visibility,proto3" json:"visibility,omitempty"`
Options []*ParameterOption `protobuf:"bytes,8,rep,name=options,proto3" json:"options,omitempty"`
} }
func (x *Parameter) Reset() { func (x *Parameter) Reset() {
@@ -113,6 +114,13 @@ func (x *Parameter) GetRequired() bool {
return false return false
} }
func (x *Parameter) GetVisibility() string {
if x != nil {
return x.Visibility
}
return ""
}
func (x *Parameter) GetOptions() []*ParameterOption { func (x *Parameter) GetOptions() []*ParameterOption {
if x != nil { if x != nil {
return x.Options return x.Options
@@ -179,7 +187,7 @@ var File_common_proto protoreflect.FileDescriptor
var file_common_proto_rawDesc = []byte{ var file_common_proto_rawDesc = []byte{
0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03,
0x61, 0x70, 0x69, 0x22, 0xcb, 0x01, 0x0a, 0x09, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x61, 0x70, 0x69, 0x22, 0xeb, 0x01, 0x0a, 0x09, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65,
0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02,
0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74,
@@ -189,7 +197,9 @@ var file_common_proto_rawDesc = []byte{
0x65, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x69, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x69, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52,
0x04, 0x68, 0x69, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x04, 0x68, 0x69, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65,
0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65,
0x64, 0x12, 0x2e, 0x0a, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x07, 0x20, 0x03, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x76, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x18,
0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x76, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74,
0x79, 0x12, 0x2e, 0x0a, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x08, 0x20, 0x03,
0x28, 0x0b, 0x32, 0x14, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74,
0x65, 0x72, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e,
0x73, 0x22, 0x3b, 0x0a, 0x0f, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x4f, 0x70, 0x73, 0x22, 0x3b, 0x0a, 0x0f, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x4f, 0x70,

View File

@@ -9,8 +9,9 @@ message Parameter {
string displayName = 4; string displayName = 4;
string hint = 5; string hint = 5;
bool required = 6; bool required = 6;
string visibility = 7;
repeated ParameterOption options = 7; repeated ParameterOption options = 8;
} }
message ParameterOption { message ParameterOption {

View File

@@ -16,6 +16,7 @@ type ParameterOption struct {
type Parameter struct { type Parameter struct {
Name string `json:"name" protobuf:"bytes,1,opt,name=name"` Name string `json:"name" protobuf:"bytes,1,opt,name=name"`
Value *string `json:"value,omitempty" protobuf:"bytes,2,opt,name=value"` Value *string `json:"value,omitempty" protobuf:"bytes,2,opt,name=value"`
Visibility *string `json:"visibility,omitempty"`
Type string `json:"type,omitempty" protobuf:"bytes,3,opt,name=type"` Type string `json:"type,omitempty" protobuf:"bytes,3,opt,name=type"`
DisplayName *string `json:"displayName,omitempty" protobuf:"bytes,4,opt,name=displayName"` DisplayName *string `json:"displayName,omitempty" protobuf:"bytes,4,opt,name=displayName"`
Hint *string `json:"hint,omitempty" protobuf:"bytes,5,opt,name=hint"` Hint *string `json:"hint,omitempty" protobuf:"bytes,5,opt,name=hint"`

View File

@@ -13,6 +13,7 @@ func TestParseParametersFromManifest(t *testing.T) {
value: https://github.com/onepanelio/Mask_RCNN.git value: https://github.com/onepanelio/Mask_RCNN.git
- name: dataset-path - name: dataset-path
value: datasets/test_05142020170720 value: datasets/test_05142020170720
visibility: public
- name: model-path - name: model-path
value: models/rush/cvat6-20 value: models/rush/cvat6-20
- name: extras - name: extras
@@ -44,6 +45,12 @@ func TestParseParametersFromManifest(t *testing.T) {
keyedParameters := MapParametersByName(parameters) keyedParameters := MapParametersByName(parameters)
// Make sure visibility is set
assert.Equal(t, *keyedParameters["dataset-path"].Visibility, "public")
// Make sure visibility is not set if omitted
assert.Nil(t, keyedParameters["tf-image"].Visibility)
// Make sure numbers, slashes, dashes, and letters are parsed correctly // Make sure numbers, slashes, dashes, and letters are parsed correctly
assert.Equal(t, *keyedParameters["tf-image"].Value, "tensorflow/tensorflow:1.13.1-py3") assert.Equal(t, *keyedParameters["tf-image"].Value, "tensorflow/tensorflow:1.13.1-py3")

View File

@@ -26,6 +26,9 @@ func apiWorkflowTemplate(wft *v1.WorkflowTemplate) *api.WorkflowTemplate {
if p.Value != nil { if p.Value != nil {
ap.Value = *p.Value ap.Value = *p.Value
} }
if p.Visibility != nil {
ap.Visibility = *p.Visibility
}
aParams = append(aParams, &ap) aParams = append(aParams, &ap)
} }