Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Transform data and create rich visualizations iteratively with AI 🪄. Try Data
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/microsoft/data-formulator?quickstart=1)

<kbd>
<a target="_blank" rel="noopener noreferrer" href="https://codespaces.new/microsoft/data-formulator?quickstart=1" title="open Data Formulator in GitHub Codespaces"><img src="public/data-formulator-screenshot.png"></a>
<a target="_blank" rel="noopener noreferrer" href="https://codespaces.new/microsoft/data-formulator?quickstart=1" title="open Data Formulator in GitHub Codespaces"><img src="https://github.com/microsoft/data-formulator/blob/main/public/data-formulator-screenshot.png?raw=true"></a>
</kbd>


Expand Down
2 changes: 1 addition & 1 deletion local_server.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
# export http_proxy=http://127.0.0.1:7890
# export https_proxy=http://127.0.0.1:7890

env FLASK_APP=py-src/data_formulator/app.py FLASK_RUN_PORT=5000 FLASK_RUN_HOST=0.0.0.0 flask run
env FLASK_APP=py-src/data_formulator/app.py FLASK_RUN_PORT=8000 FLASK_RUN_HOST=0.0.0.0 flask run
41 changes: 31 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
{
"name": "data-formulator",
"name": "@scrumdollc/data-formulator",
"type": "module",
"version": "0.1.0",
"private": true,
"version": "0.1.5",
"main": "dist/index.es.js",
"module": "dist/index.esm.js",
"files": [
"dist"
],
"repository": {
"type": "git",
"url": "https://github.com/ScrumDoLLC/data-formulator.git"
},
"exports": {
".": {
"import": "./dist/index.es.js",
"require": "./dist/index.umd.js"
}
},
"publishConfig": {
"registry": "https://npm.pkg.github.com"
},
"sideEffects": false,
"dependencies": {
"@emotion/react": "^11.9.0",
"@emotion/styled": "^11.8.1",
Expand All @@ -11,17 +29,15 @@
"@mui/material": "^5.6.0",
"@reduxjs/toolkit": "^1.8.6",
"@types/dompurify": "^3.0.5",
"@types/js-beautify": "^1.14.3",
"@types/validator": "^13.12.2",
"ag-grid-community": "^32.0.2",
"ag-grid-enterprise": "^32.0.2",
"ag-grid-react": "^32.0.2",
"d3": "^7.3.0",
"dompurify": "^3.2.4",
"js-beautify": "^1.15.4",
"localforage": "^1.10.0",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"markdown-to-jsx": "^7.4.0",
"mui-markdown": "^1.1.13",
"prettier": "^2.8.3",
"prism-react-renderer": "^1.3.5",
"prismjs": "^1.29.0",
"react": "^18.2.0",
Expand All @@ -40,7 +56,7 @@
"react-virtuoso": "^4.3.10",
"redux": "^4.2.0",
"redux-persist": "^6.0.0",
"typescript": "^4.9.5",
"sucrase": "^3.35.0",
"validator": "^13.12.0",
"vega": "^5.32.0",
"vega-embed": "^6.21.0",
Expand Down Expand Up @@ -68,7 +84,7 @@
"devDependencies": {
"@eslint/js": "^9.15.0",
"@types/d3": "^7.4.3",
"@types/lodash": "^4.17.7",
"@types/lodash-es": "^4.17.7",
"@types/node": "^20.14.10",
"@types/prismjs": "^1.26.0",
"@types/react": "^18.3.3",
Expand All @@ -80,8 +96,13 @@
"eslint-plugin-jsx-a11y": "^6.10.2",
"eslint-plugin-react": "^7.37.2",
"globals": "^15.12.0",
"rollup-plugin-visualizer": "^6.0.3",
"sass": "^1.77.6",
"typescript-eslint": "^8.16.0",
"vite": "^5.4.15"
},
"peerDependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
}
Binary file removed public/data-formulator-screenshot.png
Binary file not shown.
Binary file removed public/load-data.mp4
Binary file not shown.
Binary file removed public/renewable-pct.mp4
Binary file not shown.
Binary file removed public/renewable-rank.mp4
Binary file not shown.
Binary file removed public/renewable.mp4
Binary file not shown.
83 changes: 23 additions & 60 deletions src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,28 @@ import {
fetchFieldSemanticType,
} from './dfSlice'

import blue from '@mui/material/colors/blue';

import _ from 'lodash';

import {
Button,
Tooltip,
Typography,
Box,
Toolbar,
Input,
Divider,
DialogTitle,
Dialog,
DialogContent,
Avatar,
Link,
DialogContentText,
DialogActions,
ToggleButtonGroup,
ToggleButton,
Menu,
MenuItem,
TextField,
} from '@mui/material';
import Button from '@mui/material/Button';
import Tooltip from '@mui/material/Tooltip';
import Typography from '@mui/material/Typography';
import Box from '@mui/material/Box';
import Toolbar from '@mui/material/Toolbar';
import Input from '@mui/material/Input';
import Divider from '@mui/material/Divider';
import DialogTitle from '@mui/material/DialogTitle';
import Dialog from '@mui/material/Dialog';
import DialogContent from '@mui/material/DialogContent';
import Link from '@mui/material/Link';
import DialogContentText from '@mui/material/DialogContentText';
import DialogActions from '@mui/material/DialogActions';
import ToggleButtonGroup from '@mui/material/ToggleButtonGroup';
import ToggleButton from '@mui/material/ToggleButton';
import Menu from '@mui/material/Menu';
import MenuItem from '@mui/material/MenuItem';
import TextField from '@mui/material/TextField';


import MuiAppBar from '@mui/material/AppBar';
import { createTheme, styled, ThemeProvider } from '@mui/material/styles';
import { styled } from '@mui/material/styles';

import PowerSettingsNewIcon from '@mui/icons-material/PowerSettingsNew';
import { DataFormulatorFC } from '../views/DataFormulator';
Expand All @@ -54,7 +47,7 @@ import {
} from "react-router-dom";
import { About } from '../views/About';
import { MessageSnackbar } from '../views/MessageSnackbar';
import { appConfig, assignAppConfig, getUrls, PopupConfig } from './utils';
import { appConfig, assignAppConfig, fetchData, PopupConfig } from './utils';
import { DictTable } from '../components/ComponentType';
import { AppDispatch } from './store';
import { ActionSubscription, subscribe, unsubscribe } from './embed';
Expand Down Expand Up @@ -439,7 +432,7 @@ export const AppFC: FC<AppFCProps> = function AppFC(appProps) {
}, []);

