Skip to content

Commit 95cc7ef

Browse files
committed
converted on for tuning
1 parent ff18443 commit 95cc7ef

File tree

1 file changed

+116
-94
lines changed

1 file changed

+116
-94
lines changed

services/web/server/src/simcore_service_webserver/exporter/_formatter/xlsx/code_description.py

Lines changed: 116 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from abc import abstractmethod
2-
from typing import Any, ClassVar, Final, cast
2+
from typing import Annotated, Any, ClassVar, Final, cast
33

4+
from common_library.basic_types import DEFAULT_FACTORY
45
from models_library.services import ServiceKey, ServiceVersion
56
from pydantic import BaseModel, Field, StrictStr
67

@@ -10,20 +11,23 @@
1011

1112

1213
class RRIDEntry(BaseModel):
13-
rrid_term: StrictStr = Field(..., description="Associated tools or resources used")
14-
rrid_identifier: StrictStr = Field(
15-
..., description="Associated tools or resources identifier (with 'RRID:')"
16-
)
14+
rrid_term: Annotated[
15+
StrictStr, Field(description="Associated tools or resources used")
16+
]
17+
rrid_identifier: Annotated[
18+
StrictStr,
19+
Field(description="Associated tools or resources identifier (with 'RRID:')"),
20+
]
1721
# the 2 items below are not enabled for now
18-
ontological_term: StrictStr = Field(
19-
"", description="Associated ontological term (human-readable)"
20-
)
21-
ontological_identifier: StrictStr = Field(
22-
"",
23-
description=(
24-
"Associated ontological identifier from SciCrunch https://scicrunch.org/sawg"
22+
ontological_term: Annotated[
23+
StrictStr, Field(description="Associated ontological term (human-readable)")
24+
] = ""
25+
ontological_identifier: Annotated[
26+
StrictStr,
27+
Field(
28+
description="Associated ontological identifier from SciCrunch https://scicrunch.org/sawg"
2529
),
26-
)
30+
] = ""
2731

2832

2933
class TSREntry(BaseModel):
@@ -33,99 +37,117 @@ class TSREntry(BaseModel):
3337

3438

3539
class CodeDescriptionModel(BaseModel):
36-
rrid_entires: list[RRIDEntry] = Field(
37-
default_factory=list, description="composed from the classifiers"
38-
)
40+
rrid_entires: Annotated[
41+
list[RRIDEntry],
42+
Field(default_factory=list, description="composed from the classifiers"),
43+
] = DEFAULT_FACTORY
3944

4045
# TSR
41-
tsr_entries: dict[str, TSREntry] = Field(
42-
default_factory=dict, description="list of rules to generate tsr"
43-
)
46+
tsr_entries: Annotated[
47+
dict[str, TSREntry],
48+
Field(default_factory=dict, description="list of rules to generate tsr"),
49+
] = DEFAULT_FACTORY
4450

4551

4652
class InputsEntryModel(BaseModel):
47-
service_alias: StrictStr = Field(
48-
..., description="Name of the service containing this input, given by the user"
49-
)
50-
service_name: StrictStr = Field(
51-
..., description="Name of the service containing this input"
52-
)
53-
service_key: ServiceKey = Field(
54-
..., description="Key of the service containing this input"
55-
)
56-
service_version: ServiceVersion = Field(
57-
..., description="Version of the service containing this input"
58-
)
59-
input_name: StrictStr = Field(
60-
"", description="An input field to the MSoP submission"
61-
)
62-
input_parameter_description: StrictStr = Field(
63-
"", description="Description of what the parameter represents"
64-
)
65-
input_data_type: StrictStr = Field(
66-
"", description="Data type for the input field (in plain text)"
67-
)
68-
input_data_units: StrictStr = Field(
69-
"", description="Units of data for the input field, if applicable"
70-
)
71-
input_data_default_value: StrictStr = Field(
72-
"",
73-
description="Default value for the input field, if applicable (doi or value)",
74-
)
75-
input_data_constraints: StrictStr = Field(
76-
"",
77-
description="Range [min, max] of acceptable parameter values, or other constraints as formulas / sets",
78-
)
53+
service_alias: Annotated[
54+
StrictStr,
55+
Field(
56+
description="Name of the service containing this input, given by the user"
57+
),
58+
]
59+
service_name: Annotated[
60+
StrictStr, Field(description="Name of the service containing this input")
61+
]
62+
service_key: Annotated[
63+
ServiceKey, Field(description="Key of the service containing this input")
64+
]
65+
service_version: Annotated[
66+
ServiceVersion,
67+
Field(description="Version of the service containing this input"),
68+
]
69+
input_name: Annotated[
70+
StrictStr, Field(description="An input field to the MSoP submission")
71+
] = ""
72+
input_parameter_description: Annotated[
73+
StrictStr, Field(description="Description of what the parameter represents")
74+
] = ""
75+
input_data_type: Annotated[
76+
StrictStr, Field(description="Data type for the input field (in plain text)")
77+
] = ""
78+
input_data_units: Annotated[
79+
StrictStr, Field(description="Units of data for the input field, if applicable")
80+
] = ""
81+
input_data_default_value: Annotated[
82+
StrictStr,
83+
Field(
84+
description="Default value for the input field, if applicable (doi or value)"
85+
),
86+
] = ""
87+
input_data_constraints: Annotated[
88+
StrictStr,
89+
Field(
90+
description="Range [min, max] of acceptable parameter values, or other constraints as formulas / sets"
91+
),
92+
] = ""
7993

8094

8195
class OutputsEntryModel(BaseModel):
82-
service_alias: StrictStr = Field(
83-
..., description="Name of the service producing this output, given by the user"
84-
)
85-
service_name: StrictStr = Field(
86-
..., description="Name of the service containing this output"
87-
)
88-
service_key: ServiceKey = Field(
89-
..., description="Key of the service containing this output"
90-
)
91-
service_version: ServiceVersion = Field(
92-
..., description="Version of the service containing this output"
93-
)
94-
output_name: StrictStr = Field(
95-
"", description="An output field to the MSoP submission"
96-
)
97-
output_parameter_description: StrictStr = Field(
98-
"", description="Description of what the parameter represents"
99-
)
100-
output_data_ontology_identifier: StrictStr = Field(
101-
"",
102-
description=(
103-
"Ontology identifier for the input field, if applicable , "
104-
"https://scicrunch.org/scicrunch/interlex/search?q=NLXOEN&l=NLXOEN&types=term"
96+
service_alias: Annotated[
97+
StrictStr,
98+
Field(
99+
description="Name of the service producing this output, given by the user"
105100
),
106-
)
107-
output_data_type: StrictStr = Field(
108-
"", description="Data type for the output field"
109-
)
110-
output_data_units: StrictStr = Field(
111-
"", description="Units of data for the output field, if applicable"
112-
)
113-
output_data_constraints: StrictStr = Field(
114-
"",
115-
description="Range [min, max] of acceptable parameter values, or other constraints as formulas / sets",
116-
)
101+
]
102+
service_name: Annotated[
103+
StrictStr, Field(description="Name of the service containing this output")
104+
]
105+
service_key: Annotated[
106+
ServiceKey, Field(description="Key of the service containing this output")
107+
]
108+
service_version: Annotated[
109+
ServiceVersion,
110+
Field(description="Version of the service containing this output"),
111+
]
112+
output_name: Annotated[
113+
StrictStr, Field(description="An output field to the MSoP submission")
114+
] = ""
115+
output_parameter_description: Annotated[
116+
StrictStr, Field(description="Description of what the parameter represents")
117+
] = ""
118+
output_data_ontology_identifier: Annotated[
119+
StrictStr,
120+
Field(
121+
description="Ontology identifier for the input field, if applicable , https://scicrunch.org/scicrunch/interlex/search?q=NLXOEN&l=NLXOEN&types=term"
122+
),
123+
] = ""
124+
output_data_type: Annotated[
125+
StrictStr, Field(description="Data type for the output field")
126+
] = ""
127+
output_data_units: Annotated[
128+
StrictStr,
129+
Field(description="Units of data for the output field, if applicable"),
130+
] = ""
131+
output_data_constraints: Annotated[
132+
StrictStr,
133+
Field(
134+
description="Range [min, max] of acceptable parameter values, or other constraints as formulas / sets"
135+
),
136+
] = ""
117137

118138

119139
class CodeDescriptionParams(BaseModel):
120-
code_description: CodeDescriptionModel = Field(
121-
..., description="code description data"
122-
)
123-
inputs: list[InputsEntryModel] = Field(
124-
default_factory=list, description="List of inputs, if any"
125-
)
126-
outputs: list[OutputsEntryModel] = Field(
127-
default_factory=list, description="List of outputs, if any"
128-
)
140+
code_description: Annotated[
141+
CodeDescriptionModel, Field(description="code description data")
142+
]
143+
inputs: Annotated[
144+
list[InputsEntryModel],
145+
Field(default_factory=list, description="List of inputs, if any"),
146+
] = DEFAULT_FACTORY
147+
outputs: Annotated[
148+
list[OutputsEntryModel],
149+
Field(default_factory=list, description="List of outputs, if any"),
150+
] = DEFAULT_FACTORY
129151

130152

131153
def _include_ports_from_this_service(service_key: ServiceKey) -> bool:

0 commit comments

Comments
 (0)