validate_chart_code
Verify chart code accuracy and PyCafe link functionality. Input chart configuration and dataset metadata to ensure compliance with Python and Plotly standards, optionally opening the PyCafe link in a browser.
Instructions
Validate the chart code created by the user and optionally open the PyCafe link in a browser.
Args:
config: A ChartPlan object with the chart configuration
data_info: Metadata for the dataset to be used in the chart
auto_open: Whether to automatically open the PyCafe link in a browser
Returns:
ValidationResults object with status and dashboard details
Input Schema
Name | Required | Description | Default |
---|---|---|---|
auto_open | No | ||
config | Yes | ||
data_info | Yes |
Input Schema (JSON Schema)
{
"$defs": {
"ChartPlan": {
"description": "Base chart plan used to generate chart code based on user visualization requirements.",
"properties": {
"chart_code": {
"description": "\n Python code that generates a generates a plotly go.Figure object. It must fulfill the following criteria:\n 1. Must be wrapped in a function name\n 2. Must accept a single argument `data_frame` which is a pandas DataFrame\n 3. Must return a plotly go.Figure object\n 4. All data used in the chart must be derived from the data_frame argument, all data manipulations\n must be done within the function.\n ",
"title": "Chart Code",
"type": "string"
},
"chart_type": {
"description": "\n Describes the chart type that best reflects the user request.\n ",
"title": "Chart Type",
"type": "string"
},
"imports": {
"description": "\n List of import statements required to render the chart defined by the `chart_code` field. Ensure that every\n import statement is a separate list/array entry: An example of valid list of import statements would be:\n\n [\"import pandas as pd\",\n \"import plotly.express as px\"]\n ",
"items": {
"type": "string"
},
"title": "Imports",
"type": "array"
}
},
"required": [
"chart_type",
"imports",
"chart_code"
],
"title": "ChartPlan",
"type": "object"
},
"DFMetaData": {
"properties": {
"column_names_types": {
"anyOf": [
{
"additionalProperties": {
"type": "string"
},
"type": "object"
},
{
"type": "null"
}
],
"default": null,
"title": "Column Names Types"
},
"file_location_type": {
"enum": [
"local",
"remote"
],
"title": "File Location Type",
"type": "string"
},
"file_name": {
"title": "File Name",
"type": "string"
},
"file_path_or_url": {
"title": "File Path Or Url",
"type": "string"
},
"read_function_string": {
"enum": [
"pd.read_csv",
"pd.read_json",
"pd.read_html",
"pd.read_parquet",
"pd.read_excel"
],
"title": "Read Function String",
"type": "string"
}
},
"required": [
"file_name",
"file_path_or_url",
"file_location_type",
"read_function_string"
],
"title": "DFMetaData",
"type": "object"
}
},
"properties": {
"auto_open": {
"default": true,
"title": "Auto Open",
"type": "boolean"
},
"config": {
"$ref": "#/$defs/ChartPlan"
},
"data_info": {
"$ref": "#/$defs/DFMetaData"
}
},
"required": [
"config",
"data_info"
],
"title": "validate_chart_codeArguments",
"type": "object"
}