> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pysquirrels.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ModelArgs

> Arguments for model execution functions

`ModelArgs` is the class type of the `sqrl` argument for the main function of "federate models" (i.e. data models in the `models/federates/` folder), which runs when an API request is made to a dataset that uses the federate model.

The class can be imported from the `squirrels.arguments` or `squirrels` module.

## Properties

<ResponseField name="project_path" type="str">
  Path to the Squirrels project directory.
</ResponseField>

<ResponseField name="proj_vars" type="dict[str, Any]">
  A copy of project variables as a dictionary.
</ResponseField>

<ResponseField name="env_vars" type="dict[str, str]">
  A copy of environment variables as a dictionary.
</ResponseField>

<ResponseField name="user" type="AbstractUser">
  The current authenticated user.
</ResponseField>

<ResponseField name="prms" type="dict[str, Parameter]">
  A copy of the parameters dictionary.
</ResponseField>

<ResponseField name="configurables" type="dict[str, str]">
  A copy of the configurables dictionary.
</ResponseField>

<ResponseField name="connections" type="dict[str, Any]">
  A copy of the connections dictionary.
</ResponseField>

<ResponseField name="dependencies" type="set[str]">
  The set of dependent data model names.
</ResponseField>

<ResponseField name="ctx" type="dict[str, Any]">
  A copy of the context variables dictionary.
</ResponseField>

## Methods

### set\_placeholder()

Sets a placeholder value for use in SQL queries.

```python theme={null}
def set_placeholder(self, placeholder: str, value: TextValue | Any) -> str:
```

<Expandable title="arguments" defaultOpen>
  <ResponseField name="placeholder" type="string" required>
    The name of the placeholder.
  </ResponseField>

  <ResponseField name="value" type="TextValue | Any" required>
    The value of the placeholder.
  </ResponseField>
</Expandable>

<ResponseField name="returns" type="str">An empty string (because this function is also available to call from Jinja).</ResponseField>

### param\_exists()

Checks whether a given parameter exists and contains options.

```python theme={null}
def param_exists(self, param_name: str) -> bool:
```

<Expandable title="arguments" defaultOpen>
  <ResponseField name="param_name" type="string" required>
    The name of the parameter.
  </ResponseField>
</Expandable>

<ResponseField name="returns" type="bool">True if the parameter exists and is enabled, False otherwise.</ResponseField>

### ref()

Returns the result of a dependent model as a polars LazyFrame.

```python theme={null}
def ref(self, model: str) -> polars.LazyFrame:
```

<Expandable title="arguments" defaultOpen>
  <ResponseField name="model" type="string" required>
    The model name to reference.
  </ResponseField>
</Expandable>

<ResponseField name="returns" type="polars.LazyFrame">A polars LazyFrame of the dependent model's result.</ResponseField>

### run\_external\_sql()

Runs a SQL query against an external database.

```python theme={null}
def run_external_sql(
    self, connection_name: str, sql_query: str, **kwargs
) -> polars.DataFrame:
```

<Expandable title="arguments" defaultOpen>
  <ResponseField name="connection_name" type="string" required>
    The connection name for the database.
  </ResponseField>

  <ResponseField name="sql_query" type="string" required>
    The SQL query to execute.
  </ResponseField>
</Expandable>

<ResponseField name="returns" type="polars.DataFrame">A polars DataFrame of the query result.</ResponseField>

### run\_sql\_on\_dataframes()

Uses a dictionary of dataframes to execute a SQL query in an embedded DuckDB database.

```python theme={null}
def run_sql_on_dataframes(
    self, sql_query: str, *, dataframes: dict[str, polars.LazyFrame] | None = None, 
    **kwargs
) -> polars.DataFrame:
```

<Expandable title="arguments" defaultOpen>
  <ResponseField name="sql_query" type="string" required>
    The SQL query to run.
  </ResponseField>

  <ResponseField name="dataframes" type="dict[str, polars.LazyFrame] | None" required>
    Dictionary of table names to LazyFrames.
  </ResponseField>
</Expandable>

<ResponseField name="returns" type="polars.DataFrame">A polars DataFrame of the query result.</ResponseField>

### is\_placeholder()

Checks whether a name is a valid placeholder.

```python theme={null}
def is_placeholder(self, placeholder: str) -> bool:
```

<Expandable title="arguments" defaultOpen>
  <ResponseField name="placeholder" type="string" required>
    The name to check.
  </ResponseField>
</Expandable>

<ResponseField name="returns" type="bool">True if the name is a valid placeholder, False otherwise.</ResponseField>

### get\_placeholder\_value()

Gets the value of a placeholder. Use with caution to avoid SQL injection.

```python theme={null}
def get_placeholder_value(self, placeholder: str) -> Any | None:
```

<Expandable title="arguments" defaultOpen>
  <ResponseField name="placeholder" type="string" required>
    The name of the placeholder.
  </ResponseField>
</Expandable>

<ResponseField name="returns" type="Any | None">The value of the placeholder or None if the placeholder does not exist.</ResponseField>
