Skip to content

Commit

Permalink
move ganymedeexception to sdk (#430)
Browse files Browse the repository at this point in the history
* move ganymedeexception to sdk

* upd
  • Loading branch information
bensonlee5 authored Dec 1, 2024
1 parent df878f7 commit b672b54
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
5 changes: 4 additions & 1 deletion .wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -398,4 +398,7 @@ AKTA
Cytiva
searchability
SuggestedTags
Palantir
Palantir
GanymedeException
FlowView
useBaseURL
8 changes: 2 additions & 6 deletions docs/app/flows/FlowView.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Logs for each flow step can be accessed by clicking on the corresponding colored

### Error Attribution

Developers using the platform can specify error types and messages associated with failed nodes. These are displayed on the status tag in the Run History table. Below is an example code snippet that would be placed within a node to raise an error:
Developers using the platform can specify error types and messages associated with failed nodes using the GanymedeException class. These are displayed on the status tag in the Run History table. Below is an example code snippet that would be placed within a node to raise an error:

```python
from ganymede_sdk.flow_runtime import GanymedeException
Expand All @@ -128,8 +128,4 @@ from ganymede_sdk.flow_runtime import GanymedeException
raise GanymedeException(message=”Peaks not detected in results”, exception_type=”Function”)
```

#### Categories of Errors

- **Validation**: Schema validation errors. An example use case would be a Pandas DataFrame failing to validate against a Pandera schema.
- **Connection**: Errors related to connecting to external services. Check for errors related to authentication, service availability, and access methods.
- **Function**: Errors related to function logic. For example, a failed function call to a Python package would fall under this category.
More detail on error types can be found in the [GanymedeException section of the Ganymede SDK documentation](../../sdk/DataValidation#class-ganymedeexception).
19 changes: 18 additions & 1 deletion docs/sdk/DataValidation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,29 @@ query_sql = 'SELECT * FROM tbl WHERE flow_run_id = "{{flow_run_id}}";'
result = g.retrieve_sql(query_sql)
```

## `class` GanymedeException

The **GanymedeException** class is a custom exception class that can be used to raise exceptions to attribute error type.

```python
from ganymede_sdk.flow_runtime import GanymedeException

# available exception types are: Validation, Connection, Function
raise GanymedeException('Only 1 replicate detected in sample; expected 3.', exception_type="Validation")
```

### Error Types

- **Validation**: Schema validation errors. An example use case would be a Pandas DataFrame failing to validate against a Pandera schema.
- **Connection**: Errors related to connecting to external services. Check for errors related to authentication, service availability, and access methods.
- **Function**: Errors related to function logic. For example, a failed function call to a Python package would fall under this category.

## `function` compare_df_to_table

*compare_df_to_table* allows users to compare the columns and schema on a Pandas DataFrame to a corresponding table in the Ganymede database.
The function returns differences in column names and data types between the DataFrame and the table, and can be used to validate that the DataFrame matches the table schema before writing the DataFrame to the table.

### Parameters
### Parameters
- **ganymede_context** : `GanymedeContext`
- Ganymede context to get run attributes
- **df** : `pd.DataFrame`
Expand Down

0 comments on commit b672b54

Please sign in to comment.