civis.utils.run_template
- civis.utils.run_template(id: int, arguments: dict, JSONValue=DEPRECATED, client: APIClient | None = None, return_as: str = 'files', **kwargs) CivisFuture | dict | None[source]
Run a template and return the results.
- Parameters:
- id: int
The template id to be run.
- arguments: dict
Dictionary of arguments to be passed to the template.
- JSONValue: bool, optional
If True, will return the JSON output of the template. If False, will return the file ids associated with the output results.
Deprecated since version 2.8.0:
JSONValuewill be removed at civis-python v3.0.0. Please usereturn_asinstead.- return_as: str, optional
Determines the return type. Options: - “files”: returns file ids associated with output results (default for <v3.0.0) - “JSONValue”: returns the JSON output of the template - “future”: returns the CivisFuture object for the run At civis-python v3.0.0, the default will change to “future”.
- client: :class:`civis.APIClient`, optional
If not provided, an
civis.APIClientobject will be created from theCIVIS_API_KEY.- **kwargs: dict
Additional keyword arguments to be passed to post_custom.
- Returns:
- output: dict or CivisFuture
If return_as = “files”, dictionary of file ids with the keys being their output names. If return_as = “JSONValue”, JSON dict containing the results of the template run. Expects only a single JSON result. Will return nothing if either there is no JSON result or there is more than 1 JSON result. If return_as = “future”, returns the CivisFuture object for the run.
Examples
>>> # Run template to return file_ids >>> run_template(my_template_id, arguments=my_dict_of_args) {'output': 1234567} >>> # Run template to return JSON output >>> run_template(my_template_id, arguments=my_dict_of_args, return_as="JSONValue") {'result1': 'aaa', 'result2': 123} >>> # Run template to return CivisFuture >>> run_template(my_template_id, arguments=my_dict_of_args, return_as="future") <CivisFuture object> >>> # Run template with kwargs >>> run_template(my_template_id, arguments=my_dict_of_args, remote_host_id=1, credential_id=2) {'output': 1234567}