Skip to content

Commit

Permalink
fix model gen
Browse files Browse the repository at this point in the history
  • Loading branch information
goldenxinxing committed Jan 10, 2024
1 parent 37d981f commit 2891095
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
4 changes: 2 additions & 2 deletions client/starwhale/api/_impl/argument.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ def asdict(self) -> t.Dict[str, t.Any]:
r[func][dtype][option.name] = info
return r

def asobj(self) -> t.Dict[str, Arguments]:
r: t.Dict[str, Arguments] = defaultdict(lambda: defaultdict(dict))
def asobj(self) -> t.Dict[str, t.Dict[str, t.Dict[str, OptionField]]]:
r: t.Dict[str, t.Dict[str, t.Dict[str, OptionField]]] = defaultdict(lambda: defaultdict(dict))
for func, dtypes in self._func_related_dataclasses.items():
for dtype in dtypes:
for option in self._options[dtype]:
Expand Down
20 changes: 10 additions & 10 deletions client/starwhale/base/client/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,10 +768,10 @@ class FineTune(SwBaseModel):


class OptionType(SwBaseModel):
name: Optional[str] = None
name: str
choices: Optional[List[str]] = None
param_type: Optional[str] = None
case_sensitive: Optional[bool] = None
param_type: str
case_sensitive: bool = False


class ParameterSignature(SwBaseModel):
Expand Down Expand Up @@ -1388,15 +1388,15 @@ class ComponentSpec(SwBaseModel):


class OptionField(SwBaseModel):
name: Optional[str] = None
type: Optional[OptionType] = None
required: Optional[bool] = None
multiple: Optional[bool] = None
name: str
type: OptionType
required: bool = False
multiple: bool = False
value: Optional[str] = None
default: Any = None
help: Optional[str] = None
hidden: Optional[bool] = None
default: Optional[Dict[str, Any]] = None
is_flag: Optional[bool] = None
is_flag: bool = False
hidden: bool = False


class PageInfoTaskVo(SwBaseModel):
Expand Down
3 changes: 3 additions & 0 deletions client/tests/sdk/test_argument.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ def mock_f3(starwhale_argument: t.Tuple) -> None:
"help": "batch size",
"is_flag": False,
"hidden": False,
'value': None,
}

evaluation_strategy = info[
Expand All @@ -305,6 +306,7 @@ def mock_f3(starwhale_argument: t.Tuple) -> None:
"name": "choice",
"param_type": "CHOICE",
},
'value': None,
}

debug = info[
Expand All @@ -325,6 +327,7 @@ def mock_f3(starwhale_argument: t.Tuple) -> None:
"case_sensitive": False,
"choices": None,
},
'value': None,
}

assert json.loads(json.dumps(info)) == info
Original file line number Diff line number Diff line change
Expand Up @@ -111,25 +111,33 @@ public static class FineTune {
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public static class OptionType {
@NotNull
private String name;

@NotNull
@JsonProperty("param_type")
private String paramType;

private List<String> choices;

@NotNull
@JsonProperty("case_sensitive")
private boolean caseSensitive = false;
}

@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public static class OptionField {
@NotNull
private String name;
@NotNull
private OptionType type;
@NotNull
private boolean required = false;
@NotNull
private boolean multiple = false;

@NotNull
@JsonProperty("default")
private Object defaultValue;

Expand All @@ -140,9 +148,11 @@ public static class OptionField {

private String help;

@NotNull
@JsonProperty("is_flag")
private boolean isFlag = false;

@NotNull
private boolean hidden = false;
}

Expand Down

0 comments on commit 2891095

Please sign in to comment.