validate_chart_code
Validate user-created chart code for compliance with PyCafe standards, ensuring correct function structure, imports, and data usage. Optionally open the validated chart link in a browser for direct review.
Instructions
Validate the chart code created by the user and optionally open the PyCafe link in a browser.
Args:
    chart_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 | ||
| chart_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 that is named `chart_name`\n        2. Must accept as first argument 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        5. DO NOT modify the background (with plot_bgcolor) or color sequences unless explicitly asked for\n        6. When creating hover templates, explicitly ensure that it works on light and dark mode\n        ",
          "title": "Chart Code",
          "type": "string"
        },
        "chart_name": {
          "description": "\n        The name of the chart function. Should be unique, concise and in snake_case.\n        ",
          "pattern": "^[a-z][a-z0-9_]*$",
          "title": "Chart Name",
          "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",
        "chart_name",
        "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"
    },
    "chart_config": {
      "$ref": "#/$defs/ChartPlan"
    },
    "data_info": {
      "$ref": "#/$defs/DFMetaData"
    }
  },
  "required": [
    "chart_config",
    "data_info"
  ],
  "title": "validate_chart_codeArguments",
  "type": "object"
}