# Python Client

The primary interface for creating, manipulating, and executing Prism projects is the command line. However, starting with `v0.1.5-alpha`, users can also programmatically interact with Prism projects using Prism's Python client library. The core of this client is the `PrismDAG` object.

Below is the documentation for this object. Note that the arguments for each function are type-hinted.

<details>

<summary>PrismDAG(<em><mark style="color:orange;">project_dir</mark></em>: pathlib.Path, <em><mark style="color:orange;">log_level</mark></em>: str = <mark style="color:green;">"warn"</mark>)</summary>

Instantiate a Prism DAG object

Parameters:\
\- `project_dir`: Prism project directory\
\- `log_level`: one of `info`, `warn`, `error`, or `critical`

**PrismDAG.**<mark style="color:purple;">**connect**</mark>**(**<mark style="color:orange;">**connection\_type**</mark>: st&#x72;**)**

Create a connection to an adapter. This replicates the functionality of the `prism connect --type` CLI command.

Parameters:\
\- `connection_type`: Adapter type. Valid adapters are listed [here](https://docs.runprism.com/v0.2.6/cli/connect).

**PrismDAG.**<mark style="color:purple;">**compile**</mark>**(**\
&#x20;   <mark style="color:orange;">**modules**</mark>: Optional\[List\[str]] = <mark style="color:red;">None</mark><mark style="color:orange;">,</mark>\
&#x20;   <mark style="color:orange;">**all\_downstream**</mark>: bool = <mark style="color:blue;">True</mark>\
\&#xNAN;**)**

Compile the Prism project. This replicates the functionality of the `prism compile`.

Parameters:\
\- `modules`: A list of modules to compile. If this value is `None`, then all modules are compiled.\
\- `all_downstream`: Whether to compile modules downstream of those in `modules`. The default is `True`.

**PrismDAG.**<mark style="color:purple;">**run**</mark>**(**\
&#x20;   <mark style="color:orange;">**modules**</mark>: Optional\[List\[str]] = <mark style="color:red;">None</mark>,\
&#x20;   <mark style="color:orange;">**all\_upstream**</mark>: bool = <mark style="color:blue;">True</mark>,\
&#x20;   <mark style="color:orange;">**all\_downstream**</mark>: bool = <mark style="color:blue;">True</mark>,\
&#x20;   <mark style="color:orange;">**full\_tb**</mark>: bool = <mark style="color:blue;">True</mark>,\
&#x20;   <mark style="color:orange;">**user\_context**</mark>: Dict\[Any, Any] = <mark style="color:red;">None</mark>\
\&#xNAN;**)**

Run the Prism project. This replicates the functionality of the `prism run`.

Parameters:\
\- `modules`: A list of modules to compile. If this value is `None`, then all modules are compiled.\
\- `all_upstream`: Whether to compile modules upstream of those in `modules`. The default is `True`.\
\- `all_downstream`: Whether to compile modules downstream of those in `modules`. The default is `True`.\
\- `full_tb`: Display full traceback if errors arise at any stage of the pipeline. The default is `True`.\
\- `user_context`: dictionary with variables to overwrite `prism_project.py`.

**PrismDAG.**<mark style="color:purple;">**get\_task\_output**</mark>**(**\
&#x20;   <mark style="color:orange;">**module\_path**</mark>: pathlib.Path,\
&#x20;   <mark style="color:orange;">**bool\_run**</mark>: bool = <mark style="color:blue;">False</mark>,\
&#x20;   <mark style="color:orange;">**\*\*kwargs**</mark>\
\&#xNAN;**)**

Get output of the task at `module_path`. If `bool_run == True`, then run the project first. Note that if `bool_run == False`, then only tasks with a target can be parsed.

Parameters:\
\- `module_path`: path to module (relative to `modules/` folder)\
\- `bool_run`: boolean indicating whether to run project first; default is `False`\
\- `**kwargs`: keyword arguments for running

Returns:\
\- task output

**PrismDAG.**<mark style="color:purple;">**get\_pipeline\_output**</mark>**(**\
&#x20;   <mark style="color:orange;">**bool\_run**</mark>: bool = <mark style="color:blue;">False</mark>,\
\&#xNAN;**)**

Get pipeline output, defined as the output associated with the last task in the project

Parameters:\
\- `bool_run`: boolean indicating whether to run project first; default is `False`

Returns:\
\- output associated with last task in the project

</details>
