@@ -51,7 +51,139 @@ can send a ``POST`` request to the server with the following URL:
5151
5252 http://app-server:5000? labels=PERSON& labels=ORG
5353
54- Note that for this example to work, the parameter must be specified as
54+ Note that for this example to work, the parameter must be specified as
5555``multivalued=True `` in the app metadata, so that the SDK can collect multiple
5656values for the same parameter name in a single python list and pass to the
57- ``annotate() `` method. Otherwise, only the *first * value will be passed.
57+ ``annotate() `` method. Otherwise, only the *first * value will be passed.
58+
59+ .. _runtime-params-detailed :
60+
61+ Parameter Types
62+ ---------------
63+
64+ Each runtime parameter has a ``type `` that determines how user-provided string
65+ values are cast into Python objects before reaching your ``_annotate() `` method.
66+ The supported types are: ``string ``, ``integer ``, ``number ``, ``boolean ``, and
67+ ``map ``.
68+
69+ Primitive types
70+ ^^^^^^^^^^^^^^^
71+
72+ ``string ``
73+ Values are passed through as-is (no casting).
74+
75+ .. code-block :: python
76+
77+ metadata.add_parameter(name = ' outputFormat' , type = ' string' ,
78+ default = ' json' ,
79+ description = ' Output format.' )
80+
81+ ``integer ``
82+ Values are cast to Python ``int `` via ``int(value) ``.
83+
84+ .. code-block :: python
85+
86+ metadata.add_parameter(name = ' minFrameCount' , type = ' integer' ,
87+ default = 5 ,
88+ description = ' Minimum number of frames.' )
89+
90+ ``number ``
91+ Values are cast to Python ``float `` via ``float(value) ``.
92+
93+ .. code-block :: python
94+
95+ metadata.add_parameter(name = ' threshold' , type = ' number' ,
96+ default = 0.5 ,
97+ description = ' Confidence threshold.' )
98+
99+ ``boolean ``
100+ Values are cast to Python ``bool ``. The following string values are
101+ recognized as ``False ``: ``False ``, ``false ``, ``F ``, ``f ``, ``0 ``.
102+ Everything else is treated as ``True ``. Boolean parameters always have
103+ ``multivalued=False `` (enforced by the SDK).
104+
105+ .. code-block :: python
106+
107+ metadata.add_parameter(name = ' pretty' , type = ' boolean' ,
108+ default = False ,
109+ description = ' Pretty-print JSON output.' )
110+
111+ Multivalued parameters
112+ ^^^^^^^^^^^^^^^^^^^^^^
113+
114+ When a parameter can accept more than one value, set ``multivalued=True ``.
115+ The SDK will always pass a **list ** to ``_annotate() ``, even when the user
116+ provides only a single value.
117+
118+ .. code-block :: python
119+
120+ metadata.add_parameter(name = ' labels' , type = ' string' ,
121+ multivalued = True ,
122+ default = [' PERSON' , ' ORG' ],
123+ description = ' Annotation labels to use.' )
124+
125+ To pass multiple values:
126+
127+ - via query string: repeat the parameter name
128+
129+ .. code-block :: bash
130+
131+ http://app-server:5000? labels=PERSON& labels=ORG
132+
133+ - via CLI: list values after the flag
134+
135+ .. code-block :: bash
136+
137+ python cli.py --labels PERSON ORG
138+
139+ .. note ::
140+
141+ ``boolean `` parameters always force ``multivalued=False ``.
142+
143+ Map type parameters
144+ ^^^^^^^^^^^^^^^^^^^
145+
146+ Map parameters allow users to pass key-value pairs that arrive in
147+ ``_annotate() `` as a Python ``dict ``. Declaring ``type='map' `` automatically
148+ forces ``multivalued=True ``.
149+
150+ .. code-block :: python
151+
152+ metadata.add_parameter(name = ' labelMap' , type = ' map' ,
153+ default = [' B:bars' , ' S:slate' ],
154+ description = ' Mapping from source to target labels.' )
155+
156+ Each value uses a colon (``: ``) as the key-value delimiter::
157+
158+ KEY:VALUE
159+
160+ **Colons are not allowed in keys. ** The first colon in the string is always used
161+ as the delimiter. If colons appear in the value portion (after the first colon),
162+ the SDK will emit a warning. When the same key is passed more than once, the
163+ last value wins.
164+
165+ To pass map values:
166+
167+ - via query string: repeat the parameter name with each ``KEY:VALUE `` pair
168+
169+ .. code-block :: bash
170+
171+ http://app-server:5000? labelMap=B:bars& labelMap=S:slate
172+
173+ - via CLI: list pairs after the flag
174+
175+ .. code-block :: bash
176+
177+ python cli.py --labelMap B:bars S:slate
178+
179+ Inside ``_annotate() ``, the parameter arrives as::
180+
181+ {'B': 'bars', 'S': 'slate'}
182+
183+ Default values must be a list of colon-separated strings::
184+
185+ default=['key1:value1', 'key2:value2']
186+
187+ For more complex value structures (e.g., comma-separated lists within values),
188+ the app developer is responsible for further parsing and should document the
189+ expected format in the parameter's ``description `` field.
0 commit comments