From 95706064d4b30e706b24fe147eae917605eb0460 Mon Sep 17 00:00:00 2001 From: alexcjohnson Date: Wed, 3 May 2023 18:30:52 -0400 Subject: [PATCH 01/11] update to cimg images, and full_build with node 16 --- .circleci/config.yml | 175 +++++++++++++----- packages/python/plotly/recipe/meta.yaml | 2 +- .../requirements_36_core.txt | 1 + 3 files changed, 134 insertions(+), 44 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e77a402dc67..2a59821d92d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,5 +1,8 @@ version: 2.1 +orbs: + browser-tools: circleci/browser-tools@1.4.1 + commands: test_core: parameters: @@ -8,12 +11,22 @@ commands: type: string steps: - checkout + - browser-tools/install-chrome + - browser-tools/install-chromedriver - run: name: Install dependencies - command: "cd packages/python; sudo pip install -r ./plotly/test_requirements/requirements_<>_core.txt" + command: | + cd packages/python/plotly + python -m venv venv + . venv/bin/activate + pip install --upgrade pip wheel + pip install -r ./test_requirements/requirements_<>_core.txt - run: name: Test core - command: "cd packages/python/plotly; pytest plotly/tests/test_core" + command: | + cd packages/python/plotly + . venv/bin/activate + pytest plotly/tests/test_core no_output_timeout: 20m test_optional: @@ -23,34 +36,62 @@ commands: type: string steps: - checkout + - browser-tools/install-chrome + - browser-tools/install-chromedriver - run: name: Install dependencies - command: "cd packages/python; sudo pip install -r ./plotly/test_requirements/requirements_<>_optional.txt" + command: | + cd packages/python/plotly + python -m venv venv + . venv/bin/activate + pip install --upgrade pip wheel + pip install -r ./test_requirements/requirements_<>_optional.txt - run: name: Install plotly-geo - command: "cd packages/python/plotly-geo; sudo pip install -e ." + command: | + cd packages/python/plotly-geo + . ../plotly/venv/bin/activate + pip install -e . - run: name: Test core - command: "cd packages/python/plotly; pytest plotly/tests/test_core" + command: | + cd packages/python/plotly + . venv/bin/activate + pytest plotly/tests/test_core no_output_timeout: 20m - run: name: Test optional - command: "cd packages/python/plotly; pytest plotly/tests/test_optional" + command: | + cd packages/python/plotly + . venv/bin/activate + pytest plotly/tests/test_optional no_output_timeout: 40m - run: name: Test utils - command: "cd packages/python/plotly; pytest _plotly_utils/tests/" + command: | + cd packages/python/plotly + . venv/bin/activate + pytest _plotly_utils/tests/ no_output_timeout: 20m - run: name: Test io - command: "cd packages/python/plotly; pytest plotly/tests/test_io" + command: | + cd packages/python/plotly + . venv/bin/activate + pytest plotly/tests/test_io no_output_timeout: 20m - run: name: Test dependencdies not imported - command: "cd packages/python/plotly; pytest -x test_init/test_dependencies_not_imported.py" + command: | + cd packages/python/plotly + . venv/bin/activate + pytest -x test_init/test_dependencies_not_imported.py - run: name: Test lazy imports - command: "cd packages/python/plotly; pytest -x test_init/test_lazy_imports.py" + command: | + cd packages/python/plotly + . venv/bin/activate + pytest -x test_init/test_lazy_imports.py test_orca: parameters: @@ -59,21 +100,35 @@ commands: type: string steps: - checkout + - browser-tools/install-chrome + - browser-tools/install-chromedriver - run: name: Install dependencies - command: "cd packages/python; sudo pip install -r ./plotly/test_requirements/requirements_<>_optional.txt" + command: | + cd packages/python/plotly + python -m venv venv + . venv/bin/activate + pip install --upgrade pip wheel + pip install -r ./test_requirements/requirements_<>_optional.txt - run: name: Install plotly-geo - command: "cd packages/python/plotly-geo; sudo pip install -e ." + command: | + cd packages/python/plotly-geo + . ../plotly/venv/bin/activate + pip install -e . - run: name: Install orca command: | - sudo npm install electron@1.8.4 sudo npm install orca + npm install electron@1.8.4 + npm install orca sudo apt-get install -y poppler-utils libxtst6 xvfb libgtk2.0-0 libgconf-2-4 libnss3 libasound2 rename echo 'export PATH="/home/circleci/project/node_modules/.bin:$PATH"' >> $BASH_ENV - run: name: Test orca - command: "cd packages/python/plotly; pytest plotly/tests/test_orca" + command: | + cd packages/python/plotly + . venv/bin/activate + pytest plotly/tests/test_orca no_output_timeout: 20m - store_artifacts: path: packages/python/plotly/plotly/tests/test_orca/images/linux/failed @@ -81,42 +136,47 @@ commands: jobs: check-code-formatting: docker: - - image: circleci/python:3.7-stretch-node-browsers + - image: cimg/python:3.7 steps: - checkout - run: name: Install black - command: "sudo pip install black==22.3.0" + command: | + python -m venv venv + . venv/bin/activate + pip install black==22.3.0 - run: name: Check formatting with black - command: "black --check ." + command: | + . venv/bin/activate + black --check . --exclude venv # Core python_36_core: docker: - - image: circleci/python:3.6-stretch-node-browsers + - image: cimg/python:3.6-browsers steps: - test_core: py: "36" python_37_core: docker: - - image: circleci/python:3.7-stretch-node-browsers + - image: cimg/python:3.7-browsers steps: - test_core: py: "37" python_38_core: docker: - - image: circleci/python:3.8-buster-node-browsers + - image: cimg/python:3.8-browsers steps: - test_core: py: "38" python_39_core: docker: - - image: circleci/python:3.9-buster-node-browsers + - image: cimg/python:3.9-browsers steps: - test_core: py: "39" @@ -124,28 +184,28 @@ jobs: # Optional python_36_optional: docker: - - image: circleci/python:3.6-stretch-node-browsers + - image: cimg/python:3.6-browsers steps: - test_optional: py: "36" python_37_optional: docker: - - image: circleci/python:3.7-stretch-node-browsers + - image: cimg/python:3.7-browsers steps: - test_optional: py: "37" python_38_optional: docker: - - image: circleci/python:3.8-buster-node-browsers + - image: cimg/python:3.8-browsers steps: - test_optional: py: "38" python_39_optional: docker: - - image: circleci/python:3.9-buster-node-browsers + - image: cimg/python:3.9-browsers steps: - test_optional: py: "39" @@ -154,7 +214,7 @@ jobs: python_39_pandas_2_optional: docker: - - image: circleci/python:3.9-buster-node-browsers + - image: cimg/python:3.9-browsers steps: - test_optional: py: "39_pandas_2" @@ -162,7 +222,7 @@ jobs: # Orca python_38_orca: docker: - - image: circleci/python:3.8-buster-node-browsers + - image: cimg/python:3.8-browsers steps: - test_orca: py: "38" @@ -170,7 +230,7 @@ jobs: # Percy python_37_percy: docker: - - image: circleci/python:3.7-stretch-node-browsers + - image: cimg/python:3.7-browsers environment: PERCY_ENABLED: True PERCY_PROJECT: plotly/plotly.py @@ -178,6 +238,8 @@ jobs: steps: - checkout + - browser-tools/install-chrome + - browser-tools/install-chromedriver - run: name: Inject Percy Environment variables command: | @@ -185,9 +247,9 @@ jobs: - run: name: Install requirements command: | - sudo pip install --upgrade virtualenv - python -m venv venv || virtualenv venv + python -m venv venv . venv/bin/activate + pip install --upgrade pip wheel pip install -e ./packages/python/plotly pip install -e ./packages/python/plotly-geo pip install -r ./packages/python/plotly/test_requirements/requirements_37_optional.txt @@ -206,22 +268,30 @@ jobs: # Chart studio python_37_chart_studio: docker: - - image: circleci/python:3.7-stretch-node-browsers + - image: cimg/python:3.7 resource_class: large steps: - checkout - run: name: Install dependencies - command: "cd packages/python; sudo pip install -r ./chart-studio/test_requirements/requirements_37.txt" + command: | + cd packages/python/chart-studio + python -m venv venv + . venv/bin/activate + pip install --upgrade pip wheel + pip install -r ./test_requirements/requirements_37.txt - run: name: Tests - command: "cd packages/python/chart-studio; pytest -x chart_studio/tests/" + command: | + cd packages/python/chart-studio + . venv/bin/activate + pytest -x chart_studio/tests/ no_output_timeout: 20m plotlyjs_dev_build: docker: - - image: circleci/python:3.7-stretch-node-browsers + - image: cimg/python:3.7-node environment: LANG: en_US.UTF-8 resource_class: large @@ -230,16 +300,32 @@ jobs: - checkout - run: name: Install dependencies - command: "cd packages/python; sudo pip install -r ./plotly/test_requirements/requirements_37_core.txt black inflect; sudo pip install jupyterlab~=3.0" + command: | + cd packages/python/plotly + python -m venv venv + . venv/bin/activate + pip install --upgrade pip wheel + pip install -r ./test_requirements/requirements_37_core.txt black inflect + pip install jupyterlab~=3.0 - run: name: Update jupyterlab-plotly version - command: "cd packages/python/plotly; python setup.py updateplotlywidgetversion" + command: | + cd packages/python/plotly + . venv/bin/activate + python setup.py updateplotlywidgetversion - run: name: Update plotly.js to dev - command: "cd packages/python/plotly; python setup.py updateplotlyjsdev" + command: | + cd packages/python/plotly + . venv/bin/activate + python setup.py updateplotlyjsdev - run: name: Test core - command: "cd packages/python/plotly; locale; pytest -k 'not nodev' plotly/tests/test_core" + command: | + cd packages/python/plotly + . venv/bin/activate + locale + pytest -k 'not nodev' plotly/tests/test_core no_output_timeout: 20m - run: name: Commit @@ -254,6 +340,7 @@ jobs: name: Build source distribution packages command: | cd packages/python/plotly + . venv/bin/activate python setup.py sdist when: always - store_artifacts: @@ -273,7 +360,7 @@ jobs: name: Create conda environment command: | conda create -n env --yes python=3.9 conda-build conda-verify - conda install -n env -c conda-forge jupyterlab nodejs=18 + conda install -n env -c conda-forge jupyterlab nodejs=16 conda init bash mkdir output @@ -335,7 +422,7 @@ jobs: docker: # specify the version you desire here # use `-browsers` prefix for selenium tests, e.g. `3.6.1-browsers` - - image: circleci/python:3.7-stretch-node-browsers + - image: cimg/python:3.7-browsers steps: - add_ssh_keys: @@ -350,15 +437,15 @@ jobs: - v1-dependencies-{{ checksum "doc/requirements.txt" }} # fallback to using the latest cache if no exact match is found - v1-dependencies- + - browser-tools/install-chrome + - browser-tools/install-chromedriver - run: name: install dependencies command: | cd doc - python3 -m venv venv + python -m venv venv . venv/bin/activate - npm install electron@1.8.4 - npm install orca pip install -U pip pip uninstall -y plotly pip install -r requirements.txt @@ -369,6 +456,8 @@ jobs: cd ../../../doc fi echo 'export PATH="/home/circleci/project/doc/node_modules/.bin:$PATH"' >> $BASH_ENV + npm install electron@1.8.4 + npm install orca sudo apt-get install -y poppler-utils libxtst6 xvfb libgtk2.0-0 libgconf-2-4 libnss3 libasound2 rename cd .. diff --git a/packages/python/plotly/recipe/meta.yaml b/packages/python/plotly/recipe/meta.yaml index 701dfdd89bf..775d8fe1e39 100644 --- a/packages/python/plotly/recipe/meta.yaml +++ b/packages/python/plotly/recipe/meta.yaml @@ -21,7 +21,7 @@ requirements: - python - pip - jupyterlab =3 - - nodejs + - nodejs =16 - setuptools run: - python diff --git a/packages/python/plotly/test_requirements/requirements_36_core.txt b/packages/python/plotly/test_requirements/requirements_36_core.txt index c5d8fc57034..0f02fc47bd0 100644 --- a/packages/python/plotly/test_requirements/requirements_36_core.txt +++ b/packages/python/plotly/test_requirements/requirements_36_core.txt @@ -1,3 +1,4 @@ requests==2.12.4 tenacity==6.2.0 pytest==3.5.1 +packaging From 0bf21f909c76196f24fdaf5950e3848c7019bc0f Mon Sep 17 00:00:00 2001 From: alexcjohnson Date: Wed, 3 May 2023 21:20:42 -0400 Subject: [PATCH 02/11] tweak ci config? --- .circleci/config.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2a59821d92d..ed36462fd25 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -121,6 +121,7 @@ commands: command: | npm install electron@1.8.4 npm install orca + sudo apt-get update sudo apt-get install -y poppler-utils libxtst6 xvfb libgtk2.0-0 libgconf-2-4 libnss3 libasound2 rename echo 'export PATH="/home/circleci/project/node_modules/.bin:$PATH"' >> $BASH_ENV - run: @@ -433,10 +434,7 @@ jobs: # Download and cache dependencies - restore_cache: - keys: - - v1-dependencies-{{ checksum "doc/requirements.txt" }} - # fallback to using the latest cache if no exact match is found - - v1-dependencies- + key: v1-dependencies-{{ checksum "doc/requirements.txt" }}-{{ checksum ".circleci/config.yml" }} - browser-tools/install-chrome - browser-tools/install-chromedriver @@ -446,26 +444,28 @@ jobs: cd doc python -m venv venv . venv/bin/activate - pip install -U pip + pip install --upgrade pip wheel pip uninstall -y plotly pip install -r requirements.txt if [ "${CIRCLE_BRANCH}" != "doc-prod" ]; then pip uninstall -y plotly - cd ../packages/python/plotly - pip install -e . - cd ../../../doc + pip install -e ../packages/python/plotly fi - echo 'export PATH="/home/circleci/project/doc/node_modules/.bin:$PATH"' >> $BASH_ENV + cd .. + - run: + name: Install orca + command: | npm install electron@1.8.4 npm install orca + sudo apt-get update sudo apt-get install -y poppler-utils libxtst6 xvfb libgtk2.0-0 libgconf-2-4 libnss3 libasound2 rename - cd .. + echo 'export PATH="/home/circleci/project/node_modules/.bin:$PATH"' >> $BASH_ENV - save_cache: paths: - ./doc/venv - ./doc/node_modules - key: v1-dependencies-{{ checksum "doc/requirements.txt" }} + key: v1-dependencies-{{ checksum "doc/requirements.txt" }}-{{ checksum ".circleci/config.yml" }} - run: name: make html From 4d71da659861cb7269aa03ccde0d18f8c2561d14 Mon Sep 17 00:00:00 2001 From: alexcjohnson Date: Wed, 3 May 2023 21:30:02 -0400 Subject: [PATCH 03/11] black mplexporter??? --- .../mplexporter/renderers/vega_renderer.py | 16 +++++++++++++--- .../matplotlylib/mplexporter/tests/test_basic.py | 4 ++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/python/plotly/plotly/matplotlylib/mplexporter/renderers/vega_renderer.py b/packages/python/plotly/plotly/matplotlylib/mplexporter/renderers/vega_renderer.py index d7dd171b4e2..eab02e1f329 100644 --- a/packages/python/plotly/plotly/matplotlylib/mplexporter/renderers/vega_renderer.py +++ b/packages/python/plotly/plotly/matplotlylib/mplexporter/renderers/vega_renderer.py @@ -23,8 +23,18 @@ def open_axes(self, ax, props): dict(type="y", scale="y", ticks=10), ] self.scales = [ - dict(name="x", domain=props["xlim"], type="linear", range="width",), - dict(name="y", domain=props["ylim"], type="linear", range="height",), + dict( + name="x", + domain=props["xlim"], + type="linear", + range="width", + ), + dict( + name="y", + domain=props["ylim"], + type="linear", + range="height", + ), ] def draw_line(self, data, coordinates, style, label, mplobj=None): @@ -103,7 +113,7 @@ def __init__(self, renderer): def html(self): """Build the HTML representation for IPython.""" - id = random.randint(0, 2 ** 16) + id = random.randint(0, 2**16) html = '
' % id html += "