useEffect(() => {
fetch('/.auth/me')
fetchData('/.auth/me')
.then(function (response) { return response.json(); })
.then(function (result) {
if (Array.isArray(result) && result.length > 0) {
Expand All @@ -464,31 +457,6 @@ export const AppFC: FC<AppFCProps> = function AppFC(appProps) {
dispatch(fetchAvailableModels());
}, []);

let theme = createTheme({
typography: {
fontFamily: [
"Arial",
"Roboto",
"Helvetica Neue",
"sans-serif"
].join(",")
},
palette: {
primary: {
main: blue[700]
},
derived: {
main: "rgb(255,215,0)", // gold
},
custom: {
main: "rgb(255, 160, 122)", //lightsalmon
},
warning: {
main: '#bf5600', // New accessible color, original (#ed6c02) has insufficient color contrast of 3.11
},
},
});

let switchers = (
<Box sx={{ display: "flex" }} key="switchers">
<ToggleButtonGroup
Expand Down Expand Up @@ -577,7 +545,7 @@ export const AppFC: FC<AppFCProps> = function AppFC(appProps) {
}
]);

let app =
return (
<Box sx={{
position: 'absolute',
top: 0,
Expand All @@ -600,12 +568,7 @@ export const AppFC: FC<AppFCProps> = function AppFC(appProps) {
<RouterProvider router={router} />
<MessageSnackbar />
</Box>
</Box>;

return (
<ThemeProvider theme={theme}>
{app}
</ThemeProvider>
</Box>
);
}

Expand Down
48 changes: 28 additions & 20 deletions src/app/dfSlice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Message } from '../views/MessageSnackbar';
import { getChartTemplate, getChartChannels } from "../components/ChartTemplates"
import { getDataTable } from '../views/VisualizationView';
import { findBaseFields } from '../views/ViewUtils';
import { adaptChart, getTriggers, getUrls } from './utils';
import { adaptChart, fetchData, getTriggers, getUrls } from './utils';
import { Type } from '../data/types';
import { TableChallenges } from '../views/TableSelectionView';

Expand Down Expand Up @@ -74,8 +74,10 @@ export interface DataFormulatorState {
// Define the initial state using that type
const initialState: DataFormulatorState = {

models: [],
selectedModelId: undefined,
models: [
{id: 'chatgpt', endpoint: 'http://localhost:9000', model: '4o', api_key: '', api_base: '', api_version: ''}
],
selectedModelId: 'chatgpt',
testedModels: [],

tables: [],
Expand All @@ -86,8 +88,8 @@ const initialState: DataFormulatorState = {
conceptShelfItems: [],

//synthesizerRunning: false,
displayPanelSize: 550,
visPaneSize: 640,
displayPanelSize: 320,
visPaneSize: 30,
conceptShelfPaneSize: 240, // 300 is a good number for derived concept cards

messages: [],
Expand Down Expand Up @@ -160,18 +162,18 @@ export const fetchFieldSemanticType = createAsyncThunk(
method: 'POST',
headers: { 'Content-Type': 'application/json', },
body: JSON.stringify({
token: Date.now(),
// token: Date.now(),
input_data: {name: table.id, rows: table.rows},
model: dfSelectors.getActiveModel(state)
// model: dfSelectors.getActiveModel(state)
}),
};

// timeout the request after 20 seconds
const controller = new AbortController()
const timeoutId = setTimeout(() => controller.abort(), 20000)

let response = await fetch(getUrls().SERVER_PROCESS_DATA_ON_LOAD, {...message, signal: controller.signal })

let response = await fetchData(getUrls().SERVER_PROCESS_DATA_ON_LOAD, {...message, signal: controller.signal })
clearTimeout(timeoutId);
return response.json();
}
);
Expand Down Expand Up @@ -200,8 +202,8 @@ export const fetchCodeExpl = createAsyncThunk(
const controller = new AbortController()
const timeoutId = setTimeout(() => controller.abort(), 20000)

let response = await fetch(getUrls().CODE_EXPL_URL, {...message, signal: controller.signal })

let response = await fetchData(getUrls().CODE_EXPL_URL, {...message, signal: controller.signal })
clearTimeout(timeoutId);
return response.text();
}
);
Expand All @@ -222,8 +224,8 @@ export const fetchAvailableModels = createAsyncThunk(
const controller = new AbortController()
const timeoutId = setTimeout(() => controller.abort(), 20000)

let response = await fetch(getUrls().CHECK_AVAILABLE_MODELS, {...message, signal: controller.signal })

let response = await fetchData(getUrls().CHECK_AVAILABLE_MODELS, {...message, signal: controller.signal })
clearTimeout(timeoutId);
return response.json();
}
);
Expand Down Expand Up @@ -265,8 +267,8 @@ export const dataFormulatorSlice = createSlice({

let savedState = action.payload;

state.models = savedState.models;
state.selectedModelId = savedState.selectedModelId;
state.models = savedState.models || initialState.models;
state.selectedModelId = savedState.selectedModelId || initialState.selectedModelId;
state.testedModels = []; // models should be tested again

//state.table = undefined;
Expand All @@ -286,7 +288,7 @@ export const dataFormulatorSlice = createSlice({

state.chartSynthesisInProgress = [];

state.config = savedState.config;
state.config = savedState.config || initialState.config;
},
setConfig: (state, action: PayloadAction<{formulateTimeoutSeconds: number, maxRepairAttempts: number}>) => {
state.config = action.payload;
Expand Down Expand Up @@ -315,8 +317,8 @@ export const dataFormulatorSlice = createSlice({
},
loadTable: (state, action: PayloadAction<DictTable>) => {
let table = action.payload;
state.tables = [...state.tables, table];
state.conceptShelfItems = [...state.conceptShelfItems, ...getDataFieldItems(table)];
state.tables = [table];
state.conceptShelfItems = [...getDataFieldItems(table)];

state.focusedTableId = table.id;
state.focusedChartId = undefined;
Expand Down Expand Up @@ -363,6 +365,9 @@ export const dataFormulatorSlice = createSlice({
let chart = action.payload;
state.charts = [chart, ...state.charts]
},
setCharts: (state, action: PayloadAction<Chart[]>) => {
state.charts = [...action.payload]
},
duplicateChart: (state, action: PayloadAction<string>) => {
let chartId = action.payload;

Expand Down Expand Up @@ -496,6 +501,9 @@ export const dataFormulatorSlice = createSlice({
chart.encodingMap[channel2] = { fieldID: enc1.fieldID, aggregate: enc1.aggregate, bin: enc1.bin, sortBy: enc1.sortBy };
}
},
setConceptItems: (state, action: PayloadAction<FieldItem[]>) => {
state.conceptShelfItems = [...action.payload];
},
addConceptItems: (state, action: PayloadAction<FieldItem[]>) => {
state.conceptShelfItems = [...action.payload, ...state.conceptShelfItems];
},
Expand Down Expand Up @@ -567,8 +575,8 @@ export const dataFormulatorSlice = createSlice({
clearUnReferencedTables: (state) => {
// remove all tables that are not referred
let charts = state.charts;
let referredTableId = charts.map(chart => getDataTable(chart, state.tables, charts, state.conceptShelfItems).id);
state.tables = state.tables.filter(t => !(t.derive && !referredTableId.some(tableId => tableId == t.id)));
let referredTableId = charts.map(chart => getDataTable(chart, state.tables, charts, state.conceptShelfItems)?.id);
state.tables = state.tables.filter(t => !(t.derive && !referredTableId?.some(tableId => tableId == t.id)));
},
clearUnReferencedCustomConcepts: (state) => {
let fieldNamesFromTables = state.tables.map(t => t.names).flat();
Expand Down
22 changes: 11 additions & 11 deletions src/app/embed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@ function sendEventToSubscribers(action: Action) {
switch (action.actionName) {
case "loadData": {
if (subscription.loadData) {
let loadDataAction = action as LoadDataAction;
let table: undefined | DictTable = undefined;
try {
table = createTableFromFromObjectArray(loadDataAction.actionParams.tableName || 'dataset', loadDataAction.actionParams.table);
} catch (error) {
console.error("ActionQueue: error creating table from message", error);
}
if (table) {
console.log('ActionQueue: success creating table from message');
subscription.loadData(table);
}
// let loadDataAction = action as LoadDataAction;
// let table: undefined | DictTable = undefined;
// try {
// table = createTableFromFromObjectArray(loadDataAction.actionParams.tableName || 'dataset', loadDataAction.actionParams.table);
// } catch (error) {
// console.error("ActionQueue: error creating table from message", error);
// }
// if (table) {
// console.log('ActionQueue: success creating table from message');
// subscription.loadData(table);
// }
}
break;
}
Expand Down
Loading