Skip to content

Commit 4c31f60

Browse files
authored
Merge pull request #1280 from mito-ds/dev
Release: 3/14/24
2 parents 3086d54 + 65140c5 commit 4c31f60

File tree

20 files changed

+131
-33
lines changed

20 files changed

+131
-33
lines changed

.github/workflows/prerelease-tests.yml

+10-10
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,18 @@ jobs:
6262
timeout-minutes: 60
6363
strategy:
6464
matrix:
65-
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
65+
os: ['ubuntu-latest-m', 'macos-latest', 'windows-latest-l']
6666
python-version: ['3.10']
6767
demo: ['vanguard-fund-performance']
6868
project: ['chromium', 'firefox', 'webkit', 'Google Chrome', 'Microsoft Edge']
6969
exclude:
70-
- os: 'windows-latest'
70+
- os: 'windows-latest-l'
7171
project: webkit
7272
- os: 'macos-latest'
7373
project: 'Microsoft Edge'
74-
- os: 'ubuntu-latest'
74+
- os: 'ubuntu-latest-m'
7575
project: 'Microsoft Edge'
76-
- os: 'ubuntu-latest'
76+
- os: 'ubuntu-latest-m'
7777
project: 'webkit'
7878
fail-fast: false
7979
runs-on: ${{ matrix.os }}
@@ -95,7 +95,7 @@ jobs:
9595
cache: 'npm'
9696
cache-dependency-path: mitosheet/package-lock.json
9797
- name: Install dependencies (ubuntu, macos)
98-
if: matrix.os != 'windows-latest'
98+
if: matrix.os != 'windows-latest-l'
9999
run: |
100100
cd tests
101101
python3 -m venv venv
@@ -106,13 +106,13 @@ jobs:
106106
npm install
107107
npx playwright install chromium webkit firefox chrome
108108
- name: Setup streamlit (ubuntu, macos)
109-
if: matrix.os != 'windows-latest'
109+
if: matrix.os != 'windows-latest-l'
110110
run: |
111111
mkdir -p ~/.streamlit/
112112
echo "[general]" > ~/.streamlit/credentials.toml
113113
echo "email = \"\"" >> ~/.streamlit/credentials.toml
114114
- name: Setup streamlit (windows)
115-
if: matrix.os == 'windows-latest'
115+
if: matrix.os == 'windows-latest-l'
116116
run: |
117117
$streamlitDir = "$HOME\.streamlit"
118118
if (-not (Test-Path -Path $streamlitDir)) {
@@ -123,7 +123,7 @@ jobs:
123123
email = ""
124124
"@
125125
- name: Install dependencies (windows)
126-
if: matrix.os == 'windows-latest'
126+
if: matrix.os == 'windows-latest-l'
127127
run: |
128128
cd tests
129129
python3 -m venv venv
@@ -134,7 +134,7 @@ jobs:
134134
npm install
135135
npx playwright install chromium webkit firefox chrome
136136
- name: Start a server and run tests (ubuntu, macos)
137-
if: matrix.os != 'windows-latest'
137+
if: matrix.os != 'windows-latest-l'
138138
run: |
139139
cd tests
140140
source venv/bin/activate
@@ -144,7 +144,7 @@ jobs:
144144
bash ../check_server.sh
145145
npm run test:streamlit:demo -- --project="${{ matrix.project }}"
146146
- name: Start a server and run tests (windows)
147-
if: matrix.os == 'windows-latest'
147+
if: matrix.os == 'windows-latest-l'
148148
run: |
149149
cd tests
150150
.\venv\Scripts\Activate.ps1

.github/workflows/test-mitosheet-frontend.yml

+10-10
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ jobs:
119119
timeout-minutes: 60
120120
strategy:
121121
matrix:
122-
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
122+
os: ['ubuntu-latest-m', 'macos-latest', 'windows-latest-l']
123123
python-version: ['3.10']
124124
project:
125125
- test-name: 'chromium'
@@ -134,16 +134,16 @@ jobs:
134134
install-name: 'msedge'
135135
testfiles: ['taskpanes', 'grid', 'toolbar', 'graph']
136136
exclude:
137-
- os: 'windows-latest'
137+
- os: 'windows-latest-l'
138138
project:
139139
test-name: webkit
140140
- os: 'macos-latest'
141141
project:
142142
test-name: 'Microsoft Edge'
143-
- os: 'ubuntu-latest'
143+
- os: 'ubuntu-latest-m'
144144
project:
145145
test-name: 'Microsoft Edge'
146-
- os: 'ubuntu-latest'
146+
- os: 'ubuntu-latest-m'
147147
project:
148148
test-name: 'webkit'
149149
fail-fast: false
@@ -167,20 +167,20 @@ jobs:
167167
cache: 'npm'
168168
cache-dependency-path: mitosheet/package-lock.json
169169
- name: Install dependencies (ubuntu, macos)
170-
if: matrix.os != 'windows-latest'
170+
if: matrix.os != 'windows-latest-l'
171171
run: |
172172
cd tests
173173
bash mac-setup.sh ${{ matrix.project.install-name }}
174174
source venv/bin/activate
175175
pip install -r extra-requirements.txt
176176
- name: Setup streamlit (ubuntu, macos)
177-
if: matrix.os != 'windows-latest'
177+
if: matrix.os != 'windows-latest-l'
178178
run: |
179179
mkdir -p ~/.streamlit/
180180
echo "[general]" > ~/.streamlit/credentials.toml
181181
echo "email = \"\"" >> ~/.streamlit/credentials.toml
182182
- name: Setup streamlit (windows)
183-
if: matrix.os == 'windows-latest'
183+
if: matrix.os == 'windows-latest-l'
184184
run: |
185185
$streamlitDir = "$HOME\.streamlit"
186186
if (-not (Test-Path -Path $streamlitDir)) {
@@ -191,7 +191,7 @@ jobs:
191191
email = ""
192192
"@
193193
- name: Install dependencies (windows)
194-
if: matrix.os == 'windows-latest'
194+
if: matrix.os == 'windows-latest-l'
195195
run: |
196196
cd tests
197197
@@ -210,15 +210,15 @@ jobs:
210210
npm install
211211
npm run build
212212
- name: Start a server and run tests (ubuntu, macos)
213-
if: matrix.os != 'windows-latest'
213+
if: matrix.os != 'windows-latest-l'
214214
run: |
215215
cd tests
216216
source venv/bin/activate
217217
streamlit run streamlit_test.py --server.port 8555 &
218218
bash check_server.sh
219219
npm run test -- --project="${{ matrix.project.test-name }}" streamlit_ui_tests/${{matrix.testfiles}}
220220
- name: Start a server and run tests (windows)
221-
if: matrix.os == 'windows-latest'
221+
if: matrix.os == 'windows-latest-l'
222222
run: |
223223
cd tests
224224
.\venv\Scripts\Activate.ps1

mitosheet/css/taskpanes/Graph/GraphSidebar.css

+3
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@
7676
padding-right: 5px;
7777
padding-left: 5px;
7878
box-sizing: border-box;
79+
80+
height: 100%;
81+
overflow-y: scroll;
7982
}
8083

8184
.graph-sidebar-toolbar-content {

mitosheet/mitosheet/code_chunks/step_performers/filter_code_chunk.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77

88
from copy import copy
9+
from datetime import date
910
from typing import List, Optional, Tuple, Union
1011

1112
from mitosheet.code_chunks.code_chunk import CodeChunk
@@ -25,6 +26,7 @@
2526
get_column_header_as_transpiled_code, get_list_as_string_without_internal_quotes)
2627
from mitosheet.types import (ColumnHeader, ColumnID, ColumnIDWithFilterGroup,
2728
Filter, FilterGroup, OperatorType)
29+
import pandas as pd
2830

2931
# Dict used when a filter condition is only used by one filter
3032
FILTER_FORMAT_STRING_DICT = {
@@ -180,7 +182,7 @@
180182
OPERATOR_SIGNS = {"Or": "|", "And": "&"}
181183

182184
def get_single_filter_string(
183-
df_name: str, column_header: ColumnHeader, filter_: Filter
185+
df_name: str, column_header: ColumnHeader, column_dtype: str, filter_: Filter
184186
) -> str:
185187
"""
186188
Transpiles a specific filter to a fitler string, to be used
@@ -189,6 +191,14 @@ def get_single_filter_string(
189191
condition = filter_["condition"]
190192
value = filter_["value"]
191193

194+
# When users are mid-way through typing a date in the UI, it might not be valid yet.
195+
# To prevent throwing errors, we set it to the minimum date
196+
if is_datetime_dtype(column_dtype):
197+
try:
198+
pd.to_datetime(value)
199+
except:
200+
value = pd.Timestamp.min + pd.Timedelta(seconds=1)
201+
192202
transpiled_column_header = get_column_header_as_transpiled_code(column_header)
193203
value = get_column_header_as_transpiled_code(value)
194204

@@ -289,7 +299,7 @@ def create_filter_string_for_condition(
289299
elif len(filters_with_condition) == 1:
290300
# Use the single filter condition
291301
return get_single_filter_string(
292-
df_name, column_header, filters_with_condition[0]
302+
df_name, column_header, column_dtype, filters_with_condition[0]
293303
)
294304
elif len(filters_with_condition) > 1:
295305
# Use the multiple filter condition

mitosheet/mitosheet/code_chunks/step_performers/pivot_code_chunk.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,11 @@ def get_code(self) -> Tuple[List[str], List[str]]:
155155
for column_id, value in self.values_column_ids_map.items()
156156
}
157157
pivot_filters: List[ColumnHeaderWithFilter] = [
158-
{'column_header': self.prev_state.column_ids.get_column_header_by_id(self.sheet_index, pf['column_id']), 'filter': pf['filter']}
158+
{
159+
'column_header': self.prev_state.column_ids.get_column_header_by_id(self.sheet_index, pf['column_id']),
160+
'column_dtype': str(self.prev_state.dfs[self.sheet_index][pf['column_id']].dtype),
161+
'filter': pf['filter']
162+
}
159163
for pf in self.pivot_filters_ids
160164
]
161165

@@ -168,7 +172,7 @@ def get_code(self) -> Tuple[List[str], List[str]]:
168172
# First, filter down to the rows of the original dataframe that we need
169173
if len(pivot_filters) > 0:
170174
filter_strings = [
171-
get_single_filter_string(self.old_df_name, pf['column_header'], pf['filter'])
175+
get_single_filter_string(self.old_df_name, pf['column_header'], pf['column_dtype'], pf['filter'])
172176
for pf in pivot_filters
173177
]
174178
full_filter_string = combine_filter_strings('And', filter_strings)

mitosheet/mitosheet/steps_manager.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
from mitosheet.transpiler.transpile_utils import get_default_code_options
3838
from mitosheet.types import CodeOptions, ColumnDefinintion, ColumnDefinitions, MitoTheme, ParamMetadata
3939
from mitosheet.updates import UPDATES
40-
from mitosheet.user.utils import is_enterprise, is_running_test
40+
from mitosheet.user.utils import is_enterprise, is_pro, is_running_test
4141
from mitosheet.utils import NpEncoder, dfs_to_array_for_json, get_default_df_formats, get_new_id, is_default_df_names
4242
from mitosheet.step_performers.utils.user_defined_function_utils import get_user_defined_importers_for_frontend, get_user_defined_editors_for_frontend
4343
from mitosheet.step_performers.utils.user_defined_function_utils import validate_and_wrap_sheet_functions, validate_user_defined_editors
@@ -253,6 +253,9 @@ def __init__(
253253
if not is_running_test() and not is_enterprise() and self.user_defined_editors is not None and len(self.user_defined_editors) > 0:
254254
raise ValueError("editors are only supported in the enterprise version of Mito. See Mito plans https://www.trymito.io/plans")
255255

256+
if not is_running_test() and not is_pro() and column_definitions is not None:
257+
raise ValueError("column definitions are only supported in the enterprise version of Mito. See Mito plans https://www.trymito.io/plans")
258+
256259
# The version of the public interface used by this analysis
257260
self.public_interface_version = 3
258261

mitosheet/mitosheet/tests/saved_analyses/test_save_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import pytest
1515
from mitosheet.saved_analyses import SAVED_ANALYSIS_FOLDER, write_save_analysis_file
1616
from mitosheet.saved_analyses.save_utils import read_and_upgrade_analysis
17-
from mitosheet.step_performers.filter import FC_NUMBER_EXACTLY
17+
from mitosheet.types import FC_NUMBER_EXACTLY
1818
from mitosheet.tests.test_utils import (create_mito_wrapper_with_data,
1919
create_mito_wrapper)
2020

mitosheet/mitosheet/tests/step_performers/test_filter.py

+10
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,16 @@
322322
data={"A": pd.to_datetime(pd.Series(data=["12-2-2020", "12-3-2020"]))}
323323
),
324324
),
325+
# Test for when the year is not fully inputted yet so the date is invalid.
326+
# We don't throw an error for this so that the user can continue inputting the date.
327+
(
328+
pd.DataFrame(
329+
data={"A": pd.to_datetime(pd.Series(data=["12-2-2020", "12-3-2020"]))}
330+
),
331+
FC_DATETIME_LESS_THAN_OR_EQUAL,
332+
"12-2-0020",
333+
pd.DataFrame(data={"A": pd.to_datetime(pd.Series(data=[], dtype='float64'))}),
334+
),
325335
(
326336
pd.DataFrame(
327337
data={"A": pd.to_datetime(pd.Series(data=["12-2-2020", "12-3-2020"]))}

mitosheet/mitosheet/tests/step_performers/test_pivot.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from pandas.testing import assert_frame_equal
1616

1717
from mitosheet.saved_analyses import read_and_upgrade_analysis
18-
from mitosheet.step_performers.filter import (FC_BOOLEAN_IS_TRUE,
18+
from mitosheet.types import (FC_BOOLEAN_IS_TRUE,
1919
FC_DATETIME_EXACTLY,
2020
FC_NUMBER_EXACTLY,
2121
FC_NUMBER_GREATER,
@@ -34,7 +34,6 @@
3434
from mitosheet.tests.decorators import pandas_post_1_only, pandas_pre_1_only
3535
from mitosheet.tests.test_utils import (create_mito_wrapper,
3636
get_dataframe_generation_code)
37-
from mitosheet.types import ColumnHeaderWithPivotTransform
3837

3938

4039
def test_simple_pivot():

mitosheet/mitosheet/tests/step_performers/test_set_dataframe_format.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111
import pandas as pd
1212
import pytest
1313
from mitosheet.state import NUMBER_FORMAT_PLAIN_TEXT, NUMBER_FORMAT_CURRENCY, get_default_dataframe_format
14-
from mitosheet.step_performers.filter import FC_NUMBER_GREATER
1514
from mitosheet.tests.test_utils import create_mito_wrapper
16-
from mitosheet.types import ConditionalFormat, DataframeFormat
15+
from mitosheet.types import ConditionalFormat, DataframeFormat, FC_NUMBER_GREATER
1716

1817

1918

mitosheet/mitosheet/tests/streamlit/test_streamlit.py

+27
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,31 @@ def test_spreadsheet_with_column_definitions():
137137
code_options={'as_function': True, 'call_function': False, 'function_name': 'test', 'function_params': {}},
138138
return_type='function'
139139
)
140+
assert callable(f)
141+
142+
@requires_streamlit
143+
def test_spreadsheet_with_column_definitions_only_one_color():
144+
f = spreadsheet(
145+
df1,
146+
column_definitions=[
147+
[
148+
{
149+
'columns': ['A'],
150+
'conditional_formats': [{
151+
'filters': [{'condition': 'greater_than_or_equal', 'value': 5}],
152+
'font_color': '#c30010',
153+
}]
154+
},
155+
{
156+
'columns': ['A'],
157+
'conditional_formats': [{
158+
'filters': [{'condition': 'less', 'value': 2}],
159+
'background_color': '#ddcbd1'
160+
}]
161+
}
162+
]
163+
],
164+
code_options={'as_function': True, 'call_function': False, 'function_name': 'test', 'function_params': {}},
165+
return_type='function'
166+
)
140167
assert callable(f)

mitosheet/mitosheet/tests/updates/test_undo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"""
99
import pandas as pd
1010

11-
from mitosheet.step_performers.filter import FC_NUMBER_EXACTLY
11+
from mitosheet.types import FC_NUMBER_EXACTLY
1212
from mitosheet.tests.test_utils import create_mito_wrapper_with_data, create_mito_wrapper
1313

1414

mitosheet/mitosheet/types.py

+1
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ class ColumnIDWithFilterGroup(TypedDict):
204204

205205
class ColumnHeaderWithFilter(TypedDict):
206206
column_header: ColumnHeader
207+
column_dtype: str
207208
filter: Filter
208209

209210
class ColumnIDWithPivotTransform(TypedDict):

mitosheet/mitosheet/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ def get_default_df_formats(column_definitions: Optional[List[ColumnDefinitions]]
366366
'filters': conditional_format['filters'],
367367
'invalidFilterColumnIDs': [],
368368
'color': font_color,
369-
'backgroundColor': conditional_format['background_color']
369+
'backgroundColor': background_color
370370
}
371371

372372
conditional_formats.append(new_conditional_format)

mitosheet/src/mito/Mito.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ import { classNames } from './utils/classNames';
6666
import loadPlotly from './utils/plotly';
6767
// AUTOGENERATED LINE: MITOIMPORT (DO NOT DELETE)
6868
import { isInJupyterLab, isInJupyterNotebook } from '.';
69+
import { MitoAPIResult } from './api/api';
6970
import { SendFunction, SendFunctionError } from './api/send';
7071
import BottomLeftPopup from './components/elements/BottomLeftPopup';
7172
import StreamlitSignupModal from './components/modals/StreamlitSignupModal';
@@ -85,7 +86,6 @@ import { getCSSStyleVariables } from './utils/colors';
8586
import { handleKeyboardShortcuts } from './utils/keyboardShortcuts';
8687
import { isInDashboard } from './utils/location';
8788
import { shallowEqualToDepth } from './utils/objects';
88-
import { MitoAPIResult } from './api/api';
8989

9090
export type MitoProps = {
9191
getSendFunction: () => Promise<SendFunction | SendFunctionError>

mitosheet/src/mito/components/endo/EndoGrid.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,9 @@ function EndoGrid(props: {
544544

545545
// On double click, open the cell editor on this cell
546546
const onDoubleClick = (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
547+
if (editorState !== undefined) {
548+
return;
549+
}
547550
const {rowIndex, columnIndex} = getIndexesFromMouseEvent(e);
548551
// Don't open for headers
549552
if ((rowIndex === undefined || columnIndex === undefined) || getIsHeader(rowIndex, columnIndex)) {

0 commit comments

Comments
 (0)