galtimur commited on
Commit
d822266
1 Parent(s): 232f9bc

test data add

Browse files
Files changed (19) hide show
  1. data/0.json +1 -0
  2. data/1.json +0 -0
  3. data/10.json +1 -0
  4. data/11.json +1 -0
  5. data/12.json +1 -0
  6. data/13.json +1 -0
  7. data/14.json +1 -0
  8. data/15.json +1 -0
  9. data/16.json +1 -0
  10. data/17.json +1 -0
  11. data/18.json +1 -0
  12. data/2.json +1 -0
  13. data/3.json +1 -0
  14. data/4.json +1 -0
  15. data/5.json +1 -0
  16. data/6.json +1 -0
  17. data/7.json +1 -0
  18. data/8.json +1 -0
  19. data/9.json +1 -0
data/0.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"head_branch": "master", "contributor": "ftshijt", "sha_fail": "4925a8d5c47620270aba3ee5c39398abf47fb470", "sha_success": "23cb59f410a6c3caad9012f9c75a1986a21c3f1c", "language": "Python", "repo_owner": "s3prl", "repo_name": "s3prl", "workflow_name": "CI", "workflow_filename": "ci.yml", "workflow_path": ".github/workflows/ci.yml", "workflow": "name: CI\n\non:\n # Trigger the workflow on push to main or any pull request\n push:\n branches:\n - main\n pull_request:\n\njobs:\n build-and-test:\n\n strategy:\n matrix:\n os: [ubuntu-20.04]\n python-version: [3.8]\n torchaudio-version: [0.8.1, 0.9.1, 0.10.2, 0.11.0, 0.12.1]\n include:\n - os: ubuntu-20.04\n python-version: 3.7\n torchaudio-version: 0.11.0\n - os: ubuntu-20.04\n python-version: 3.9\n torchaudio-version: 0.8.1\n - os: ubuntu-20.04\n python-version: \"3.10\" # if not quoted, will be interpreted as 3.1\n torchaudio-version: 0.11.0\n\n runs-on: ${{ matrix.os }}\n\n steps:\n - uses: actions/checkout@v2\n\n - name: Set up Python ${{ matrix.python-version }}\n uses: actions/setup-python@v2\n with:\n python-version: ${{ matrix.python-version }}\n\n - name: Install Linux dependencies\n run: |\n sudo apt-get update\n sudo apt-get install -y libsndfile1-dev sox git git-lfs\n\n - name: Upgrade pip and wheel\n run: pip3 install --upgrade pip wheel\n\n - name: Install dependencies for tests\n run: pip3 install -r requirements/dev.txt\n\n - name: Check coding style by ci/format.py\n run: |\n ./ci/format.py --check\n\n # This can be very helpful for debugging\n # The action can create a SSH server for you to connect. After you\n # log into the machine hosted by GitHub, it becomes easy to debug\n # why the CI fails on a specific machine.\n\n # - name: Setup upterm session\n # uses: lhotari/action-upterm@v1\n\n - name: Run tox for common upstream\n run: |\n tox -e common_upstream-audio${{ matrix.torchaudio-version }}\n\n # Not all upstreams will be tested on CI since this will take too much time\n # To test all upstreams, run tox locally with '-e all_upstream'\n\n # - name: Run tox for all other functionalities\n # run: |\n # tox -e all_others-deps_all-audio${{ matrix.torchaudio-version }}\n", "logs": "common_upstream-audio0.11.0 create: /home/runner/work/s3prl/s3prl/.tox/common_upstream-audio0.11.0\ncommon_upstream-audio0.11.0 inst: /home/runner/work/s3prl/s3prl/.tox/.tmp/package/1/s3prl-0.4.10.zip\ncommon_upstream-audio0.11.0 installed: antlr4-python3-runtime==4.9.3,certifi==2023.7.22,charset-normalizer==3.3.0,filelock==3.12.2,fsspec==2023.1.0,huggingface-hub==0.16.4,idna==3.4,importlib-metadata==6.7.0,numpy==1.21.6,nvidia-cublas-cu11==11.10.3.66,nvidia-cuda-nvrtc-cu11==11.7.99,nvidia-cuda-runtime-cu11==11.7.99,nvidia-cudnn-cu11==8.5.0.96,omegaconf==2.3.0,packaging==23.2,protobuf==3.20.3,PyYAML==6.0.1,regex==2023.10.3,requests==2.31.0,s3prl @ file:///home/runner/work/s3prl/s3prl/.tox/.tmp/package/1/s3prl-0.4.10.zip#sha256=e8442f550b5e81b813e520dc03ed1efec5e786eb46d6d10017560df6ccdfcc5d,safetensors==0.3.3,tokenizers==0.13.3,torch==1.13.1,torchaudio==0.13.1,tqdm==4.66.1,transformers==4.30.2,typing_extensions==4.7.1,urllib3==2.0.6,zipp==3.15.0\ncommon_upstream-audio0.11.0 run-test-pre: PYTHONHASHSEED='1167914577'\ncommon_upstream-audio0.11.0 run-test: commands[0] | /home/runner/work/s3prl/s3prl/.tox/common_upstream-audio0.11.0/bin/python -m pip install torchaudio==0.11.0\nCollecting torchaudio==0.11.0\n Downloading torchaudio-0.11.0-cp37-cp37m-manylinux1_x86_64.whl (2.9 MB)\n \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 2.9/2.9 MB 45.2 MB/s eta 0:00:00\nCollecting torch==1.11.0 (from torchaudio==0.11.0)\n Downloading torch-1.11.0-cp37-cp37m-manylinux1_x86_64.whl (750.6 MB)\n \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 750.6/750.6 MB 1.2 MB/s eta 0:00:00\nRequirement already satisfied: typing-extensions in /home/runner/work/s3prl/s3prl/.tox/common_upstream-audio0.11.0/lib/python3.7/site-packages (from torch==1.11.0->torchaudio==0.11.0) (4.7.1)\nInstalling collected packages: torch, torchaudio\n Attempting uninstall: torch\n Found existing installation: torch 1.13.1\n Uninstalling torch-1.13.1:\n Successfully uninstalled torch-1.13.1\n Attempting uninstall: torchaudio\n Found existing installation: torchaudio 0.13.1\n Uninstalling torchaudio-0.13.1:\n Successfully uninstalled torchaudio-0.13.1\nSuccessfully installed torch-1.11.0 torchaudio-0.11.0\n\n[notice] A new release of pip is available: 23.1 -> 23.2.1\n[notice] To update, run: pip install --upgrade pip\ncommon_upstream-audio0.11.0 run-test: commands[1] | /home/runner/work/s3prl/s3prl/.tox/common_upstream-audio0.11.0/bin/python -c 'import s3prl; from s3prl.nn import S3PRLUpstream;'\nTraceback (most recent call last):\n File \"/home/runner/work/s3prl/s3prl/.tox/common_upstream-audio0.11.0/lib/python3.7/site-packages/s3prl/upstream/espnet_hubert/expert.py\", line 12, in <module>\n from espnet2.tasks.hubert import HubertTask\nModuleNotFoundError: No module named 'espnet2'\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File \"<string>\", line 1, in <module>\n File \"/home/runner/work/s3prl/s3prl/.tox/common_upstream-audio0.11.0/lib/python3.7/site-packages/s3prl/nn/__init__.py\", line 12, in <module>\n from .upstream import Featurizer, S3PRLUpstream\n File \"/home/runner/work/s3prl/s3prl/.tox/common_upstream-audio0.11.0/lib/python3.7/site-packages/s3prl/nn/upstream.py\", line 14, in <module>\n from s3prl import hub\n File \"/home/runner/work/s3prl/s3prl/.tox/common_upstream-audio0.11.0/lib/python3.7/site-packages/s3prl/hub.py\", line 14, in <module>\n from s3prl.upstream.espnet_hubert.hubconf import *\n File \"/home/runner/work/s3prl/s3prl/.tox/common_upstream-audio0.11.0/lib/python3.7/site-packages/s3prl/upstream/espnet_hubert/hubconf.py\", line 3, in <module>\n from .expert import UpstreamExpert as _UpstreamExpert\n File \"/home/runner/work/s3prl/s3prl/.tox/common_upstream-audio0.11.0/lib/python3.7/site-packages/s3prl/upstream/espnet_hubert/expert.py\", line 15, in <module>\n logger.warnning(\"ESPnet is not installed, cannot use espnet_hubert upstream\")\nAttributeError: 'Logger' object has no attribute 'warnning'\nERROR: InvocationError for command /home/runner/work/s3prl/s3prl/.tox/common_upstream-audio0.11.0/bin/python -c 'import s3prl; from s3prl.nn import S3PRLUpstream;' (exited with code 1)\n___________________________________ summary ____________________________________\nERROR: common_upstream-audio0.11.0: commands failed\n##[error]Process completed with exit code 1.\n", "diff": "diff --git a/s3prl/upstream/espnet_hubert/expert.py b/s3prl/upstream/espnet_hubert/expert.py\nindex b76fcc48..27694982 100644\n--- a/s3prl/upstream/espnet_hubert/expert.py\n+++ b/s3prl/upstream/espnet_hubert/expert.py\n@@ -12,7 +12,7 @@ try:\n from espnet2.tasks.hubert import HubertTask\n except ModuleNotFoundError:\n HuBERTTask = None\n- logger.warnning(\"ESPnet is not installed, cannot use espnet_hubert upstream\")\n+ logger.warning(\"ESPnet is not installed, cannot use espnet_hubert upstream\")\n \n \n class UpstreamExpert(torch.nn.Module):\n"}
data/1.json ADDED
The diff for this file is too large to render. See raw diff
 
data/10.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"head_branch": "master", "contributor": "keras-team", "sha_fail": "d043c7c56796b9f37e7daa74aeebace78206ae78", "sha_success": "879a1942e5aa364cf31e8d65cdf4e3720209b03f", "language": "Python", "repo_owner": "keras-team", "repo_name": "keras", "workflow_name": "Tests", "workflow_filename": "actions.yml", "workflow_path": ".github/workflows/actions.yml", "workflow": "name: Tests\n\non:\n push:\n branches: [ master ]\n pull_request:\n release:\n types: [created]\n\npermissions:\n contents: read\n\njobs:\n build:\n strategy:\n fail-fast: false\n matrix:\n python-version: [3.9]\n backend: [tensorflow, jax, torch, numpy]\n name: Run tests\n runs-on: ubuntu-latest\n env:\n PYTHON: ${{ matrix.python-version }}\n KERAS_BACKEND: ${{ matrix.backend }}\n steps:\n - uses: actions/checkout@v3\n - name: Check for changes in keras/applications\n uses: dorny/paths-filter@v2\n id: filter\n with:\n filters: |\n applications:\n - 'keras/applications/**'\n - name: Set up Python\n uses: actions/setup-python@v4\n with:\n python-version: ${{ matrix.python-version }}\n - name: Get pip cache dir\n id: pip-cache\n run: |\n python -m pip install --upgrade pip setuptools\n echo \"dir=$(pip cache dir)\" >> $GITHUB_OUTPUT\n - name: pip cache\n uses: actions/cache@v3\n with:\n path: ${{ steps.pip-cache.outputs.dir }}\n key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements.txt') }}\n - name: Install dependencies\n run: |\n pip install -r requirements.txt --progress-bar off --upgrade\n pip install -e \".\" --progress-bar off --upgrade\n - name: Test applications with pytest\n if: ${{ steps.filter.outputs.applications == 'true' }}\n run: |\n pytest keras/applications --cov=keras.applications\n coverage xml --include='keras/applications/*' -o apps-coverage.xml\n - name: Codecov keras.applications\n if: ${{ steps.filter.outputs.applications == 'true' }}\n uses: codecov/codecov-action@v3\n with:\n env_vars: PYTHON,KERAS_BACKEND\n flags: keras.applications,keras.applications-${{ matrix.backend }}\n files: apps-coverage.xml\n fail_ci_if_error: true\n - name: Test with pytest\n run: |\n pytest keras --ignore keras/applications --cov=keras\n coverage xml --omit='keras/applications/*' -o core-coverage.xml\n - name: Codecov keras\n uses: codecov/codecov-action@v3\n with:\n env_vars: PYTHON,KERAS_BACKEND\n flags: keras,keras-${{ matrix.backend }}\n files: core-coverage.xml\n fail_ci_if_error: true\n\n format:\n name: Check the code format\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@v3\n - name: Set up Python 3.9\n uses: actions/setup-python@v4\n with:\n python-version: '3.9'\n - name: Get pip cache dir\n id: pip-cache\n run: |\n python -m pip install --upgrade pip setuptools\n echo \"dir=$(pip cache dir)\" >> $GITHUB_OUTPUT\n - name: pip cache\n uses: actions/cache@v3\n with:\n path: ${{ steps.pip-cache.outputs.dir }}\n key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements.txt') }}\n - name: Install dependencies\n run: |\n pip install -r requirements.txt --progress-bar off --upgrade\n pip install -e \".\" --progress-bar off --upgrade\n - name: Lint\n run: bash shell/lint.sh\n", "logs": "keras/testing/test_utils.py 11 1 4 1 87%\nkeras/trainers/__init__.py 0 0 0 0 100%\nkeras/trainers/compile_utils.py 356 54 281 39 81%\nkeras/trainers/data_adapters/__init__.py 0 0 0 0 100%\nkeras/trainers/data_adapters/array_data_adapter.py 141 19 58 11 84%\nkeras/trainers/data_adapters/data_adapter.py 13 0 0 0 100%\nkeras/trainers/data_adapters/data_adapter_utils.py 92 21 61 13 73%\nkeras/trainers/data_adapters/generator_data_adapter.py 41 3 8 3 88%\nkeras/trainers/data_adapters/py_dataset_adapter.py 252 49 80 17 76%\nkeras/trainers/data_adapters/tf_dataset_adapter.py 47 0 20 0 100%\nkeras/trainers/data_adapters/torch_data_adapter.py 46 3 10 3 89%\nkeras/trainers/epoch_iterator.py 105 13 72 13 83%\nkeras/trainers/trainer.py 193 23 89 14 84%\nkeras/utils/__init__.py 24 0 0 0 100%\nkeras/utils/argument_validation.py 43 10 26 5 78%\nkeras/utils/audio_dataset_utils.py 87 16 52 4 83%\nkeras/utils/backend_utils.py 37 6 12 3 78%\nkeras/utils/code_stats.py 40 3 34 2 91%\nkeras/utils/dataset_utils.py 286 61 202 45 74%\nkeras/utils/dtype_utils.py 25 0 16 0 100%\nkeras/utils/file_utils.py 221 52 129 23 71%\nkeras/utils/image_dataset_utils.py 91 6 48 6 90%\nkeras/utils/image_utils.py 149 73 80 13 45%\nkeras/utils/io_utils.py 34 0 10 0 100%\nkeras/utils/jax_utils.py 7 3 4 1 45%\nkeras/utils/model_visualization.py 193 169 90 0 8%\nkeras/utils/module_utils.py 32 1 6 1 95%\nkeras/utils/naming.py 34 1 8 1 95%\nkeras/utils/nest.py 42 9 18 3 77%\nkeras/utils/numerical_utils.py 58 4 26 5 89%\nkeras/utils/progbar.py 132 25 60 9 78%\nkeras/utils/python_utils.py 62 5 28 4 90%\nkeras/utils/rng_utils.py 16 1 6 3 82%\nkeras/utils/sequence_utils.py 41 8 24 6 78%\nkeras/utils/shape_utils.py 15 1 19 1 94%\nkeras/utils/summary_utils.py 212 39 116 18 77%\nkeras/utils/text_dataset_utils.py 68 4 40 5 90%\nkeras/utils/tf_utils.py 68 32 38 6 53%\nkeras/utils/timeseries_dataset_utils.py 62 4 48 5 92%\nkeras/utils/torch_utils.py 23 2 6 1 90%\nkeras/utils/traceback_utils.py 107 79 48 1 19%\nkeras/utils/tracking.py 97 10 54 5 82%\nkeras/version.py 1 0 0 0 100%\n----------------------------------------------------------------------------------------------\nTOTAL 34213 12330 13281 1443 62%\n\n=========================== short test summary info ============================\nFAILED keras/callbacks/model_checkpoint_test.py::ModelCheckpointTest::test_model_checkpoint_loading - ValueError: Arguments `target` and `output` must have the same shape. Received: target.shape=torch.Size([5, 1]), output.shape=torch.Size([5, 2])\n====== 1 failed, 2900 passed, 306 skipped, 1 xpassed in 69.52s (0:01:09) =======\n##[error]Process completed with exit code 1.\n", "diff": "diff --git a/keras/callbacks/model_checkpoint_test.py b/keras/callbacks/model_checkpoint_test.py\nindex bea73de7b8..fbc669cebc 100644\n--- a/keras/callbacks/model_checkpoint_test.py\n+++ b/keras/callbacks/model_checkpoint_test.py\n@@ -18,9 +18,9 @@ try:\n except ImportError:\n h5py = None\n \n-TRAIN_SAMPLES = 10\n-TEST_SAMPLES = 10\n-NUM_CLASSES = 2\n+TRAIN_SAMPLES = 30\n+TEST_SAMPLES = 30\n+NUM_CLASSES = 3\n INPUT_DIM = 3\n NUM_HIDDEN = 5\n BATCH_SIZE = 5\n@@ -203,7 +203,7 @@ class ModelCheckpointTest(testing.TestCase):\n model.fit(\n x_train,\n y_train,\n- batch_size=2, # 5 batches / epoch, so should backup every 3 epochs\n+ batch_size=6, # 5 batches / epoch, so should backup every 3 epochs\n validation_data=(x_test, y_test),\n callbacks=cbks,\n epochs=10,\n@@ -236,7 +236,7 @@ class ModelCheckpointTest(testing.TestCase):\n model.fit(\n x_train,\n y_train,\n- batch_size=2,\n+ batch_size=6,\n validation_data=(x_test, y_test),\n callbacks=cbks,\n epochs=10,\n@@ -288,7 +288,7 @@ class ModelCheckpointTest(testing.TestCase):\n model.fit(\n x_train,\n y_train,\n- batch_size=5,\n+ batch_size=15,\n validation_data=(x_test, y_test),\n callbacks=cbks,\n epochs=5,\n@@ -318,7 +318,7 @@ class ModelCheckpointTest(testing.TestCase):\n model.fit(\n x_train,\n y_train,\n- batch_size=5,\n+ batch_size=15,\n validation_data=(x_test, y_test),\n callbacks=cbks,\n epochs=5,\n"}
data/11.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"head_branch": "py3.12-fstring-extraction", "contributor": "encukou", "sha_fail": "be26d03a477a8c7a3919e2ba00121a0f7954bdb5", "sha_success": "1f06b3616f44bbd87a3c9df274225d431c01ae6e", "language": "Python", "repo_owner": "python-babel", "repo_name": "babel", "workflow_name": "Test", "workflow_filename": "test.yml", "workflow_path": ".github/workflows/test.yml", "workflow": "name: Test\n\non:\n push:\n branches:\n - master\n - '*-maint'\n pull_request:\n branches:\n - master\n - '*-maint'\n\njobs:\n lint:\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@v3\n - uses: pre-commit/[email protected]\n test:\n runs-on: ${{ matrix.os }}\n strategy:\n matrix:\n os: [\"ubuntu-20.04\", \"windows-2022\", \"macos-11\"]\n python-version: [\"3.7\", \"3.8\", \"3.9\", \"3.10\", \"3.11\", \"pypy-3.7\"]\n env:\n BABEL_CLDR_NO_DOWNLOAD_PROGRESS: \"1\"\n BABEL_CLDR_QUIET: \"1\"\n steps:\n - uses: actions/checkout@v3\n - uses: actions/cache@v3\n with:\n path: cldr\n key: cldr-${{ hashFiles('scripts/*cldr*') }}\n - name: Set up Python ${{ matrix.python-version }}\n uses: actions/setup-python@v4\n with:\n python-version: ${{ matrix.python-version }}\n cache: \"pip\"\n cache-dependency-path: \"**/setup.py\"\n - name: Install dependencies\n run: |\n python -m pip install --upgrade pip setuptools wheel\n python -m pip install 'tox~=4.0' 'tox-gh-actions~=3.0'\n - name: Run test via Tox\n run: tox --skip-missing-interpreters\n env:\n COVERAGE_XML_PATH: ${{ runner.temp }}\n - uses: codecov/codecov-action@v3\n with:\n directory: ${{ runner.temp }}\n", "logs": "shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}\n##[endgroup]\n[INFO]\u001b[m Initializing environment for https://github.com/astral-sh/ruff-pre-commit.\n[INFO]\u001b[m Initializing environment for https://github.com/pre-commit/pre-commit-hooks.\n[INFO]\u001b[m Installing environment for https://github.com/astral-sh/ruff-pre-commit.\n[INFO]\u001b[m Once installed this environment will be reused.\n[INFO]\u001b[m This may take a few minutes...\n[INFO]\u001b[m Installing environment for https://github.com/pre-commit/pre-commit-hooks.\n[INFO]\u001b[m Once installed this environment will be reused.\n[INFO]\u001b[m This may take a few minutes...\nruff.....................................................................\u001b[41mFailed\u001b[m\n\u001b[2m- hook id: ruff\u001b[m\n\u001b[2m- files were modified by this hook\u001b[m\n\nFound 1 error (1 fixed, 0 remaining).\n\ncheck for added large files..............................................\u001b[42mPassed\u001b[m\ncheck docstring is first.................................................\u001b[42mPassed\u001b[m\ncheck json...........................................(no files to check)\u001b[46;30mSkipped\u001b[m\ncheck yaml...............................................................\u001b[42mPassed\u001b[m\ndebug statements (python)................................................\u001b[42mPassed\u001b[m\nfix end of files.........................................................\u001b[42mPassed\u001b[m\npython tests naming......................................................\u001b[42mPassed\u001b[m\nfix requirements.txt.....................................................\u001b[42mPassed\u001b[m\ntrim trailing whitespace.................................................\u001b[42mPassed\u001b[m\npre-commit hook(s) made changes.\nIf you are seeing this message in CI, reproduce locally with: `pre-commit run --all-files`.\nTo run `pre-commit` as part of git workflow, use `pre-commit install`.\nAll changes made by hooks:\n\u001b[1mdiff --git a/babel/messages/extract.py b/babel/messages/extract.py\u001b[m\n\u001b[1mindex 5b67d2b..2f02638 100644\u001b[m\n\u001b[1m--- a/babel/messages/extract.py\u001b[m\n\u001b[1m+++ b/babel/messages/extract.py\u001b[m\n\u001b[36m@@ -21,6 +21,7 @@\u001b[m \u001b[mimport ast\u001b[m\n import io\u001b[m\n import os\u001b[m\n import sys\u001b[m\n\u001b[32m+\u001b[m\u001b[32mimport tokenize\u001b[m\n from collections.abc import (\u001b[m\n Callable,\u001b[m\n Collection,\u001b[m\n\u001b[36m@@ -33,7 +34,6 @@\u001b[m \u001b[mfrom os.path import relpath\u001b[m\n from textwrap import dedent\u001b[m\n from tokenize import COMMENT, NAME, OP, STRING, generate_tokens\u001b[m\n from typing import TYPE_CHECKING, Any\u001b[m\n\u001b[31m-import tokenize\u001b[m\n \u001b[m\n from babel.util import parse_encoding, parse_future_flags, pathmatch\u001b[m\n \u001b[m\n##[error]Process completed with exit code 1.\n", "diff": "diff --git a/babel/messages/extract.py b/babel/messages/extract.py\nindex 5b67d2b..2f02638 100644\n--- a/babel/messages/extract.py\n+++ b/babel/messages/extract.py\n@@ -21,6 +21,7 @@ import ast\n import io\n import os\n import sys\n+import tokenize\n from collections.abc import (\n Callable,\n Collection,\n@@ -33,7 +34,6 @@ from os.path import relpath\n from textwrap import dedent\n from tokenize import COMMENT, NAME, OP, STRING, generate_tokens\n from typing import TYPE_CHECKING, Any\n-import tokenize\n \n from babel.util import parse_encoding, parse_future_flags, pathmatch\n \n"}
data/12.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"head_branch": "vizrank-2.0", "contributor": "janezd", "sha_fail": "1fef7bf674f2441de7fec54c3b6017d622722c48", "sha_success": "e8f13f71dd1bd19ae107057f850e8f1195478297", "language": "Python", "repo_owner": "biolab", "repo_name": "orange3", "workflow_name": "Documentation workflow", "workflow_filename": "doc.yml", "workflow_path": ".github/workflows/doc.yml", "workflow": "name: Documentation workflow\n\non:\n push:\n branches:\n - master\n pull_request:\n branches:\n - master\n\njobs:\n build:\n runs-on: ${{ matrix.os }}\n strategy:\n fail-fast: False\n matrix:\n python: [3.9]\n os: [ubuntu-22.04]\n\n steps:\n - uses: actions/checkout@v2\n - name: Setup Python\n uses: actions/setup-python@v1\n with:\n python-version: ${{ matrix.python }}\n\n - name: Install linux system dependencies\n run: sudo apt-get install -y libxkbcommon-x11-0\n\n - name: Install Tox\n run: pip install tox\n\n - name: Build documentation\n run: tox -e build_doc\n env:\n QT_QPA_PLATFORM: offscreen\n", "logs": "- \"keywords\": [\n- \"sieve\",\n- \"diagram\"\n- ]\n- },\n- {\n- \"text\": \"Mosaic Display\",\n- \"doc\": \"visual-programming/source/widgets/visualize/mosaicdisplay.md\",\n- \"icon\": \"../Orange/widgets/visualize/icons/MosaicDisplay.svg\",\n- \"background\": \"#FFB7B1\",\n- \"keywords\": [\n- \"mosaic\",\n- \"display\"\n- ]\n- },\n {\n \"text\": \"FreeViz\",\n \"doc\": \"visual-programming/source/widgets/visualize/freeviz.md\",\n@@ -492,26 +462,6 @@\n \"viz\"\n ]\n },\n- {\n- \"text\": \"Linear Projection\",\n- \"doc\": \"visual-programming/source/widgets/visualize/linearprojection.md\",\n- \"icon\": \"../Orange/widgets/visualize/icons/LinearProjection.svg\",\n- \"background\": \"#FFB7B1\",\n- \"keywords\": [\n- \"linear\",\n- \"projection\"\n- ]\n- },\n- {\n- \"text\": \"Radviz\",\n- \"doc\": \"visual-programming/source/widgets/visualize/radviz.md\",\n- \"icon\": \"../Orange/widgets/visualize/icons/Radviz.svg\",\n- \"background\": \"#FFB7B1\",\n- \"keywords\": [\n- \"radviz\",\n- \"viz\"\n- ]\n- },\n {\n \"text\": \"Heat Map\",\n \"doc\": \"visual-programming/source/widgets/visualize/heatmap.md\",\nbuild_doc: exit 1 (24.95 seconds) /home/runner/work/orange3/orange3> bash doc/build_doc.sh pid=2358\n.pkg: _exit> python /opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/pyproject_api/_backend.py True setuptools.build_meta\n build_doc: FAIL code 1 (140.40=setup[113.93]+cmd[1.12,0.41,24.95] seconds)\n evaluation failed :( (140.58 seconds)\n##[error]Process completed with exit code 1.\n", "diff": "diff --git a/Orange/widgets/visualize/utils/tests/test_vizrank.py b/Orange/widgets/visualize/utils/tests/test_vizrank.py\nnew file mode 100644\nindex 000000000..ae0fda3d3\n--- /dev/null\n+++ b/Orange/widgets/visualize/utils/tests/test_vizrank.py\n@@ -0,0 +1,304 @@\n+import unittest\n+from AnyQt.QtTest import QSignalSpy\n+from unittest.mock import patch, Mock\n+\n+from AnyQt.QtCore import Qt, pyqtSignal as Signal\n+from AnyQt.QtWidgets import QDialog\n+\n+from orangewidget.tests.base import GuiTest\n+from Orange.data import Table, Domain, ContinuousVariable\n+from Orange.widgets.visualize.utils.vizrank import (\n+ RunState, VizRankMixin,\n+ VizRankDialog, VizRankDialogAttrs, VizRankDialogAttrPair,\n+ VizRankDialogNAttrs\n+)\n+\n+\n+class MockDialog(VizRankDialog):\n+ class Task:\n+ interrupt = False\n+ set_partial_result = Mock()\n+\n+ def is_interruption_requested(self):\n+ return self.interrupt\n+\n+ task = Task()\n+\n+ def __init__(self, parent=None):\n+ super().__init__(parent)\n+\n+ def start(self, func, *args):\n+ func(*args, self.task)\n+\n+ def state_generator(self):\n+ return range(10)\n+\n+ def state_count(self):\n+ return 10\n+\n+ def compute_score(self, state):\n+ return 10 * (state % 2) + state // 2 if state != 3 else None\n+\n+ row_for_state = Mock()\n+\n+\n+class TestVizRankDialog(GuiTest):\n+\n+ @patch.object(VizRankDialog, \"start\")\n+ @patch.object(VizRankDialog, \"prepare_run\",\n+ new=lambda self: setattr(self.run_state,\n+ \"state\", RunState.Ready))\n+ def test_init_and_button(self, run_vizrank):\n+ dialog = VizRankDialog(None)\n+ self.assertEqual(dialog.run_state.state, RunState.Initialized)\n+ self.assertEqual(dialog.button.text(), dialog.button_labels[RunState.Initialized])\n+ dialog.button.click()\n+ run_vizrank.assert_called_once()\n+ self.assertEqual(dialog.run_state.state, RunState.Running)\n+ self.assertEqual(dialog.button.text(), dialog.button_labels[RunState.Running])\n+\n+ dialog.button.click()\n+ run_vizrank.assert_called_once()\n+ self.assertEqual(dialog.run_state.state, RunState.Paused)\n+ self.assertEqual(dialog.button.text(), dialog.button_labels[RunState.Paused])\n+\n+ dialog.button.click()\n+ self.assertEqual(run_vizrank.call_count, 2)\n+ self.assertEqual(dialog.run_state.state, RunState.Running)\n+ self.assertEqual(dialog.button.text(), dialog.button_labels[RunState.Running])\n+\n+ def test_running(self):\n+ dialog = MockDialog()\n+ dialog.start_computation()\n+ result = dialog.task.set_partial_result.call_args[0][0]\n+ self.assertEqual(result.scores, [0, 1, 2, 3, 4, 10, 12, 13, 14])\n+ self.assertEqual(result.completed_states, 10)\n+\n+ dialog.on_done(result)\n+ self.assertEqual(dialog.run_state.state, RunState.Done)\n+ self.assertEqual(dialog.button.text(), dialog.button_labels[RunState.Done])\n+ self.assertFalse(dialog.button.isEnabled())\n+\n+\n+ def test_running(self):\n+ dialog = MockDialog()\n+ dialog.task.interrupt = True\n+ dialog.start_computation()\n+ result = dialog.task.set_partial_result.call_args[0][0]\n+ self.assertEqual(result.scores, [0])\n+ self.assertEqual(result.completed_states, 1)\n+\n+\n+class TestVizRankMixin(GuiTest):\n+ def setUp(self):\n+ self.mock_dialog = Mock()\n+ self.mock_dialog.__name__ = \"foo\"\n+\n+ class Widget(QDialog, VizRankMixin(self.mock_dialog)):\n+ pass\n+\n+ self.widget = Widget()\n+\n+ def test_button(self):\n+ widget, dialog = self.widget, self.mock_dialog\n+\n+ widget.start_vizrank = Mock()\n+ widget.raise_vizrank = Mock()\n+\n+ button = widget.vizrank_button(\"Let's Vizrank\")\n+ self.assertEqual(button.text(), \"Let's Vizrank\")\n+ self.assertFalse(button.isEnabled())\n+\n+ widget.disable_vizrank(\"Too lazy to rank to-day.\")\n+ self.assertEqual(button.text(), \"Let's Vizrank\")\n+ self.assertEqual(button.toolTip(), \"Too lazy to rank to-day.\")\n+ self.assertFalse(button.isEnabled())\n+ dialog.assert_not_called()\n+\n+ widget.init_vizrank()\n+ dialog.assert_called_once()\n+ dialog.reset_mock()\n+ self.assertEqual(button.text(), \"Let's Vizrank\")\n+ self.assertEqual(button.toolTip(), \"\")\n+ self.assertTrue(button.isEnabled())\n+\n+ widget.disable_vizrank(\"Too lazy to rank to-day.\")\n+ self.assertEqual(button.text(), \"Let's Vizrank\")\n+ self.assertEqual(button.toolTip(), \"Too lazy to rank to-day.\")\n+ self.assertFalse(button.isEnabled())\n+ dialog.assert_not_called()\n+\n+ widget.init_vizrank()\n+ dialog.assert_called_once() # new data, new dialog!\n+ dialog.reset_mock()\n+\n+ button.click()\n+ widget.start_vizrank.assert_called_once()\n+ widget.raise_vizrank.assert_called_once()\n+\n+ def test_no_button(self):\n+ widget, dialog = self.widget, self.mock_dialog\n+\n+ widget.disable_vizrank(\"Too lazy to rank to-day.\")\n+ dialog.assert_not_called()\n+\n+ widget.init_vizrank()\n+ dialog.assert_called_once()\n+ dialog.reset_mock()\n+ widget.disable_vizrank(\"Too lazy to rank to-day.\")\n+\n+ widget.disable_vizrank(\"Too lazy to rank to-day.\")\n+ dialog.assert_not_called()\n+\n+ widget.init_vizrank()\n+ dialog.assert_called_once()\n+ dialog.reset_mock()\n+ widget.disable_vizrank(\"Too lazy to rank to-day.\")\n+\n+ def test_init_vizrank(self):\n+ widget, dialog = self.widget, self.mock_dialog\n+ a, b = Mock(), Mock()\n+ widget.init_vizrank(a, b)\n+ dialog.assert_called_with(widget, a, b)\n+\n+\n+class TestVizRankDialogWithData(GuiTest):\n+ def setUp(self):\n+ self.attrs = tuple(ContinuousVariable(n) for n in \"abcdef\")\n+ self.class_var = ContinuousVariable(\"y\")\n+ self.variables = (*self.attrs, self.class_var)\n+ self.metas = tuple(ContinuousVariable(n) for n in \"mn\")\n+ self.data = Table.from_list(\n+ Domain(self.attrs, self.class_var, self.metas),\n+ [[0] * 9])\n+\n+\n+class TestVizRankDialogAttrs(TestVizRankDialogWithData):\n+ def test_init(self):\n+ dialog = VizRankDialogAttrs(None, self.data)\n+ self.assertIs(dialog.data, self.data)\n+ self.assertEqual(dialog.attrs, self.variables)\n+ self.assertIsNone(dialog.attr_color)\n+\n+ dialog = VizRankDialogAttrs(None, self.data, self.attrs[1:])\n+ self.assertIs(dialog.data, self.data)\n+ self.assertEqual(dialog.attrs, self.attrs[1:])\n+ self.assertIsNone(dialog.attr_color)\n+\n+ dialog = VizRankDialogAttrs(None, self.data, self.attrs[1:], self.attrs[3])\n+ self.assertIs(dialog.data, self.data)\n+ self.assertEqual(dialog.attrs, self.attrs[1:])\n+ self.assertIs(dialog.attr_color, self.attrs[3])\n+\n+ def test_attr_order(self):\n+ dialog = VizRankDialogAttrs(None, self.data)\n+ self.assertEqual(dialog.attr_order, self.variables)\n+\n+ class OrderedAttr(VizRankDialogAttrs):\n+ call_count = 0\n+\n+ def score_attributes(self):\n+ self.call_count += 1\n+ return self.attrs[::-1]\n+\n+ dialog = OrderedAttr(None, self.data)\n+ self.assertEqual(dialog.attr_order, self.variables[::-1])\n+ self.assertEqual(dialog.attr_order, self.variables[::-1])\n+ self.assertEqual(dialog.call_count, 1)\n+\n+ def test_row_for_state(self):\n+ dialog = VizRankDialogAttrs(None, self.data)\n+ item = dialog.row_for_state(0, [3, 1])[0]\n+ self.assertEqual(item.data(Qt.DisplayRole), \"d, b\")\n+ self.assertEqual(item.data(dialog._AttrRole), [self.attrs[3], self.attrs[1]])\n+\n+ dialog.sort_names_in_row = True\n+ item = dialog.row_for_state(0, [3, 1])[0]\n+ self.assertEqual(item.data(Qt.DisplayRole), \"b, d\")\n+ self.assertEqual(item.data(dialog._AttrRole), [self.attrs[3], self.attrs[1]])\n+\n+ def test_autoselect(self):\n+ widget = VizRankMixin()\n+ dialog = VizRankDialogAttrs(widget, self.data)\n+ for state in ([0, 1], [0, 3], [1, 3], [3, 1]):\n+ dialog.rank_model.appendRow(dialog.row_for_state(0, state))\n+\n+ widget.vizrankAutoSelect.emit([self.attrs[1], self.attrs[3]])\n+ selection = dialog.rank_table.selectedIndexes()\n+ self.assertEqual(len(selection), 1)\n+ self.assertEqual(selection[0].row(), 2)\n+\n+ widget.vizrankAutoSelect.emit([self.attrs[3], self.attrs[1]])\n+ selection = dialog.rank_table.selectedIndexes()\n+ self.assertEqual(len(selection), 1)\n+ self.assertEqual(selection[0].row(), 3)\n+\n+ widget.vizrankAutoSelect.emit([self.attrs[3], self.attrs[0]])\n+ selection = dialog.rank_table.selectedIndexes()\n+ self.assertEqual(len(selection), 0)\n+\n+\n+class TestVizRankDialogAttrPair(TestVizRankDialogWithData):\n+ def test_count_and_generator(self):\n+ dialog = VizRankDialogAttrPair(None, self.data, self.attrs[:5])\n+ self.assertEqual(dialog.state_count(), 5 * 4 / 2)\n+ self.assertEqual(\n+ list(dialog.state_generator()),\n+ [(0, 1), (0, 2), (1, 2), (0, 3), (1, 3), (2, 3),\n+ (0, 4), (1, 4), (2, 4), (3, 4)])\n+\n+\n+class TestVizRankDialogNAttrs(TestVizRankDialogWithData):\n+ def test_spin_interaction(self):\n+ dialog = VizRankDialogNAttrs(None,\n+ self.data, self.attrs[:5], None, 4)\n+ spy = QSignalSpy(dialog.runStateChanged)\n+\n+ with patch.object(\n+ VizRankDialog, \"pause_computation\",\n+ side_effect=lambda: dialog.set_run_state(RunState.Paused)):\n+ with patch.object(\n+ VizRankDialog, \"start_computation\",\n+ side_effect=lambda: dialog.set_run_state(RunState.Running)):\n+ spin = dialog.n_attrs_spin\n+ self.assertEqual(spin.value(), 4)\n+ self.assertEqual(spin.maximum(), 5)\n+\n+ dialog.start_computation()\n+ self.assertEqual(dialog.run_state.state, RunState.Running)\n+ self.assertEqual(spy[-1][1][\"n_attrs\"], 4)\n+\n+ spin.setValue(3)\n+ # Ranking must be paused\n+ self.assertEqual(dialog.run_state.state, RunState.Paused)\n+ # Label should be changed to \"restart with ...\"\n+ self.assertNotEqual(dialog.button.text(),\n+ dialog.button_labels[RunState.Paused])\n+\n+ spin.setValue(4)\n+ self.assertEqual(dialog.run_state.state, RunState.Paused)\n+ # Label should be reset to \"Continue\"\n+ self.assertEqual(dialog.button.text(),\n+ dialog.button_labels[RunState.Paused])\n+\n+ # Remove the side-effect so that we see that start_computation\n+ # resets the state to Initialized before calling super\n+ with patch.object(VizRankDialog, \"start_computation\"):\n+ dialog.start_computation()\n+ self.assertEqual(spy[-1][1][\"n_attrs\"], 4)\n+ # Here, the state must not be reset to Initialized\n+ self.assertEqual(dialog.run_state.state, RunState.Paused)\n+ # But now manually set it to appropriate state\n+ dialog.set_run_state(RunState.Running)\n+\n+ spin.setValue(3)\n+ self.assertEqual(dialog.run_state.state, RunState.Paused)\n+ self.assertNotEqual(dialog.button.text(), dialog.button_labels[RunState.Paused])\n+\n+ dialog.start_computation()\n+ self.assertEqual(dialog.run_state.state, RunState.Initialized)\n+ self.assertEqual(spy[-1][1][\"n_attrs\"], 3)\n+\n+\n+if __name__ == \"__main__\":\n+ unittest.main()\n\\ndiff --git a/Orange/widgets/visualize/utils/vizrank.py b/Orange/widgets/visualize/utils/vizrank.py\nnew file mode 100644\nindex 000000000..bbdaff0af\n--- /dev/null\n+++ b/Orange/widgets/visualize/utils/vizrank.py\n@@ -0,0 +1,743 @@\n+from bisect import bisect_left\n+from queue import Queue, Empty\n+from types import SimpleNamespace as namespace\n+from typing import Optional, Iterable, List, Callable, Iterator, Any, Type\n+from threading import Timer\n+\n+from AnyQt.QtCore import Qt, QSize, QSortFilterProxyModel, pyqtSignal as Signal\n+from AnyQt.QtGui import (\n+ QStandardItemModel, QStandardItem, QShowEvent, QCloseEvent, QHideEvent)\n+from AnyQt.QtWidgets import (\n+ QTableView, QDialog, QVBoxLayout, QLineEdit, QPushButton)\n+\n+from Orange.widgets import gui\n+from Orange.widgets.gui import HorizontalGridDelegate, TableBarItem\n+from Orange.widgets.utils.concurrent import ConcurrentMixin, TaskState\n+from Orange.widgets.utils.progressbar import ProgressBarMixin\n+\n+\n+class Result(namespace):\n+ queue = None # type: Queue[QueuedScore, ...]\n+ scores = None # type: Optional[List[float, ...]]\n+\n+\n+class QueuedScore(namespace):\n+ position = None # type: int\n+ score = None # type: float\n+ state = None # type: Iterable\n+\n+\n+class RunState(namespace):\n+ Invalid = 0 # Used only as default, changed to Initialized when instantiated\n+ Initialized = 1 # Has data; prepare_run must be called before starting computation\n+ Ready = 2 # Has data, iterator is initialized, but never used\n+ Running = 3 # Scoring thread is running\n+ Paused = 4 # Scoring thread is inactive, but can continue (without prepare_run)\n+ Done = 5 # Scoring is done\n+\n+ state: int = Invalid\n+ iterator: Iterable = None\n+ completed: int = 0\n+\n+ def can_run(self):\n+ return self.state in (self.Ready, self.Paused)\n+\n+\n+class VizRankDialog(QDialog, ProgressBarMixin, ConcurrentMixin):\n+ \"\"\"\n+ Base class for VizRank dialogs, providing a GUI with a table and a button,\n+ and the skeleton for managing the evaluation of visualizations.\n+\n+ A new instance of this class is used for new data or any change made in\n+ the widget (e.g. color attribute in the scatter plot).\n+\n+ The attribute run_state (and the related signal runStateChanged) can be\n+ used for tracking the work flow of the widget. run_state.state can be\n+\n+ - RunState.Initialized (after __init__): the widget has the data, but\n+ the state generator is not constructed, total statecount is not known\n+ yet. The dialog may reenter this state after, for instance, changing\n+ the number of attributes per combination in radviz.\n+ - RunState.Ready (after prepare_run): the iterator is ready, state count\n+ is known: the ranking can commence.\n+ - RunState.Running (after start_computation): ranking is in progress.\n+ This state is entered by start_computation. If start_computation is\n+ called when the state is Initialized, start computation will call\n+ prepare_run.\n+ - RunState.Paused (after pause_computation): ranking is paused. This may\n+ continue (with start_computation) or be reset when parameters of VizRank\n+ are changed (by calling `set_run_state(RunState.Initialized)` and then\n+ start_computation, which will first call prepare_run to go to Ready)\n+ - RunState.Done: ranking is done. The only allowed next state is\n+ Initialized (with the procedure described in the previous point).\n+\n+ State should be changed through set_run_state, which also changes the button\n+ label and disables the button when Done.\n+\n+ Derived classes must provide methods\n+\n+ - `__init__(parent, *args, **kwargs)`: stores the data to run vizrank,\n+ - `state_generator()`: generates combinations (e.g. of attributes),\n+ - `compute_score(state)`: computes the score for the combination,\n+ - `row_for_state(state)`: returns a list of items inserted into the\n+ table for the given state.\n+\n+ and, probably,\n+\n+ - emit `selectionChanged` when the user changes the selection in the table,\n+\n+ and, optionally,\n+\n+ - `state_count`: return the number of combinations (used for progress bar)\n+ - `bar_length`: return the length of the bar corresponding to the score,\n+ - `auto_select`: selects the row corresponding to the given data.\n+\n+ Derived classes are also responsible for connecting to\n+ rank_table.selectionModel().selectionChanged and emitting something useful\n+ via selectionChanged\n+\n+ The constructor shouldn't do anything but store the necessary data (as is)\n+ because instances of this object are created on any new data. The actual\n+ work can only start in `prepare_run`. `prepare_run` usually won't be\n+ overriden, so the first computation in derived classes will usually happen\n+ in `compute_score` or, in classes derived from`VizRankAttributes`, in\n+ `score_attributes`.\n+\n+ Args:\n+ parent (Orange.widget.OWWidget): widget to which the dialog belongs\n+\n+ Attributes:\n+ captionTitle (str): the caption for the dialog. This can be a class\n+ attribute. `captionTitle` is used by the `ProgressBarMixin`.\n+ show_bars (True): if True (default), table with scores contains bars\n+ of length -score. For a different length, override `bar_lenght`.\n+ To hide bars (e.g. because scores can't be normalized) set this to\n+ `False`.\n+\n+ Signal:\n+ selectionChanged(object): emitted when selection in the table is\n+ changed. The data type depends on the derived class (e.g. a list\n+ of attributes)\n+ runStateChanged(int, dict): emitted when the run state changes\n+ (e.g. start, pause...). Derived classes can fill the dictionary\n+ with additional data, e.g. the state of the user interface\n+ \"\"\"\n+ captionTitle = \"Score Plots\"\n+ show_bars = True\n+\n+ selectionChanged = Signal(object)\n+ runStateChanged = Signal(int, dict)\n+\n+ button_labels = {RunState.Initialized: \"Start\",\n+ RunState.Ready: \"Start\",\n+ RunState.Running: \"Pause\",\n+ RunState.Paused: \"Continue\",\n+ RunState.Done: \"Finished\",\n+ RunState.Invalid: \"Start\"}\n+\n+ def __init__(self, parent):\n+ QDialog.__init__(self, parent, windowTitle=self.captionTitle)\n+ ConcurrentMixin.__init__(self)\n+ ProgressBarMixin.__init__(self)\n+ self.setLayout(QVBoxLayout())\n+\n+ self.scores = []\n+ self.add_to_model = Queue()\n+ self.run_state = RunState()\n+ self.total_states = 1\n+\n+ self.filter = QLineEdit()\n+ self.filter.setPlaceholderText(\"Filter ...\")\n+ self.layout().addWidget(self.filter)\n+\n+ self.rank_model = QStandardItemModel(self)\n+ self.model_proxy = QSortFilterProxyModel(\n+ self, filterCaseSensitivity=Qt.CaseInsensitive)\n+ self.model_proxy.setSourceModel(self.rank_model)\n+ self.filter.textChanged.connect(self.model_proxy.setFilterFixedString)\n+\n+ self.rank_table = view = QTableView(\n+ selectionBehavior=QTableView.SelectRows,\n+ selectionMode=QTableView.SingleSelection,\n+ showGrid=False,\n+ editTriggers=gui.TableView.NoEditTriggers)\n+ view.setItemDelegate(TableBarItem() if self.show_bars\n+ else HorizontalGridDelegate())\n+ view.setModel(self.model_proxy)\n+ view.horizontalHeader().setStretchLastSection(True)\n+ view.horizontalHeader().hide()\n+ self.layout().addWidget(view)\n+\n+ self.button = gui.button(self, self, \"Start\", default=True)\n+\n+ @self.button.pressed.connect\n+ def on_button_pressed():\n+ if self.run_state.state == RunState.Running:\n+ self.pause_computation()\n+ else:\n+ self.start_computation()\n+\n+ self.set_run_state(RunState.Initialized)\n+\n+ def prepare_run(self) -> None:\n+ \"\"\"\n+ Called by start_computation before running for the first time or with\n+ new parameters within the vizrank gui, e.g. a different number of\n+ attributes in combinations.\n+\n+ Derived classes may override this method to add other preparation steps,\n+ but shouldn't need to call it.\n+ \"\"\"\n+ self.progressBarInit()\n+ self.scores = []\n+ self._update_model() # empty queue\n+ self.rank_model.clear()\n+ self.run_state.iterator = self.state_generator()\n+ self.total_states = self.state_count() or 1\n+ self.set_run_state(RunState.Ready)\n+\n+ def start_computation(self) -> None:\n+ if self.run_state.state == RunState.Initialized:\n+ self.prepare_run()\n+ if not self.run_state.can_run():\n+ return\n+ self.set_run_state(RunState.Running)\n+ self.start(\n+ self.run_vizrank,\n+ self.compute_score, self.scores,\n+ self.run_state.iterator, self.run_state.completed)\n+\n+ def pause_computation(self) -> None:\n+ if not self.run_state.state == RunState.Running:\n+ return\n+ self.set_run_state(RunState.Paused)\n+ self.cancel()\n+ self._update_model()\n+\n+ @staticmethod\n+ def run_vizrank(compute_score: Callable, scores: List,\n+ state_iterator: Iterator, completed: int, task: TaskState):\n+ res = Result(queue=Queue(), scores=None, completed_states=completed)\n+ scores = scores.copy()\n+ can_set_partial_result = True\n+\n+ def do_work(st: Any):\n+ score = compute_score(st)\n+ if score is not None:\n+ pos = bisect_left(scores, score)\n+ res.queue.put_nowait(QueuedScore(position=pos, score=score,\n+ state=st))\n+ scores.insert(pos, score)\n+ res.scores = scores.copy()\n+ res.completed_states += 1\n+\n+ def reset_flag():\n+ nonlocal can_set_partial_result\n+ can_set_partial_result = True\n+\n+ for state in state_iterator:\n+ do_work(state)\n+ # Prevent simple scores from invoking 'task.set_partial_result')\n+ # too frequently and making the widget unresponsive\n+ if can_set_partial_result:\n+ task.set_partial_result(res)\n+ can_set_partial_result = False\n+ Timer(0.01, reset_flag).start()\n+ if task.is_interruption_requested():\n+ return res\n+ task.set_partial_result(res)\n+ return res\n+\n+ def on_partial_result(self, result: Result) -> None:\n+ try:\n+ while True:\n+ queued = result.queue.get_nowait()\n+ self.add_to_model.put_nowait(queued)\n+ except Empty:\n+ pass\n+ self.scores = result.scores\n+ self._update_model()\n+ self.run_state.completed = result.completed_states\n+ self.progressBarSet(self._progress)\n+\n+ @property\n+ def _progress(self) -> int:\n+ return int(round(self.run_state.completed * 100 / self.total_states))\n+\n+ def on_done(self, result: Result) -> None:\n+ self.progressBarFinished()\n+ self.set_run_state(RunState.Done)\n+ self._update_model()\n+\n+ def set_run_state(self, state: Any) -> None:\n+ if state != self.run_state.state:\n+ self.run_state.state = state\n+ self.emit_run_state_changed()\n+ if state == RunState.Paused:\n+ self.setWindowTitle(\n+ f\"{self.captionTitle} (paused at {self._progress}%)\")\n+ self.set_button_state()\n+\n+ def emit_run_state_changed(self):\n+ self.runStateChanged.emit(self.run_state.state, {})\n+\n+ def set_button_state(self,\n+ label: Optional[str] = None,\n+ enabled: Optional[bool]=None) -> None:\n+ state = self.run_state.state\n+ self.button.setText(\n+ label if label is not None\n+ else self.button_labels[state])\n+ self.button.setEnabled(\n+ enabled if enabled is not None\n+ else state not in [RunState.Done, RunState.Invalid])\n+\n+ def _update_model(self) -> None:\n+ try:\n+ while True:\n+ queued = self.add_to_model.get_nowait()\n+ row_items = self.row_for_state(queued.score, queued.state)\n+ bar_length = self.bar_length(queued.score)\n+ if bar_length is not None:\n+ row_items[0].setData(bar_length,\n+ gui.TableBarItem.BarRole)\n+ self.rank_model.insertRow(queued.position, row_items)\n+ except Empty:\n+ pass\n+\n+ def showEvent(self, event: QShowEvent) -> None:\n+ self.parent()._restore_vizrank_geometry()\n+ super().showEvent(event)\n+\n+ def closeEvent(self, event: QCloseEvent) -> None:\n+ self.pause_computation()\n+ self.parent()._save_vizrank_geometry()\n+ super().closeEvent(event)\n+\n+ def state_generator(self) -> Iterable:\n+ \"\"\"\n+ Generate all possible states (e.g. attribute combinations) for the\n+ given data. The content of the generated states is specific to the\n+ visualization.\n+ \"\"\"\n+ raise NotImplementedError\n+\n+ def compute_score(self, state: Any) -> Optional[float]:\n+ \"\"\"\n+ Abstract method for computing the score for the given state. Smaller\n+ scores are better.\n+\n+ Args:\n+ state: the state, e.g. the combination of attributes as generated\n+ by :obj:`state_count`.\n+ \"\"\"\n+ raise NotImplementedError\n+\n+ def row_for_state(self, score: float, state: Any) -> List[QStandardItem]:\n+ \"\"\"\n+ Return a list of items that are inserted into the table.\n+\n+ Args:\n+ score: score, computed by :obj:`compute_score`\n+ state: the state, e.g. combination of attributes\n+ \"\"\"\n+ raise NotImplementedError\n+\n+ def auto_select(self, arg: Any) -> None:\n+ \"\"\"\n+ Select the row corresponding to the give data.\n+ \"\"\"\n+ pass\n+\n+ def state_count(self) -> int:\n+ \"\"\"\n+ Return the total number of states, needed for the progress bar.\n+ \"\"\"\n+ return 1\n+\n+ def bar_length(self, score: float) -> float:\n+ \"\"\"\n+ Return the bar length (between 0 and 1) corresponding to the score.\n+ Return `None` if the score cannot be normalized.\n+ \"\"\"\n+ return max(0., -score)\n+\n+\n+def VizRankMixin(vizrank_class) -> Type[type]:\n+ \"\"\"\n+ A mixin that serves as an interface between the vizrank dialog and the widget.\n+\n+ Widget should avoid directly access the vizrank dialog.\n+\n+ This mixin takes care of constructing the vizrank dialog, raising it,\n+ and for closing and shutting the vizrank down when necessary. Data for\n+ vizrank is passed to the vizrank through the mixin, and the mixin forwards\n+ the signals from vizrank dialog (e.g. when the user selects rows in vizrank)\n+ to the widget.\n+\n+ The mixin is parametrized: it must be given the VizRank class to open,\n+ as in\n+\n+ ```\n+ class OWMosaicDisplay(OWWidget, VizRankMixin(MosaicVizRank)):\n+ ```\n+\n+ There should therefore be no need to subclass this class.\n+\n+ Method `vizrank_button` returns a button to be placed into the widget.\n+\n+ Signals:\n+ - `vizrankSelectionChanged` is connected to VizRank's selectionChanged.\n+ E.g. MosaicVizRank.selectionChanged is forwarded to selectionChanged,\n+ and contains the data sent by the former.\n+ - `virankRunStateChanged` is connected to VizRank's runStateChanged.\n+ This can be used to retrieve the settings from the dialog at appropriate\n+ times.\n+ - If the widget emits a signal `vizrankAutoSelect` when\n+ the user manually changes the variables shown in the plot (e.g. x or y\n+ attribute in the scatter plot), the vizrank will also select this\n+ combination in the list, if found.\n+\"\"\"\n+ class __VizRankMixin:\n+ __button: Optional[QPushButton] = None\n+ __vizrank: Optional[VizRankDialog] = None\n+ __vizrank_geometry: Optional[bytes] = None\n+\n+ vizrankSelectionChanged = Signal(object)\n+ vizrankRunStateChanged = Signal(int, dict)\n+ vizrankAutoSelect = Signal(object)\n+\n+ @property\n+ def vizrank_dialog(self) -> Optional[VizRankDialog]:\n+ \"\"\"\n+ The vizrank dialog. This should be used only in tests.\n+ \"\"\"\n+ return self.__vizrank\n+\n+ def vizrank_button(self, button_label: Optional[str] = None) -> QPushButton:\n+ \"\"\"\n+ A button that opens/starts the vizrank.\n+\n+ The label is optional because this function is used for\n+ constructing the button as well as for retrieving it later.\n+ \"\"\"\n+ if self.__button is None:\n+ self.__button = QPushButton()\n+ self.__button.pressed.connect(self.start_vizrank)\n+ self.__button.pressed.connect(self.raise_vizrank)\n+ # It's implausible that vizrank_button will be called after\n+ # init_vizrank, we could just disable the button. But let's\n+ # play it safe.\n+ self.__button.setDisabled(self.__vizrank is None)\n+ if button_label is not None:\n+ self.__button.setText(button_label)\n+ return self.__button\n+\n+ def init_vizrank(self, *args, **kwargs) -> None:\n+ \"\"\"\n+ Construct the vizrank dialog\n+\n+ Any data is given to the constructor. This also enables the button\n+ if it exists.\n+ \"\"\"\n+ self.shutdown_vizrank()\n+ self.__vizrank = vizrank_class(self, *args, **kwargs)\n+ self.__vizrank.selectionChanged.connect(self.vizrankSelectionChanged)\n+ self.__vizrank.runStateChanged.connect(self.vizrankRunStateChanged)\n+ self.vizrankAutoSelect.connect(self.__vizrank.auto_select)\n+ # There may be Vizrank without a button ... perhaps.\n+ if self.__button is not None:\n+ self.__button.setEnabled(True)\n+ self.__button.setToolTip(\"\")\n+\n+ def disable_vizrank(self, reason: str = \"\") -> None:\n+ \"\"\"\n+ Shut down the vizrank thread, closes it, disables the button.\n+\n+ The method should be called when the widget has no data or cannot\n+ run vizrank on it. The optional `reason` is set as tool tip.\n+ \"\"\"\n+ self.shutdown_vizrank()\n+ if self.__button is not None:\n+ self.__button.setEnabled(False)\n+ self.__button.setToolTip(reason)\n+\n+ def start_vizrank(self) -> None:\n+ \"\"\"\n+ Start the ranking.\n+\n+ There should be no reason to call this directly,\n+ unless the widget has no vizrank button.\n+ \"\"\"\n+ self.__vizrank.start_computation()\n+\n+ def raise_vizrank(self) -> None:\n+ \"\"\"\n+ Start the ranking.\n+\n+ There should be no reason to call this directly,\n+ unless the widget has no vizrank button.\n+ \"\"\"\n+ if self.__vizrank is None:\n+ return\n+ self.__vizrank.show()\n+ self.__vizrank.activateWindow()\n+ self.__vizrank.raise_()\n+\n+ def shutdown_vizrank(self) -> None:\n+ \"\"\"\n+ Start the ranking.\n+\n+ There should be no reason to call this directly:\n+ the method is called\n+ - from init_vizrank (the widget received new data),\n+ - from disable_vizrank (the widget lost data, or data is unsuitable),\n+ - when the widget is deleted.\n+ \"\"\"\n+ if self.__vizrank is None:\n+ return\n+ self.__vizrank.cancel()\n+ self.__vizrank.close()\n+ self.__vizrank.deleteLater()\n+ self.__vizrank = None\n+\n+ # The following methods ensure that the vizrank dialog is\n+ # closed/hidden/destroyed together with its parent widget.\n+ def closeEvent(self, event: QCloseEvent) -> None:\n+ if self.__vizrank:\n+ self.__vizrank.close()\n+ super().closeEvent(event)\n+\n+ def hideEvent(self, event: QHideEvent) -> None:\n+ if self.__vizrank:\n+ self.__vizrank.hide()\n+ super().hideEvent(event)\n+\n+ def onDeleteWidget(self) -> None:\n+ self.shutdown_vizrank()\n+ super().onDeleteWidget()\n+\n+ def _save_vizrank_geometry(self) -> None:\n+ assert self.__vizrank\n+ self.__vizrank_geometry = self.__vizrank.saveGeometry()\n+\n+ def _restore_vizrank_geometry(self) -> None:\n+ assert self.__vizrank\n+ if self.__vizrank_geometry is not None:\n+ self.__vizrank.restoreGeometry(self.__vizrank_geometry)\n+\n+ # Give the returned class a proper name, like MosaicVizRankMixin\n+ return type(f\"{vizrank_class.__name__}Mixin\", (__VizRankMixin, ), {})\n+\n+\n+class VizRankDialogAttrs(VizRankDialog):\n+ \"\"\"\n+ Base class for VizRank classes that work over combinations of attributes.\n+\n+ Constructor accepts\n+ - data (Table),\n+ - attributes (list[Variable]; if omitted, data.domain.variables is used),\n+ - attr_color (Optional[Variable]): the \"color\" attribute, if applicable.\n+\n+ The class assumes that `state` is a sequence of indices into a list of\n+ attributes. On this basis, it provides\n+\n+ - `row_for_state`, that constructs a list containing a single QStandardItem\n+ with names of attributes and with `_AttrRole` data set to a list of\n+ attributes for the given state.\n+ - `on_selection_changed` that emits a `selectionChanged` signal with the\n+ above list.\n+\n+ Derived classes must still provide\n+\n+ - `state_generator()`: generates combinations of attribute indices\n+ - `compute_score(state)`: computes the score for the combination\n+\n+ Derived classes will usually provide\n+ - `score_attribute` that will returned a list of attributes, such as found\n+ in self.attrs, but sorted by importance according to some heuristic.\n+\n+ Attributes:\n+ - data (Table): data used in ranking\n+ - attrs (list[Variable]): applicable variables\n+ - attr_color (Variable or None): the target attribute\n+\n+ Class attributes:\n+ - sort_names_in_row (bool): if set to True (default is False),\n+ variables in the view will be sorted alphabetically.\n+ \"\"\"\n+ _AttrRole = next(gui.OrangeUserRole)\n+ sort_names_in_row = False\n+\n+ # Ideally, the only argument would be `data`, with attributes used for\n+ # ranking and class_var would be the \"color\". This would however require\n+ # that widgets prepare such data when initializing vizrank even though\n+ # vizrank wouldn't necessarily be called at all. We will be able to afford\n+ # that after we migrate Table to pandas.\n+ def __init__(self, parent,\n+ data: \"Orange.data.Table\",\n+ attributes: Optional[List[\"Orange.data.Variable\"]] = None,\n+ attr_color: Optional[\"Orange.data.Variable\"] = None):\n+ super().__init__(parent)\n+ self.data = data or None\n+ self.attrs = attributes or (\n+ self.data and self.data.domain.variables)\n+ self.attr_color = attr_color\n+ self._attr_order = None\n+\n+ self.rank_table.selectionModel().selectionChanged.connect(\n+ self.on_selection_changed)\n+\n+ @property\n+ def attr_order(self) -> List[\"Orange.data.Variable\"]:\n+ \"\"\"\n+ Attributes, sorted according to some heuristic.\n+\n+ The property is computed by score_attributes when neceessary, and\n+ cached.\n+ \"\"\"\n+ if self._attr_order is None:\n+ self._attr_order = self.score_attributes()\n+ return self._attr_order\n+\n+ def score_attributes(self) -> None:\n+ \"\"\"\n+ Return a list of attributes ordered according by some heuristic.\n+\n+ Default implementation returns the original list `self.attrs`.\n+ \"\"\"\n+ return self.attrs\n+\n+ def on_selection_changed(self, selected, deselected) -> None:\n+ \"\"\"\n+ Emit the currently selected combination of variables.\n+ \"\"\"\n+ selection = selected.indexes()\n+ if not selection:\n+ return\n+ attrs = selected.indexes()[0].data(self._AttrRole)\n+ self.selectionChanged.emit(attrs)\n+\n+ def row_for_state(self, score: float, state: List[int]\n+ ) -> List[QStandardItem]:\n+ \"\"\"\n+ Return the QStandardItem for the given combination of attributes.\n+ \"\"\"\n+ attrs = [self.attr_order[s] for s in state]\n+ if self.sort_names_in_row:\n+ attrs.sort(key=lambda attr: attr.name.lower())\n+ attr_names = (a.name for a in attrs)\n+ item = QStandardItem(', '.join(attr_names))\n+ item.setData(attrs, self._AttrRole)\n+ return [item]\n+\n+ def auto_select(self, attrs: List[\"Orange.data.Variable\"]) -> None:\n+ \"\"\"\n+ Find the given combination of variables and select it (if it exists)\n+ \"\"\"\n+ model = self.rank_model\n+ self.rank_table.selectionModel().clear()\n+ for row in range(model.rowCount()):\n+ index = model.index(row, 0)\n+ row_attrs = model.data(index, self._AttrRole)\n+ if all(x is y for x, y in zip(row_attrs, attrs)):\n+ self.rank_table.selectRow(row)\n+ self.rank_table.scrollTo(index)\n+ return\n+\n+\n+class VizRankDialogAttrPair(VizRankDialogAttrs):\n+ \"\"\"\n+ Base class for VizRanks with combinations of two variables.\n+\n+ Provides state_generator and state_count; derived classes must provide\n+ compute_score and, possibly, score_attributes.\n+ \"\"\"\n+ def __init__(self, parent, data, attributes=None, attr_color=None):\n+ super().__init__(parent, data, attributes, attr_color)\n+ self.resize(320, 512)\n+\n+ def sizeHint(self) -> QSize:\n+ return QSize(320, 512)\n+\n+ def state_count(self) -> int:\n+ n_attrs = len(self.attrs)\n+ return n_attrs * (n_attrs - 1) // 2\n+\n+ def state_generator(self) -> Iterable:\n+ return ((j, i) for i in range(len(self.attr_order)) for j in range(i))\n+\n+\n+class VizRankDialogNAttrs(VizRankDialogAttrs):\n+ \"\"\"\n+ Base class for VizRanks with a spin for selecting the number of attributes.\n+\n+ Constructor requires data, attributes, attr_color and, also, the initial\n+ number of attributes in the spin box.\n+\n+ - Ranking is stopped if the user interacts with the spin.\n+ - The button label is changed to \"Restart with {...} variables\" if the\n+ number selected in the spin doesn't match the number of varialbes in the\n+ paused ranking, and reset back to \"Continue\" when it matches.\n+ - start_computation is overriden to lower the state to Initialized before\n+ calling super, if the number of selected in the spin doesn't match the\n+ previous run.\n+ - The dictionary passed by the signal runStateChanged contains n_attrs\n+ with the number of attributes used in the current/last ranking.\n+ - When closing the dialog, the spin is reset to the number of attributes\n+ used in the last run.\n+ \"\"\"\n+ attrsSelected = Signal([])\n+\n+ def __init__(self, parent,\n+ data: \"Orange.data.Table\",\n+ attributes: List[\"Orange.data.Variable\"],\n+ color: \"Orange.data.Variable\",\n+ n_attrs: int,\n+ *, spin_label: str = \"Number of variables: \"):\n+ # Add the spin box for a number of attributes to take into account.\n+ self.n_attrs = n_attrs\n+ super().__init__(parent, data, attributes, color)\n+ self._attr_order = None\n+\n+ box = gui.hBox(self)\n+ self.n_attrs_spin = gui.spin(\n+ box, self, None, 3, 8, label=spin_label,\n+ controlWidth=50, alignment=Qt.AlignRight,\n+ callback=self.on_n_attrs_changed)\n+\n+ n_cont = self.max_attrs()\n+ self.n_attrs_spin.setValue(min(self.n_attrs, n_cont))\n+ self.n_attrs_spin.setMaximum(n_cont)\n+ self.n_attrs_spin.parent().setDisabled(not n_cont)\n+\n+ def max_attrs(self) -> int:\n+ return sum(v is not self.attr_color for v in self.attrs)\n+\n+ def start_computation(self) -> None:\n+ if self.n_attrs != self.n_attrs_spin.value():\n+ self.n_attrs = self.n_attrs_spin.value()\n+ self.set_run_state(RunState.Initialized)\n+ self.n_attrs_spin.lineEdit().deselect()\n+ self.rank_table.setFocus(Qt.FocusReason.OtherFocusReason)\n+ super().start_computation()\n+\n+ def on_n_attrs_changed(self) -> None:\n+ if self.run_state.state == RunState.Running:\n+ self.pause_computation()\n+\n+ new_attrs = self.n_attrs_spin.value()\n+ if new_attrs == self.n_attrs:\n+ self.set_button_state()\n+ else:\n+ self.set_button_state(label=f\"Restart with {new_attrs} variables\",\n+ enabled=True)\n+\n+ def emit_run_state_changed(self) -> None:\n+ self.runStateChanged.emit(self.run_state.state,\n+ dict(n_attrs=self.n_attrs))\n+\n+ def closeEvent(self, event) -> None:\n+ self.n_attrs_spin.setValue(self.n_attrs)\n+ super().closeEvent(event)\n+\n"}
data/13.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"head_branch": "nightly", "contributor": "markotoplak", "sha_fail": "d54275b61d018de1027878ce5ac738c280a0f48f", "sha_success": "34ac519e0facc8c6961c1c1aefee53e24c884dec", "language": "Python", "repo_owner": "biolab", "repo_name": "orange3", "workflow_name": "Check translations", "workflow_filename": "translations.yml", "workflow_path": ".github/workflows/translations.yml", "workflow": "name: Check translations\n\non:\n push:\n branches:\n - master\n pull_request:\n branches:\n - master\n\njobs:\n build:\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@v4\n\n - name: Setup Python\n uses: actions/setup-python@v4\n with:\n python-version: '3.x'\n\n - name: Install Trubar\n run: |\n pip install trubar\n\n - name: Collect translations\n run: |\n cd i18n\n trubar collect -s ../Orange new.jaml\n trubar merge -u Obsolete.jaml si.jaml new.jaml\n trubar missing -o Missing.jaml new.jaml\n if [ ! -s Missing.jaml ]\n then\n rm Missing.jaml\n fi\n\n - name: Check translations\n run: |\n cd i18n\n for fn in Obsolete Missing\n do\n if [ -f $fn.jaml ]\n then\n echo \"::group::$fn translations\"\n cat $fn.jaml\n echo \"::endgroup::\"\n fi\n done\n echo \"-------------------------------\"\n trubar stat new.jaml\n echo \"-------------------------------\"\n if [ -f Missing.jaml ] || [ -f Obsolete.jaml ]\n then\n echo \"### Missing or obsolete translations\" >> $GITHUB_STEP_SUMMARY\n echo \"::error::Missing or obsolete translations\"\n echo \"Run 'trubar collect -s Orange i18n/si.jaml'\"\n echo \"and see the changes in the message file, i18n/si.jaml\"\n exit 1\n else\n echo \"### All translations are up to date\" >> $GITHUB_STEP_SUMMARY\n fi\n", "logs": "\u001b[36;1m cat $fn.jaml\u001b[0m\n\u001b[36;1m echo \"::endgroup::\"\u001b[0m\n\u001b[36;1m fi\u001b[0m\n\u001b[36;1mdone\u001b[0m\n\u001b[36;1mecho \"-------------------------------\"\u001b[0m\n\u001b[36;1mtrubar stat new.jaml\u001b[0m\n\u001b[36;1mecho \"-------------------------------\"\u001b[0m\n\u001b[36;1mif [ -f Missing.jaml ] || [ -f Obsolete.jaml ]\u001b[0m\n\u001b[36;1mthen\u001b[0m\n\u001b[36;1m echo \"### Missing or obsolete translations\" >> $GITHUB_STEP_SUMMARY\u001b[0m\n\u001b[36;1m echo \"::error::Missing or obsolete translations\"\u001b[0m\n\u001b[36;1m echo \"Run 'trubar collect -s Orange i18n/si.jaml'\"\u001b[0m\n\u001b[36;1m echo \"and see the changes in the message file, i18n/si.jaml\"\u001b[0m\n\u001b[36;1m exit 1\u001b[0m\n\u001b[36;1melse\u001b[0m\n\u001b[36;1m echo \"### All translations are up to date\" >> $GITHUB_STEP_SUMMARY\u001b[0m\n\u001b[36;1mfi\u001b[0m\nshell: /usr/bin/bash -e {0}\nenv:\n pythonLocation: /opt/hostedtoolcache/Python/3.12.0/x64\n PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.12.0/x64/lib/pkgconfig\n Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.0/x64\n Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.0/x64\n Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.12.0/x64\n LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.12.0/x64/lib\n##[endgroup]\n##[group]Missing translations\ntests/sql/base.py:\n class `DataBaseTest`:\n def `_check_db`:\n def `ensure_db`:\n {} module is required for this database: null\n Database is not running: null\n No connection provided for {}: null\n Unsupported database: null\n##[endgroup]\n-------------------------------\nTotal messages: 11238\n\nTranslated: 3711 33.0%\nKept unchanged: 331 2.9%\nProgrammatic: 7192 64.0%\nTotal completed: 11234 100.0%\n\nUntranslated: 4 0.0%\n-------------------------------\n##[error]Missing or obsolete translations\nRun 'trubar collect -s Orange i18n/si.jaml'\nand see the changes in the message file, i18n/si.jaml\n##[error]Process completed with exit code 1.\n", "diff": "diff --git a/Orange/tests/sql/base.py b/Orange/tests/sql/base.py\nindex 75b084b37..c396274bc 100644\n--- a/Orange/tests/sql/base.py\n+++ b/Orange/tests/sql/base.py\n@@ -340,22 +340,19 @@ class DataBaseTest:\n i = db.find(\"<\")\n db, ver = db[:i], db[i:]\n \n- def ensure_db(db):\n- if db in cls.db_conn:\n- if not cls.db_conn[db].is_module:\n- raise unittest.SkipTest(\n- \"{} module is required for this database\".format(\n- cls.db_conn[db].module))\n-\n- elif not cls.db_conn[db].is_active:\n- raise unittest.SkipTest(\"Database is not running\")\n- else:\n- if db in test_connections.keys():\n- raise unittest.SkipTest(\"No connection provided for {}\".format(db))\n- else:\n- raise Exception(\"Unsupported database\")\n+ if db in cls.db_conn:\n+ if not cls.db_conn[db].is_module:\n+ raise unittest.SkipTest(\n+ \"{} module is required for this database\".format(\n+ cls.db_conn[db].module))\n \n- ensure_db(db)\n+ elif not cls.db_conn[db].is_active:\n+ raise unittest.SkipTest(\"Database is not running\")\n+ else:\n+ if db in test_connections.keys():\n+ raise unittest.SkipTest(\"No connection provided for {}\".format(db))\n+ else:\n+ raise Exception(\"Unsupported database\")\n \n if ver is not None:\n if ver[0] == \">\" and cls.db_conn[db].version <= int(ver[1:]):\n"}
data/14.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"head_branch": "kingmigdor/entitlements", "contributor": "kingmigdor", "sha_fail": "da9d790a9c6dccd49a8dc0766f8ecea1043f49b6", "sha_success": "57bb0eff511eb11062cba25ddc948329475aa0fc", "language": "Python", "repo_owner": "nextcord", "repo_name": "nextcord", "workflow_name": "Test docs", "workflow_filename": "docs.yml", "workflow_path": ".github/workflows/docs.yml", "workflow": "name: Test docs\n\non:\n push:\n branches:\n - master\n pull_request:\n\njobs:\n docs:\n runs-on: ubuntu-latest\n strategy:\n matrix:\n python-version: [ 3.8 ]\n steps:\n - uses: actions/checkout@v3\n - name: Set up Python ${{ matrix.python-version }}\n uses: actions/setup-python@v4\n with:\n python-version: ${{ matrix.python-version }}\n - name: Install dependencies\n run: |\n python -m pip install --upgrade pip\n pip install -r requirements.txt -r docs/requirements.txt\n - name: Compile docs\n run: |\n cd docs\n make html\n", "logs": "No module named 'enums'\nWARNING: autodoc: failed to import exception 'ext.commands.BotMissingRole' from module 'nextcord'; the following exception was raised:\nNo module named 'enums'\nWARNING: autodoc: failed to import exception 'ext.commands.MissingAnyRole' from module 'nextcord'; the following exception was raised:\nNo module named 'enums'\nWARNING: autodoc: failed to import exception 'ext.commands.BotMissingAnyRole' from module 'nextcord'; the following exception was raised:\nNo module named 'enums'\nWARNING: autodoc: failed to import exception 'ext.commands.NSFWChannelRequired' from module 'nextcord'; the following exception was raised:\nNo module named 'enums'\nWARNING: autodoc: failed to import exception 'ext.commands.FlagError' from module 'nextcord'; the following exception was raised:\nNo module named 'enums'\nWARNING: autodoc: failed to import exception 'ext.commands.BadFlagArgument' from module 'nextcord'; the following exception was raised:\nNo module named 'enums'\nWARNING: autodoc: failed to import exception 'ext.commands.MissingFlagArgument' from module 'nextcord'; the following exception was raised:\nNo module named 'enums'\nWARNING: autodoc: failed to import exception 'ext.commands.TooManyFlags' from module 'nextcord'; the following exception was raised:\nNo module named 'enums'\nWARNING: autodoc: failed to import exception 'ext.commands.MissingRequiredFlag' from module 'nextcord'; the following exception was raised:\nNo module named 'enums'\nWARNING: autodoc: failed to import exception 'ext.commands.ExtensionError' from module 'nextcord'; the following exception was raised:\nNo module named 'enums'\nWARNING: autodoc: failed to import exception 'ext.commands.ExtensionAlreadyLoaded' from module 'nextcord'; the following exception was raised:\nNo module named 'enums'\nWARNING: autodoc: failed to import exception 'ext.commands.ExtensionNotLoaded' from module 'nextcord'; the following exception was raised:\nNo module named 'enums'\nWARNING: autodoc: failed to import exception 'ext.commands.NoEntryPointError' from module 'nextcord'; the following exception was raised:\nNo module named 'enums'\nWARNING: autodoc: failed to import exception 'ext.commands.InvalidSetupArguments' from module 'nextcord'; the following exception was raised:\nNo module named 'enums'\nWARNING: autodoc: failed to import exception 'ext.commands.ExtensionFailed' from module 'nextcord'; the following exception was raised:\nNo module named 'enums'\nWARNING: autodoc: failed to import exception 'ext.commands.ExtensionNotFound' from module 'nextcord'; the following exception was raised:\nNo module named 'enums'\nWARNING: autodoc: failed to import exception 'ext.commands.CommandRegistrationError' from module 'nextcord'; the following exception was raised:\nNo module named 'enums'\nWARNING: autodoc: failed to import class 'ext.tasks.Loop' from module 'nextcord'; the following exception was raised:\nNo module named 'enums'\nWARNING: autodoc: failed to import function 'ext.tasks.loop' from module 'nextcord'; the following exception was raised:\nNo module named 'enums'\n\nlooking for now-outdated files... none found\npickling environment... done\nchecking consistency... done\npreparing documents... done\nwriting output... [ 4%] api\n\nExtension error (attributetable):\nHandler <function process_attributetable at 0x7f1ef468c1f0> for event 'doctree-resolved' threw an exception (exception: No module named 'enums')\nmake: *** [Makefile:54: html] Error 2\n##[error]Process completed with exit code 2.\n", "diff": "diff --git a/nextcord/entitlement.py b/nextcord/entitlement.py\nindex 8e23694a..fa23219c 100644\n--- a/nextcord/entitlement.py\n+++ b/nextcord/entitlement.py\n@@ -5,11 +5,10 @@ from __future__ import annotations\n from datetime import datetime\n from typing import Optional\n \n-from enums import EntitlementType, SKUType\n-from flags import SKUFlags\n-from object import Object\n-from utils import parse_time\n-\n+from .enums import EntitlementType, SKUType\n+from .flags import SKUFlags\n+from .object import Object\n+from .utils import parse_time\n from .types.entitlement import SKU as SKUPayload, Entitlement as EntitlementPayload\n \n \n"}
data/15.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"head_branch": "TrapDrap-nextcord-voice-recording", "contributor": "TrapDrap", "sha_fail": "c19fff9e1d8bdd2b0918d43774ee026132a957ff", "sha_success": "31ffa8d7929b4ad576359e07f0177653750b6408", "language": "Python", "repo_owner": "nextcord", "repo_name": "nextcord", "workflow_name": "Test docs", "workflow_filename": "docs.yml", "workflow_path": ".github/workflows/docs.yml", "workflow": "name: Test docs\n\non:\n push:\n branches:\n - master\n pull_request:\n\njobs:\n docs:\n runs-on: ubuntu-latest\n strategy:\n matrix:\n python-version: [ 3.8 ]\n steps:\n - uses: actions/checkout@v3\n - name: Set up Python ${{ matrix.python-version }}\n uses: actions/setup-python@v4\n with:\n python-version: ${{ matrix.python-version }}\n - name: Install dependencies\n run: |\n python -m pip install --upgrade pip\n pip install -r requirements.txt -r docs/requirements.txt\n - name: Compile docs\n run: |\n cd docs\n make html\n", "logs": " File \"/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/importlib/__init__.py\", line 127, in import_module\n return _bootstrap._gcd_import(name[level:], package, level)\n File \"<frozen importlib._bootstrap>\", line 1014, in _gcd_import\n File \"<frozen importlib._bootstrap>\", line 991, in _find_and_load\n File \"<frozen importlib._bootstrap>\", line 975, in _find_and_load_unlocked\n File \"<frozen importlib._bootstrap>\", line 671, in _load_unlocked\n File \"<frozen importlib._bootstrap_external>\", line 843, in exec_module\n File \"<frozen importlib._bootstrap>\", line 219, in _call_with_frames_removed\n File \"/home/runner/work/nextcord/nextcord/nextcord/__init__.py\", line 23, in <module>\n from . import abc, opus, ui, utils\n File \"/home/runner/work/nextcord/nextcord/nextcord/abc.py\", line 40, in <module>\n from .voice_recording import RecorderClient\n File \"/home/runner/work/nextcord/nextcord/nextcord/voice_recording/__init__.py\", line 2, in <module>\n from .core import *\n File \"/home/runner/work/nextcord/nextcord/nextcord/voice_recording/core.py\", line 346, in <module>\n class RecorderClient(VoiceClient):\nNameError: name 'VoiceClient' is not defined\n\nWARNING: autodoc: failed to import function 'ext.tasks.loop' from module 'nextcord'; the following exception was raised:\nTraceback (most recent call last):\n File \"/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/sphinx/ext/autodoc/importer.py\", line 58, in import_module\n return importlib.import_module(modname)\n File \"/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/importlib/__init__.py\", line 127, in import_module\n return _bootstrap._gcd_import(name[level:], package, level)\n File \"<frozen importlib._bootstrap>\", line 1014, in _gcd_import\n File \"<frozen importlib._bootstrap>\", line 991, in _find_and_load\n File \"<frozen importlib._bootstrap>\", line 975, in _find_and_load_unlocked\n File \"<frozen importlib._bootstrap>\", line 671, in _load_unlocked\n File \"<frozen importlib._bootstrap_external>\", line 843, in exec_module\n File \"<frozen importlib._bootstrap>\", line 219, in _call_with_frames_removed\n File \"/home/runner/work/nextcord/nextcord/nextcord/__init__.py\", line 23, in <module>\n from . import abc, opus, ui, utils\n File \"/home/runner/work/nextcord/nextcord/nextcord/abc.py\", line 40, in <module>\n from .voice_recording import RecorderClient\n File \"/home/runner/work/nextcord/nextcord/nextcord/voice_recording/__init__.py\", line 2, in <module>\n from .core import *\n File \"/home/runner/work/nextcord/nextcord/nextcord/voice_recording/core.py\", line 346, in <module>\n class RecorderClient(VoiceClient):\nNameError: name 'VoiceClient' is not defined\n\nlooking for now-outdated files... none found\npickling environment... done\nchecking consistency... done\npreparing documents... done\nwriting output... [ 4%] api\n\nExtension error (attributetable):\nHandler <function process_attributetable at 0x7efdfc0061f0> for event 'doctree-resolved' threw an exception (exception: name 'VoiceClient' is not defined)\nmake: *** [Makefile:54: html] Error 2\n##[error]Process completed with exit code 2.\n", "diff": "diff --git a/nextcord/voice_recording/core.py b/nextcord/voice_recording/core.py\nindex 7d7a8c45..884946dc 100644\n--- a/nextcord/voice_recording/core.py\n+++ b/nextcord/voice_recording/core.py\n@@ -13,6 +13,7 @@ from threading import Thread\n from time import perf_counter, sleep, time as clock_timestamp\n from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, Optional, Union\n \n+import nextcord.voice_client as nc_vc\n from nextcord.utils import MISSING\n \n from . import decrypter\n@@ -22,7 +23,7 @@ from .opus import DecoderThread\n from .shared import *\n \n if TYPE_CHECKING:\n- from nextcord import Member, User, VoiceClient\n+ from nextcord import Member, User\n from nextcord.abc import Connectable\n from nextcord.client import Client\n \n@@ -343,7 +344,7 @@ class OpusFrame:\n user_id: Optional[int] = None\n \n \n-class RecorderClient(VoiceClient):\n+class RecorderClient(nc_vc.VoiceClient):\n \"\"\"Represents a Discord voice connection that is able to receive audio packets.\n \n This is returned when passing `recordable=True` when connecting to a voice channel.\n"}
data/16.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"head_branch": "dev_min_discrete", "contributor": "Dhruvanshu-Joshi", "sha_fail": "7eb1f38279a6064244259157b3a591dd23a9efca", "sha_success": "c885c321111aa171cb7e9db056d0824b70b35d66", "language": "Python", "repo_owner": "pymc-devs", "repo_name": "pymc", "workflow_name": "pre-commit", "workflow_filename": "pre-commit.yml", "workflow_path": ".github/workflows/pre-commit.yml", "workflow": "name: pre-commit\n\non:\n pull_request:\n push:\n branches: [main]\n\njobs:\n pre-commit:\n runs-on: ubuntu-latest\n env:\n SKIP: no-commit-to-branch\n steps:\n - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11\n - uses: actions/setup-python@v4\n with:\n python-version: \"3.9\" # Run pre-commit on oldest supported Python version\n - uses: pre-commit/[email protected]\n mypy:\n runs-on: ubuntu-latest\n defaults:\n run:\n shell: bash -l {0}\n steps:\n - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11\n - name: Cache conda\n uses: actions/cache@v3\n env:\n # Increase this value to reset cache if environment-test.yml has not changed\n CACHE_NUMBER: 0\n with:\n path: ~/conda_pkgs_dir\n key: ${{ runner.os }}-py39-conda-${{ env.CACHE_NUMBER }}-${{\n hashFiles('conda-envs/environment-test.yml') }}\n - name: Cache multiple paths\n uses: actions/cache@v3\n env:\n # Increase this value to reset cache if requirements.txt has not changed\n CACHE_NUMBER: 0\n with:\n path: |\n ~/.cache/pip\n $RUNNER_TOOL_CACHE/Python/*\n ~\\AppData\\Local\\pip\\Cache\n key: ${{ runner.os }}-build-${{ matrix.python-version }}-${{ env.CACHE_NUMBER }}-${{\n hashFiles('requirements.txt') }}\n - uses: conda-incubator/setup-miniconda@v2\n with:\n miniforge-variant: Mambaforge\n miniforge-version: latest\n mamba-version: \"*\"\n activate-environment: pymc-test\n channel-priority: strict\n environment-file: conda-envs/environment-test.yml\n python-version: \"3.9\" # Run pre-commit on oldest supported Python version\n use-mamba: true\n use-only-tar-bz2: false # IMPORTANT: This may break caching of conda packages! See https://github.com/conda-incubator/setup-miniconda/issues/267\n - name: Install-pymc and mypy dependencies\n run: |\n conda activate pymc-test\n pip install -e .\n pip install --pre -U polyagamma\n python --version\n - name: Run mypy\n run: |\n conda activate pymc-test\n python ./scripts/run_mypy.py --verbose\n", "logs": " LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.18/x64/lib\n##[endgroup]\ncheck for merge conflicts............................................................\u001b[42mPassed\u001b[m\ncheck toml...........................................................................\u001b[42mPassed\u001b[m\ncheck yaml...........................................................................\u001b[42mPassed\u001b[m\ndebug statements (python)............................................................\u001b[42mPassed\u001b[m\nfix end of files.....................................................................\u001b[42mPassed\u001b[m\ndon't commit to branch..............................................................\u001b[43;30mSkipped\u001b[m\nfix requirements.txt.................................................................\u001b[42mPassed\u001b[m\ntrim trailing whitespace.............................................................\u001b[42mPassed\u001b[m\nApply Apache 2.0 License.............................................................\u001b[42mPassed\u001b[m\nisort................................................................................\u001b[41mFailed\u001b[m\n\u001b[2m- hook id: isort\u001b[m\n\u001b[2m- files were modified by this hook\u001b[m\n\nFixing /home/runner/work/pymc/pymc/pymc/logprob/transforms.py\nSkipped 1 files\n\npyupgrade............................................................................\u001b[42mPassed\u001b[m\nblack................................................................................\u001b[42mPassed\u001b[m\nblack-jupyter........................................................................\u001b[42mPassed\u001b[m\npylint...............................................................................\u001b[42mPassed\u001b[m\npydocstyle...........................................................................\u001b[42mPassed\u001b[m\nDisallow print statements............................................................\u001b[42mPassed\u001b[m\nCheck no tests are ignored...........................................................\u001b[42mPassed\u001b[m\nGenerate pip dependency from conda...................................................\u001b[42mPassed\u001b[m\nNo relative imports..................................................................\u001b[42mPassed\u001b[m\nCheck no links that should be cross-references are in the docs.......................\u001b[42mPassed\u001b[m\npre-commit hook(s) made changes.\nIf you are seeing this message in CI, reproduce locally with: `pre-commit run --all-files`.\nTo run `pre-commit` as part of git workflow, use `pre-commit install`.\nAll changes made by hooks:\n\u001b[1mdiff --git a/pymc/logprob/transforms.py b/pymc/logprob/transforms.py\u001b[m\n\u001b[1mindex e9092ea..a3f0a98 100644\u001b[m\n\u001b[1m--- a/pymc/logprob/transforms.py\u001b[m\n\u001b[1m+++ b/pymc/logprob/transforms.py\u001b[m\n\u001b[36m@@ -127,7 +127,11 @@\u001b[m \u001b[mfrom pymc.logprob.rewriting import (\u001b[m\n cleanup_ir_rewrites_db,\u001b[m\n measurable_ir_rewrites_db,\u001b[m\n )\u001b[m\n\u001b[31m-from pymc.logprob.utils import CheckParameterValue, check_negation, check_potential_measurability\u001b[m\n\u001b[32m+\u001b[m\u001b[32mfrom pymc.logprob.utils import (\u001b[m\n\u001b[32m+\u001b[m\u001b[32m CheckParameterValue,\u001b[m\n\u001b[32m+\u001b[m\u001b[32m check_negation,\u001b[m\n\u001b[32m+\u001b[m\u001b[32m check_potential_measurability,\u001b[m\n\u001b[32m+\u001b[m\u001b[32m)\u001b[m\n \u001b[m\n \u001b[m\n class TransformedVariable(Op):\u001b[m\n##[error]Process completed with exit code 1.\n", "diff": "diff --git a/pymc/logprob/order.py b/pymc/logprob/order.py\nindex 42e53e24..0433dece 100644\n--- a/pymc/logprob/order.py\n+++ b/pymc/logprob/order.py\n@@ -270,11 +270,12 @@ def max_neg_logprob_discrete(op, values, base_rv, **kwargs):\n \\ln(P_{(n)}(x)) = \\ln((1 - F(x - 1))^n - (1 - F(x))^n)\n where $P_{(n)}(x)$ represents the p.m.f of the maximum statistic and $F(x)$ represents the c.d.f of the i.i.d. variables.\n \"\"\"\n+\n (value,) = values\n \n # The cdf of a negative variable is the survival at the negated value\n logcdf = pt.log1mexp(_logcdf_helper(base_rv, -value))\n- logcdf_prev = pt.log1mexp(_logcdf_helper(base_rv, -(value - 1)))\n+ logcdf_prev = pt.log1mexp(_logcdf_helper(base_rv, -(value + 1)))\n \n [n] = constant_fold([base_rv.size])\n \n@@ -282,7 +283,7 @@ def max_neg_logprob_discrete(op, values, base_rv, **kwargs):\n logprob = pt.where(\n pt.and_(pt.eq(logcdf, -pt.inf), pt.eq(logcdf_prev, -pt.inf)),\n -pt.inf,\n- logdiffexp(n * logcdf, n * logcdf_prev),\n+ logdiffexp(n * logcdf_prev, n * logcdf),\n )\n \n return logprob\ndiff --git a/pymc/logprob/transforms.py b/pymc/logprob/transforms.py\nindex e9092ea6..c73095fa 100644\n--- a/pymc/logprob/transforms.py\n+++ b/pymc/logprob/transforms.py\n@@ -127,7 +127,11 @@ from pymc.logprob.rewriting import (\n cleanup_ir_rewrites_db,\n measurable_ir_rewrites_db,\n )\n-from pymc.logprob.utils import CheckParameterValue, check_negation, check_potential_measurability\n+from pymc.logprob.utils import (\n+ CheckParameterValue,\n+ check_negation,\n+ check_potential_measurability,\n+)\n \n \n class TransformedVariable(Op):\n@@ -469,6 +473,10 @@ def measurable_transform_logcdf(op: MeasurableTransform, value, *inputs, **kwarg\n other_inputs = list(inputs)\n measurable_input = other_inputs.pop(op.measurable_input_idx)\n \n+ # Do not apply rewrite to discrete variables\n+ if measurable_input.type.dtype.startswith(\"int\"):\n+ return NotImplementedError\n+\n backward_value = op.transform_elemwise.backward(value, *other_inputs)\n \n # Fail if transformation is not injective\n@@ -513,6 +521,10 @@ def measurable_transform_icdf(op: MeasurableTransform, value, *inputs, **kwargs)\n other_inputs = list(inputs)\n measurable_input = other_inputs.pop(op.measurable_input_idx)\n \n+ # Do not apply rewrite to discrete variables\n+ if measurable_input.type.dtype.startswith(\"int\"):\n+ return NotImplementedError\n+\n if isinstance(op.scalar_op, MONOTONICALLY_INCREASING_OPS):\n pass\n elif isinstance(op.scalar_op, MONOTONICALLY_DECREASING_OPS):\n@@ -672,8 +684,8 @@ def find_measurable_transforms(fgraph: FunctionGraph, node: Node) -> Optional[Li\n \n # Do not apply rewrite to discrete variables\n if measurable_input.type.dtype.startswith(\"int\"):\n- if check_negation(node.op.scalar_op, node.inputs[0]) is False and not isinstance(\n- node.op.scalar_op, Add\n+ if not (\n+ check_negation(node.op.scalar_op, node.inputs[0]) or isinstance(node.op.scalar_op, Add)\n ):\n return None\n \ndiff --git a/tests/logprob/test_order.py b/tests/logprob/test_order.py\nindex 6b7c6458..a7bbc97f 100644\n--- a/tests/logprob/test_order.py\n+++ b/tests/logprob/test_order.py\n@@ -37,6 +37,7 @@\n import re\n \n import numpy as np\n+import pytensor\n import pytensor.tensor as pt\n import pytest\n import scipy.stats as sp\n@@ -258,12 +259,7 @@ def test_max_discrete(mu, size, value, axis):\n \n @pytest.mark.parametrize(\n \"mu, n, test_value, axis\",\n- [\n- (2, 3, 1, -1),\n- (2, 3, 1, 0),\n- (1, 2, 2, None),\n- (0, 4, 0, 0),\n- ],\n+ [(2, 3, 1, -1), (2, 3, 1, 0), (1, 2, 2, None), (0, 4, 0, 0)],\n )\n def test_min_discrete(mu, n, test_value, axis):\n x = pm.Poisson.dist(name=\"x\", mu=mu, size=(n,))\n@@ -271,9 +267,9 @@ def test_min_discrete(mu, n, test_value, axis):\n x_min_value = pt.scalar(\"x_min_value\")\n x_min_logprob = logp(x_min, x_min_value)\n \n- sf_before = 1 - sp.poisson(mu).cdf(test_value)\n- # TODO: Confirm it should be test_value + 1??\n- sf = 1 - sp.poisson(mu).cdf(test_value + 1)\n+ sf_before = 1 - sp.poisson(mu).cdf(test_value - 1)\n+ sf = 1 - sp.poisson(mu).cdf(test_value)\n+\n expected_logp = np.log(sf_before**n - sf**n)\n \n np.testing.assert_allclose(\n@@ -281,3 +277,19 @@ def test_min_discrete(mu, n, test_value, axis):\n expected_logp,\n rtol=1e-06,\n )\n+\n+\n+def test_min_max_bernoulli():\n+ p = 0.7\n+ q = 1 - p\n+ n = 3\n+ x = pm.Bernoulli.dist(p=p, shape=(n,))\n+ value = pt.scalar(\"value\", dtype=int)\n+\n+ max_logp_fn = pytensor.function([value], pm.logp(pt.max(x), value))\n+ np.testing.assert_allclose(max_logp_fn(0), np.log(q**n))\n+ np.testing.assert_allclose(max_logp_fn(1), np.log(1 - q**n))\n+\n+ min_logp_fn = pytensor.function([value], pm.logp(pt.min(x), value))\n+ np.testing.assert_allclose(min_logp_fn(1), np.log(p**n))\n+ np.testing.assert_allclose(min_logp_fn(0), np.log(1 - p**n))\ndiff --git a/tests/logprob/test_transforms.py b/tests/logprob/test_transforms.py\nindex 32924a37..ea6a0f4d 100644\n--- a/tests/logprob/test_transforms.py\n+++ b/tests/logprob/test_transforms.py\n@@ -47,6 +47,8 @@ from pytensor.graph.basic import equal_computations\n from pytensor.graph.fg import FunctionGraph\n from pytensor.scan import scan\n \n+import pymc as pm\n+\n from pymc.distributions.continuous import Cauchy\n from pymc.distributions.transforms import _default_transform, log, logodds\n from pymc.logprob.abstract import MeasurableVariable, _logprob\n@@ -1262,3 +1264,14 @@ def test_invalid_broadcasted_transform_rv_fails():\n # This logp derivation should fail or count only once the values that are broadcasted\n logprob = logp(y_rv, y_vv)\n assert logprob.eval({y_vv: [0, 0, 0, 0], loc: [0, 0, 0, 0]}).shape == ()\n+\n+\n+def test_discrete_measurable_cdf_icdf():\n+ p = 0.7\n+ rv = -pm.Bernoulli.dist(p=p)\n+\n+ # A negated Bernoulli has pmf {p if x == -1; 1-p if x == 0; 0 otherwise}\n+ assert pm.logp(rv, -2).eval() == -np.inf # Correct\n+ assert pm.logp(rv, -1).eval() == np.log(p) # Correct\n+ assert pm.logp(rv, 0).eval() == np.log(1 - p) # Correct\n+ assert pm.logp(rv, 1).eval() == -np.inf # Correct\n"}
data/17.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"head_branch": "master", "contributor": "jelmer", "sha_fail": "a36e3c039fb1cd09ddd1729531b1cf9fb99924ab", "sha_success": "cd0990259901351400deda93b529ec601cfa52e8", "language": "Python", "repo_owner": "jelmer", "repo_name": "dulwich", "workflow_name": "Python tests", "workflow_filename": "pythontest.yml", "workflow_path": ".github/workflows/pythontest.yml", "workflow": "name: Python tests\n\non:\n push:\n pull_request:\n schedule:\n - cron: \"0 6 * * *\" # Daily 6AM UTC build\n\njobs:\n test:\n runs-on: ${{ matrix.os }}\n strategy:\n matrix:\n os: [ubuntu-latest, macos-latest, windows-latest]\n python-version:\n [\"3.7\", \"3.8\", \"3.9\", \"3.10\", \"3.11\"]\n fail-fast: false\n\n steps:\n - uses: actions/checkout@v3\n - name: Set up Python ${{ matrix.python-version }}\n uses: actions/setup-python@v4\n with:\n python-version: ${{ matrix.python-version }}\n - name: Install native dependencies (Ubuntu)\n run: sudo apt-get update && sudo apt-get install -y libgpgme-dev libgpg-error-dev\n if: \"matrix.os == 'ubuntu-latest'\"\n - name: Install native dependencies (MacOS)\n run: brew install swig gpgme\n if: \"matrix.os == 'macos-latest'\"\n - name: Install dependencies\n run: |\n python -m pip install --upgrade pip\n pip install --upgrade \".[fastimport,paramiko,https]\"\n - name: Install gpg on supported platforms\n run: pip install --upgrade \".[pgp]\"\n if: \"matrix.os != 'windows-latest' && matrix.python-version != 'pypy3'\"\n - name: Style checks\n run: |\n pip install --upgrade flake8\n python -m flake8\n - name: Typing checks\n run: |\n pip install --upgrade mypy types-paramiko types-requests\n python -m mypy dulwich\n if: \"matrix.python-version != 'pypy3'\"\n - name: Build\n run: |\n python setup.py build_ext -i\n - name: codespell\n run: |\n pip install --upgrade codespell\n codespell --config .codespellrc .\n - name: Coverage test suite run\n run: |\n pip install --upgrade coverage\n python -m coverage run -p -m unittest dulwich.tests.test_suite\n", "logs": " DeprecationWarning)\n....................................ss.s............................................................counting objects: 2, done.\ncopying pack entries: 0/2\ncopying pack entries: 1/2\ncopied 1 pack entries\ngenerating index: 0/2\ngenerating index: 1/2\n127.0.0.1 - - [04/Oct/2023 06:12:31] \"GET /info/refs?service=git-upload-pack HTTP/1.1\" 200 285\n127.0.0.1 - - [04/Oct/2023 06:12:33] \"POST /git-upload-pack HTTP/1.1\" 200 253\n.Push to http://localhost:50010 successful.\nRef refs/heads/master updated\n127.0.0.1 - - [04/Oct/2023 06:12:36] \"GET /info/refs?service=git-receive-pack HTTP/1.1\" 200 195\n127.0.0.1 - - [04/Oct/2023 06:12:38] \"POST /git-receive-pack HTTP/1.1\" 200 52\n..............................ss...........................................................................................s.........................................................s............................................ss....................s..ssss.............................................................................x..................................................s......................................................x..E.......s..s...ss........................ssssssssssssssssssssssssssss.....ssssssssssssssssssssssssssssssssssssssssssssssssssssssss.....sssssssssssssssssssssssssssssssssssssssss\n======================================================================\nERROR: test_incremental_fetch_pack (dulwich.tests.compat.test_client.DulwichTCPClientTest)\n----------------------------------------------------------------------\nTraceback (most recent call last):\n File \"D:\\a\\dulwich\\dulwich\\dulwich\\protocol.py\", line 213, in read_pkt_line\n sizestr = read(4)\n File \"C:\\hostedtoolcache\\windows\\Python\\3.7.9\\x64\\lib\\socket.py\", line 589, in readinto\n return self._sock.recv_into(b)\nConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n File \"D:\\a\\dulwich\\dulwich\\dulwich\\tests\\compat\\test_client.py\", line 279, in test_incremental_fetch_pack\n self.test_fetch_pack()\n File \"D:\\a\\dulwich\\dulwich\\dulwich\\tests\\compat\\test_client.py\", line 227, in test_fetch_pack\n result = c.fetch(self._build_path(\"/server_new.export\"), dest)\n File \"D:\\a\\dulwich\\dulwich\\dulwich\\client.py\", line 822, in fetch\n depth=depth,\n File \"D:\\a\\dulwich\\dulwich\\dulwich\\client.py\", line 1169, in fetch_pack\n progress,\n File \"D:\\a\\dulwich\\dulwich\\dulwich\\client.py\", line 606, in _handle_upload_pack_tail\n for chan, data in _read_side_band64k_data(proto.read_pkt_seq()):\n File \"D:\\a\\dulwich\\dulwich\\dulwich\\client.py\", line 497, in _read_side_band64k_data\n for pkt in pkt_seq:\n File \"D:\\a\\dulwich\\dulwich\\dulwich\\protocol.py\", line 275, in read_pkt_seq\n pkt = self.read_pkt_line()\n File \"D:\\a\\dulwich\\dulwich\\dulwich\\protocol.py\", line 225, in read_pkt_line\n raise HangupException() from exc\ndulwich.errors.HangupException: The remote server unexpectedly closed the connection.\n\n----------------------------------------------------------------------\nRan 1503 tests in 200.654s\n\nFAILED (errors=1, skipped=151, expected failures=2)\n##[error]Process completed with exit code 1.\n", "diff": "diff --git a/dulwich/config.py b/dulwich/config.py\nindex 1a32cba7..2bd10877 100644\n--- a/dulwich/config.py\n+++ b/dulwich/config.py\n@@ -780,9 +780,15 @@ def parse_submodules(config: ConfigFile) -> Iterator[Tuple[bytes, bytes, bytes]]\n for section in config.keys():\n section_kind, section_name = section\n if section_kind == b\"submodule\":\n- sm_path = config.get(section, b\"path\")\n- sm_url = config.get(section, b\"url\")\n- yield (sm_path, sm_url, section_name)\n+ try:\n+ sm_path = config.get(section, b\"path\")\n+ sm_url = config.get(section, b\"url\")\n+ yield (sm_path, sm_url, section_name)\n+ except KeyError:\n+ # If either path or url is missing, just ignore this\n+ # submodule entry and move on to the next one. This is\n+ # how git itself handles malformed .gitmodule entries.\n+ pass\n \n \n def iter_instead_of(config: Config, push: bool = False) -> Iterable[Tuple[str, str]]:\ndiff --git a/dulwich/tests/test_config.py b/dulwich/tests/test_config.py\nindex bae048eb..a0504779 100644\n--- a/dulwich/tests/test_config.py\n+++ b/dulwich/tests/test_config.py\n@@ -423,6 +423,31 @@ class SubmodulesTests(TestCase):\n [submodule \"core/lib\"]\n \\tpath = core/lib\n \\turl = https://github.com/phhusson/QuasselC.git\n+\"\"\"\n+ )\n+ )\n+ got = list(parse_submodules(cf))\n+ self.assertEqual(\n+ [\n+ (\n+ b\"core/lib\",\n+ b\"https://github.com/phhusson/QuasselC.git\",\n+ b\"core/lib\",\n+ )\n+ ],\n+ got,\n+ )\n+\n+ def testMalformedSubmodules(self):\n+ cf = ConfigFile.from_file(\n+ BytesIO(\n+ b\"\"\"\\\n+[submodule \"core/lib\"]\n+\\tpath = core/lib\n+\\turl = https://github.com/phhusson/QuasselC.git\n+\n+[submodule \"dulwich\"]\n+\\turl = https://github.com/jelmer/dulwich\n \"\"\"\n )\n )\n"}
data/18.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"head_branch": "fix-percent-true-2", "contributor": "alteryx", "sha_fail": "f0a5812487ba8e8cfe9cd5eb28cb71977619259f", "sha_success": "b0630043ffac825c46d3a99e1b1ce4d86731839f", "language": "Python", "repo_owner": "alteryx", "repo_name": "featuretools", "workflow_name": "Release Notes Updated", "workflow_filename": "release_notes_updated.yaml", "workflow_path": ".github/workflows/release_notes_updated.yaml", "workflow": "name: Release Notes Updated\non:\n pull_request:\n types: [opened, synchronize]\njobs:\n release_notes_updated:\n name: release notes updated\n runs-on: ubuntu-latest\n steps:\n - name: Check for development branch\n id: branch\n shell: python\n run: |\n from re import compile\n main = '^main$'\n release = '^release_v\\d+\\.\\d+\\.\\d+$'\n backport = '^backport_v\\d+\\.\\d+\\.\\d+$'\n dep_update = '^latest-dep-update-[a-f0-9]{7}$'\n min_dep_update = '^min-dep-update-[a-f0-9]{7}$'\n regex = main, release, backport, dep_update, min_dep_update\n patterns = list(map(compile, regex))\n ref = \"${{ github.event.pull_request.head.ref }}\"\n is_dev = not any(pattern.match(ref) for pattern in patterns)\n print('::set-output name=is_dev::' + str(is_dev))\n - if: ${{ steps.branch.outputs.is_dev == 'true' }}\n name: Checkout repository\n uses: actions/checkout@v3\n with:\n ref: ${{ github.event.pull_request.head.ref }}\n repository: ${{ github.event.pull_request.head.repo.full_name }}\n - if: ${{ steps.branch.outputs.is_dev == 'true' }}\n name: Check if release notes were updated\n run: cat docs/source/release_notes.rst | grep \":pr:\\`${{ github.event.number }}\\`\"\n \n", "logs": "##[group]Run cat docs/source/release_notes.rst | grep \":pr:\\`2627\\`\"\n\u001b[36;1mcat docs/source/release_notes.rst | grep \":pr:\\`2627\\`\"\u001b[0m\nshell: /usr/bin/bash -e {0}\n##[endgroup]\n##[error]Process completed with exit code 1.\n", "diff": "diff --git a/docs/source/release_notes.rst b/docs/source/release_notes.rst\nindex 79aa960e..8d0b1686 100644\n--- a/docs/source/release_notes.rst\n+++ b/docs/source/release_notes.rst\n@@ -7,7 +7,7 @@ Future Release\n ==============\n * Enhancements\n * Fixes\n- * Fix bug with default value in ``PercentTrue`` primitive (:pr:`2626`)\n+ * Fix bug with default value in ``PercentTrue`` primitive (:pr:`2627`)\n * Changes\n * Refactor ``featuretools/tests/primitive_tests/utils.py`` to leverage list comprehensions for improved Pythonic quality (:pr:`2607`)\n * Refactor ``can_stack_primitive_on_inputs`` (:pr:`2522`)\n"}
data/2.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"head_branch": "cumulative", "contributor": "max-sixty", "sha_fail": "0ef192072cb4433dbc4524dee1041eadc20d086a", "sha_success": "bc99a661d07d7a33a6f95db78e9fdbfa22939c88", "language": "Python", "repo_owner": "pydata", "repo_name": "xarray", "workflow_name": "CI Additional", "workflow_filename": "ci-additional.yaml", "workflow_path": ".github/workflows/ci-additional.yaml", "workflow": "name: CI Additional\non:\n push:\n branches:\n - \"main\"\n pull_request:\n branches:\n - \"main\"\n workflow_dispatch: # allows you to trigger manually\n\nconcurrency:\n group: ${{ github.workflow }}-${{ github.ref }}\n cancel-in-progress: true\n\njobs:\n detect-ci-trigger:\n name: detect ci trigger\n runs-on: ubuntu-latest\n if: |\n github.repository == 'pydata/xarray'\n && (github.event_name == 'push' || github.event_name == 'pull_request')\n outputs:\n triggered: ${{ steps.detect-trigger.outputs.trigger-found }}\n steps:\n - uses: actions/checkout@v4\n with:\n fetch-depth: 2\n - uses: xarray-contrib/ci-trigger@v1\n id: detect-trigger\n with:\n keyword: \"[skip-ci]\"\n\n doctest:\n name: Doctests\n runs-on: \"ubuntu-latest\"\n needs: detect-ci-trigger\n if: needs.detect-ci-trigger.outputs.triggered == 'false'\n defaults:\n run:\n shell: bash -l {0}\n\n env:\n CONDA_ENV_FILE: ci/requirements/environment.yml\n PYTHON_VERSION: \"3.11\"\n\n steps:\n - uses: actions/checkout@v4\n with:\n fetch-depth: 0 # Fetch all history for all branches and tags.\n\n - name: set environment variables\n run: |\n echo \"TODAY=$(date +'%Y-%m-%d')\" >> $GITHUB_ENV\n\n - name: Setup micromamba\n uses: mamba-org/setup-micromamba@v1\n with:\n environment-file: ${{env.CONDA_ENV_FILE}}\n environment-name: xarray-tests\n create-args: >-\n python=${{env.PYTHON_VERSION}}\n conda\n cache-environment: true\n cache-environment-key: \"${{runner.os}}-${{runner.arch}}-py${{env.PYTHON_VERSION}}-${{env.TODAY}}-${{hashFiles(env.CONDA_ENV_FILE)}}\"\n\n - name: Install xarray\n run: |\n python -m pip install --no-deps -e .\n - name: Version info\n run: |\n conda info -a\n conda list\n python xarray/util/print_versions.py\n - name: Run doctests\n run: |\n # Raise an error if there are warnings in the doctests, with `-Werror`.\n # This is a trial; if it presents an problem, feel free to remove.\n # See https://github.com/pydata/xarray/issues/7164 for more info.\n python -m pytest --doctest-modules xarray --ignore xarray/tests -Werror\n\n mypy:\n name: Mypy\n runs-on: \"ubuntu-latest\"\n needs: detect-ci-trigger\n defaults:\n run:\n shell: bash -l {0}\n env:\n CONDA_ENV_FILE: ci/requirements/environment.yml\n PYTHON_VERSION: \"3.11\"\n\n steps:\n - uses: actions/checkout@v4\n with:\n fetch-depth: 0 # Fetch all history for all branches and tags.\n\n - name: set environment variables\n run: |\n echo \"TODAY=$(date +'%Y-%m-%d')\" >> $GITHUB_ENV\n - name: Setup micromamba\n uses: mamba-org/setup-micromamba@v1\n with:\n environment-file: ${{env.CONDA_ENV_FILE}}\n environment-name: xarray-tests\n create-args: >-\n python=${{env.PYTHON_VERSION}}\n conda\n cache-environment: true\n cache-environment-key: \"${{runner.os}}-${{runner.arch}}-py${{env.PYTHON_VERSION}}-${{env.TODAY}}-${{hashFiles(env.CONDA_ENV_FILE)}}\"\n - name: Install xarray\n run: |\n python -m pip install --no-deps -e .\n - name: Version info\n run: |\n conda info -a\n conda list\n python xarray/util/print_versions.py\n - name: Install mypy\n run: |\n python -m pip install \"mypy<1.8\" --force-reinstall\n\n - name: Run mypy\n run: |\n python -m mypy --install-types --non-interactive --cobertura-xml-report mypy_report xarray/\n\n - name: Upload mypy coverage to Codecov\n uses: codecov/[email protected]\n with:\n file: mypy_report/cobertura.xml\n flags: mypy\n env_vars: PYTHON_VERSION\n name: codecov-umbrella\n fail_ci_if_error: false\n\n mypy39:\n name: Mypy 3.9\n runs-on: \"ubuntu-latest\"\n needs: detect-ci-trigger\n defaults:\n run:\n shell: bash -l {0}\n env:\n CONDA_ENV_FILE: ci/requirements/environment.yml\n PYTHON_VERSION: \"3.9\"\n\n steps:\n - uses: actions/checkout@v4\n with:\n fetch-depth: 0 # Fetch all history for all branches and tags.\n\n - name: set environment variables\n run: |\n echo \"TODAY=$(date +'%Y-%m-%d')\" >> $GITHUB_ENV\n - name: Setup micromamba\n uses: mamba-org/setup-micromamba@v1\n with:\n environment-file: ${{env.CONDA_ENV_FILE}}\n environment-name: xarray-tests\n create-args: >-\n python=${{env.PYTHON_VERSION}}\n conda\n cache-environment: true\n cache-environment-key: \"${{runner.os}}-${{runner.arch}}-py${{env.PYTHON_VERSION}}-${{env.TODAY}}-${{hashFiles(env.CONDA_ENV_FILE)}}\"\n - name: Install xarray\n run: |\n python -m pip install --no-deps -e .\n - name: Version info\n run: |\n conda info -a\n conda list\n python xarray/util/print_versions.py\n - name: Install mypy\n run: |\n python -m pip install \"mypy<1.8\" --force-reinstall\n\n - name: Run mypy\n run: |\n python -m mypy --install-types --non-interactive --cobertura-xml-report mypy_report xarray/\n\n - name: Upload mypy coverage to Codecov\n uses: codecov/[email protected]\n with:\n file: mypy_report/cobertura.xml\n flags: mypy39\n env_vars: PYTHON_VERSION\n name: codecov-umbrella\n fail_ci_if_error: false\n\n\n\n pyright:\n name: Pyright\n runs-on: \"ubuntu-latest\"\n needs: detect-ci-trigger\n if: |\n always()\n && (\n contains( github.event.pull_request.labels.*.name, 'run-pyright')\n )\n defaults:\n run:\n shell: bash -l {0}\n env:\n CONDA_ENV_FILE: ci/requirements/environment.yml\n PYTHON_VERSION: \"3.10\"\n\n steps:\n - uses: actions/checkout@v4\n with:\n fetch-depth: 0 # Fetch all history for all branches and tags.\n\n - name: set environment variables\n run: |\n echo \"TODAY=$(date +'%Y-%m-%d')\" >> $GITHUB_ENV\n - name: Setup micromamba\n uses: mamba-org/setup-micromamba@v1\n with:\n environment-file: ${{env.CONDA_ENV_FILE}}\n environment-name: xarray-tests\n create-args: >-\n python=${{env.PYTHON_VERSION}}\n conda\n cache-environment: true\n cache-environment-key: \"${{runner.os}}-${{runner.arch}}-py${{env.PYTHON_VERSION}}-${{env.TODAY}}-${{hashFiles(env.CONDA_ENV_FILE)}}\"\n - name: Install xarray\n run: |\n python -m pip install --no-deps -e .\n - name: Version info\n run: |\n conda info -a\n conda list\n python xarray/util/print_versions.py\n - name: Install pyright\n run: |\n python -m pip install pyright --force-reinstall\n\n - name: Run pyright\n run: |\n python -m pyright xarray/\n\n - name: Upload pyright coverage to Codecov\n uses: codecov/[email protected]\n with:\n file: pyright_report/cobertura.xml\n flags: pyright\n env_vars: PYTHON_VERSION\n name: codecov-umbrella\n fail_ci_if_error: false\n\n pyright39:\n name: Pyright 3.9\n runs-on: \"ubuntu-latest\"\n needs: detect-ci-trigger\n if: |\n always()\n && (\n contains( github.event.pull_request.labels.*.name, 'run-pyright')\n )\n defaults:\n run:\n shell: bash -l {0}\n env:\n CONDA_ENV_FILE: ci/requirements/environment.yml\n PYTHON_VERSION: \"3.9\"\n\n steps:\n - uses: actions/checkout@v4\n with:\n fetch-depth: 0 # Fetch all history for all branches and tags.\n\n - name: set environment variables\n run: |\n echo \"TODAY=$(date +'%Y-%m-%d')\" >> $GITHUB_ENV\n - name: Setup micromamba\n uses: mamba-org/setup-micromamba@v1\n with:\n environment-file: ${{env.CONDA_ENV_FILE}}\n environment-name: xarray-tests\n create-args: >-\n python=${{env.PYTHON_VERSION}}\n conda\n cache-environment: true\n cache-environment-key: \"${{runner.os}}-${{runner.arch}}-py${{env.PYTHON_VERSION}}-${{env.TODAY}}-${{hashFiles(env.CONDA_ENV_FILE)}}\"\n - name: Install xarray\n run: |\n python -m pip install --no-deps -e .\n - name: Version info\n run: |\n conda info -a\n conda list\n python xarray/util/print_versions.py\n - name: Install pyright\n run: |\n python -m pip install pyright --force-reinstall\n\n - name: Run pyright\n run: |\n python -m pyright xarray/\n\n - name: Upload pyright coverage to Codecov\n uses: codecov/[email protected]\n with:\n file: pyright_report/cobertura.xml\n flags: pyright39\n env_vars: PYTHON_VERSION\n name: codecov-umbrella\n fail_ci_if_error: false\n\n\n\n min-version-policy:\n name: Minimum Version Policy\n runs-on: \"ubuntu-latest\"\n needs: detect-ci-trigger\n if: needs.detect-ci-trigger.outputs.triggered == 'false'\n defaults:\n run:\n shell: bash -l {0}\n\n strategy:\n matrix:\n environment-file: [\"bare-minimum\", \"min-all-deps\"]\n fail-fast: false\n\n steps:\n - uses: actions/checkout@v4\n with:\n fetch-depth: 0 # Fetch all history for all branches and tags.\n\n - name: Setup micromamba\n uses: mamba-org/setup-micromamba@v1\n with:\n environment-name: xarray-tests\n create-args: >-\n python=3.11\n pyyaml\n conda\n python-dateutil\n\n - name: minimum versions policy\n run: |\n python ci/min_deps_check.py ci/requirements/${{ matrix.environment-file }}.yml\n", "logs": "xarray/core/combine.py .. [ 42%]\nxarray/core/common.py ........... [ 45%]\nxarray/core/computation.py ...... [ 47%]\nxarray/core/concat.py . [ 48%]\nxarray/core/coordinates.py .. [ 48%]\nxarray/core/dataarray.py .........F..................................... [ 64%]\n........ [ 67%]\nxarray/core/dataset.py ............................................ [ 82%]\nxarray/core/extensions.py . [ 82%]\nxarray/core/groupby.py . [ 82%]\nxarray/core/indexing.py ... [ 83%]\nxarray/core/merge.py . [ 84%]\nxarray/core/options.py . [ 84%]\nxarray/core/parallel.py . [ 84%]\nxarray/core/rolling.py .... [ 86%]\nxarray/core/rolling_exp.py ...... [ 88%]\nxarray/core/utils.py . [ 88%]\nxarray/core/variable.py ... [ 89%]\nxarray/namedarray/_aggregations.py ............. [ 93%]\nxarray/namedarray/_array_api.py .... [ 95%]\nxarray/namedarray/core.py . [ 95%]\nxarray/plot/dataarray_plot.py . [ 95%]\nxarray/plot/facetgrid.py .. [ 96%]\nxarray/plot/utils.py .......... [100%]\n\n=================================== FAILURES ===================================\n______________ [doctest] xarray.core.dataarray.DataArray.curvefit ______________\n6318 0.04744543, 0.03602333, 0.03129354, 0.01074885, 0.01284436,\n6319 0.00910995]])\n6320 Coordinates:\n6321 * x (x) int64 0 1 2\n6322 * time (time) int64 0 1 2 3 4 5 6 7 8 9 10\n6323 \n6324 Fit the exponential decay function to the data along the ``time`` dimension:\n6325 \n6326 >>> fit_result = da.curvefit(\"time\", exp_decay)\n6327 >>> fit_result[\"curvefit_coefficients\"].sel(\nDifferences (unified diff with -expected +actual):\n @@ -1,4 +1,4 @@\n <xarray.DataArray 'curvefit_coefficients' (x: 3)>\n -array([1.05692035, 1.73549638, 2.9421577 ])\n +array([1.05692036, 1.73549638, 2.94215771])\n Coordinates:\n * x (x) int64 0 1 2\n\n/home/runner/work/xarray/xarray/xarray/core/dataarray.py:6327: DocTestFailure\n=========================== short test summary info ============================\nFAILED xarray/core/dataarray.py::xarray.core.dataarray.DataArray.curvefit\n=================== 1 failed, 297 passed in 64.59s (0:01:04) ===================\n##[error]Process completed with exit code 1.\n", "diff": "diff --git a/doc/api.rst b/doc/api.rst\nindex 24c3aee7..38844f22 100644\n--- a/doc/api.rst\n+++ b/doc/api.rst\n@@ -182,6 +182,7 @@ Computation\n Dataset.groupby_bins\n Dataset.rolling\n Dataset.rolling_exp\n+ Dataset.cumulative\n Dataset.weighted\n Dataset.coarsen\n Dataset.resample\n@@ -378,6 +379,7 @@ Computation\n DataArray.groupby_bins\n DataArray.rolling\n DataArray.rolling_exp\n+ DataArray.cumulative\n DataArray.weighted\n DataArray.coarsen\n DataArray.resample\ndiff --git a/xarray/core/dataarray.py b/xarray/core/dataarray.py\nindex 4533ea7d..7db2eeaa 100644\n--- a/xarray/core/dataarray.py\n+++ b/xarray/core/dataarray.py\n@@ -6328,7 +6328,7 @@ class DataArray(\n ... param=\"time_constant\"\n ... ) # doctest: +NUMBER\n <xarray.DataArray 'curvefit_coefficients' (x: 3)>\n- array([1.05692035, 1.73549638, 2.9421577 ])\n+ array([1.0569203, 1.7354963, 2.9421577])\n Coordinates:\n * x (x) int64 0 1 2\n param <U13 'time_constant'\n@@ -6895,14 +6895,90 @@ class DataArray(\n \n See Also\n --------\n- core.rolling.DataArrayRolling\n+ DataArray.cumulative\n Dataset.rolling\n+ core.rolling.DataArrayRolling\n \"\"\"\n from xarray.core.rolling import DataArrayRolling\n \n dim = either_dict_or_kwargs(dim, window_kwargs, \"rolling\")\n return DataArrayRolling(self, dim, min_periods=min_periods, center=center)\n \n+ def cumulative(\n+ self,\n+ dim: str | Iterable[Hashable],\n+ min_periods: int | None = 1,\n+ ) -> DataArrayRolling:\n+ \"\"\"\n+ Rolling window object for DataArrays.\n+\n+ Parameters\n+ ----------\n+ dims : iterable of hashable\n+ The name(s) of the dimensions to create the cumulative window along\n+ min_periods : int or None, default: None\n+ Minimum number of observations in window required to have a value\n+ (otherwise result is NA). The default is 1 (note this is different\n+ from ``Rolling``, whose default is the size of the window).\n+\n+ Returns\n+ -------\n+ core.rolling.DataArrayRolling\n+\n+ Examples\n+ --------\n+ Create rolling seasonal average of monthly data e.g. DJF, JFM, ..., SON:\n+\n+ >>> da = xr.DataArray(\n+ ... np.linspace(0, 11, num=12),\n+ ... coords=[\n+ ... pd.date_range(\n+ ... \"1999-12-15\",\n+ ... periods=12,\n+ ... freq=pd.DateOffset(months=1),\n+ ... )\n+ ... ],\n+ ... dims=\"time\",\n+ ... )\n+\n+ >>> da\n+ <xarray.DataArray (time: 12)>\n+ array([ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11.])\n+ Coordinates:\n+ * time (time) datetime64[ns] 1999-12-15 2000-01-15 ... 2000-11-15\n+\n+ >>> da.cumulative(\"time\").sum()\n+ <xarray.DataArray (time: 12)>\n+ array([ 0., 1., 3., 6., 10., 15., 21., 28., 36., 45., 55., 66.])\n+ Coordinates:\n+ * time (time) datetime64[ns] 1999-12-15 2000-01-15 ... 2000-11-15\n+\n+ See Also\n+ --------\n+ DataArray.rolling\n+ Dataset.cumulative\n+ core.rolling.DataArrayRolling\n+ \"\"\"\n+ from xarray.core.rolling import DataArrayRolling\n+\n+ # Could we abstract this \"normalize and check 'dim'\" logic? It's currently shared\n+ # with the same method in Dataset.\n+ if isinstance(dim, str):\n+ if dim not in self.dims:\n+ raise ValueError(\n+ f\"Dimension {dim} not found in data dimensions: {self.dims}\"\n+ )\n+ dim = {dim: self.sizes[dim]}\n+ else:\n+ missing_dims = set(dim) - set(self.dims)\n+ if missing_dims:\n+ raise ValueError(\n+ f\"Dimensions {missing_dims} not found in data dimensions: {self.dims}\"\n+ )\n+ dim = {d: self.sizes[d] for d in dim}\n+\n+ return DataArrayRolling(self, dim, min_periods=min_periods or 1, center=False)\n+\n def coarsen(\n self,\n dim: Mapping[Any, int] | None = None,\ndiff --git a/xarray/core/dataset.py b/xarray/core/dataset.py\nindex d010bfba..03269007 100644\n--- a/xarray/core/dataset.py\n+++ b/xarray/core/dataset.py\n@@ -10272,14 +10272,60 @@ class Dataset(\n \n See Also\n --------\n- core.rolling.DatasetRolling\n+ Dataset.cumulative\n DataArray.rolling\n+ core.rolling.DatasetRolling\n \"\"\"\n from xarray.core.rolling import DatasetRolling\n \n dim = either_dict_or_kwargs(dim, window_kwargs, \"rolling\")\n return DatasetRolling(self, dim, min_periods=min_periods, center=center)\n \n+ def cumulative(\n+ self,\n+ dim: str | Iterable[Hashable],\n+ min_periods: int | None = 1,\n+ ) -> DatasetRolling:\n+ \"\"\"\n+ Rolling window object for Datasets\n+\n+ Parameters\n+ ----------\n+ dims : iterable of hashable\n+ The name(s) of the dimensions to create the cumulative window along\n+ min_periods : int or None, default: None\n+ Minimum number of observations in window required to have a value\n+ (otherwise result is NA). The default is 1 (note this is different\n+ from ``Rolling``, whose default is the size of the window).\n+\n+ Returns\n+ -------\n+ core.rolling.DatasetRolling\n+\n+ See Also\n+ --------\n+ Dataset.rolling\n+ DataArray.cumulative\n+ core.rolling.DatasetRolling\n+ \"\"\"\n+ from xarray.core.rolling import DatasetRolling\n+\n+ if isinstance(dim, str):\n+ if dim not in self.dims:\n+ raise ValueError(\n+ f\"Dimension {dim} not found in data dimensions: {self.dims}\"\n+ )\n+ dim = {dim: self.sizes[dim]}\n+ else:\n+ missing_dims = set(dim) - set(self.dims)\n+ if missing_dims:\n+ raise ValueError(\n+ f\"Dimensions {missing_dims} not found in data dimensions: {self.dims}\"\n+ )\n+ dim = {d: self.sizes[d] for d in dim}\n+\n+ return DatasetRolling(self, dim, min_periods=min_periods or 1, center=False)\n+\n def coarsen(\n self,\n dim: Mapping[Any, int] | None = None,\ndiff --git a/xarray/tests/test_rolling.py b/xarray/tests/test_rolling.py\nindex cb7b723a..d019e52d 100644\n--- a/xarray/tests/test_rolling.py\n+++ b/xarray/tests/test_rolling.py\n@@ -461,6 +461,24 @@ class TestDataArrayRollingExp:\n ):\n da.rolling_exp(time=10, keep_attrs=True)\n \n+ @pytest.mark.parametrize(\"func\", [\"mean\", \"sum\"])\n+ @pytest.mark.parametrize(\"min_periods\", [None, 1, 20])\n+ def test_cumulative(self, da, func, min_periods) -> None:\n+ # One dim\n+ result = getattr(da.cumulative(\"time\", min_periods=min_periods), func)()\n+ expected = getattr(\n+ da.rolling(time=da.time.size, min_periods=min_periods or 1), func\n+ )()\n+ assert_identical(result, expected)\n+\n+ # Multiple dim\n+ result = getattr(da.cumulative([\"time\", \"a\"], min_periods=min_periods), func)()\n+ expected = getattr(\n+ da.rolling(time=da.time.size, a=da.a.size, min_periods=min_periods or 1),\n+ func,\n+ )()\n+ assert_identical(result, expected)\n+\n \n class TestDatasetRolling:\n @pytest.mark.parametrize(\n@@ -785,6 +803,25 @@ class TestDatasetRolling:\n expected = getattr(getattr(ds.rolling(time=4), name)().rolling(x=3), name)()\n assert_allclose(actual, expected)\n \n+ @pytest.mark.parametrize(\"func\", [\"mean\", \"sum\"])\n+ @pytest.mark.parametrize(\"ds\", (2,), indirect=True)\n+ @pytest.mark.parametrize(\"min_periods\", [None, 1, 20])\n+ def test_cumulative(self, ds, func, min_periods) -> None:\n+ # One dim\n+ result = getattr(ds.cumulative(\"time\", min_periods=min_periods), func)()\n+ expected = getattr(\n+ ds.rolling(time=ds.time.size, min_periods=min_periods or 1), func\n+ )()\n+ assert_identical(result, expected)\n+\n+ # Multiple dim\n+ result = getattr(ds.cumulative([\"time\", \"x\"], min_periods=min_periods), func)()\n+ expected = getattr(\n+ ds.rolling(time=ds.time.size, x=ds.x.size, min_periods=min_periods or 1),\n+ func,\n+ )()\n+ assert_identical(result, expected)\n+\n \n @requires_numbagg\n class TestDatasetRollingExp:\n"}
data/3.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"head_branch": "templates", "contributor": "sepandhaghighi", "sha_fail": "47ad548c15613c32f12b38e004ee58a36178f631", "sha_success": "92c0053fc684fd1ec008b733c2e45db08321f0e6", "language": "Python", "repo_owner": "sepandhaghighi", "repo_name": "pycm", "workflow_name": "CI", "workflow_filename": "test.yml", "workflow_path": ".github/workflows/test.yml", "workflow": "# This workflow will install Python dependencies, run tests and lint with a variety of Python versions\n# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions\n\nname: CI\n\non: [push, pull_request]\n\nenv:\n TEST_PYTHON_VERSION: 3.9\n TEST_OS: 'ubuntu-20.04'\n\njobs:\n build:\n\n runs-on: ${{ matrix.os }}\n strategy:\n matrix:\n os: [ubuntu-20.04, windows-2022, macOS-12]\n python-version: [3.6, 3.7.9, 3.8, 3.9, 3.10.0, 3.11.0]\n steps:\n - uses: actions/checkout@v2\n - name: Set up Python ${{ matrix.python-version }}\n uses: actions/setup-python@v2\n with:\n python-version: ${{ matrix.python-version }}\n - name: Installation\n run: |\n python -m pip install --upgrade pip\n pip install -r requirements.txt\n python setup.py install\n - name: First test\n run: |\n python -m pycm test\n python -m pycm\n - name: Test requirements Installation\n run: |\n python Otherfiles/requirements-splitter.py\n pip install --upgrade --upgrade-strategy=only-if-needed -r test-requirements.txt\n - name: Test with pytest\n run: |\n python -m pytest --cov=pycm --cov-report=term\n - name: Version check\n run: |\n python Otherfiles/version_check.py\n if: matrix.python-version == env.TEST_PYTHON_VERSION\n - name: Notebook check\n run: |\n pip install notebook>=5.2.2\n python Otherfiles/notebook_check.py\n if: matrix.python-version == env.TEST_PYTHON_VERSION && matrix.os == env.TEST_OS\n - name: Other tests\n run: |\n python -m vulture pycm/ Otherfiles/ setup.py --min-confidence 65 --exclude=__init__.py --sort-by-size\n python -m bandit -r pycm -s B311\n python -m pydocstyle -v --match-dir=pycm\n if: matrix.python-version == env.TEST_PYTHON_VERSION\n - name: Upload coverage to Codecov\n uses: codecov/codecov-action@v3\n with:\n fail_ci_if_error: false\n if: matrix.python-version == env.TEST_PYTHON_VERSION && matrix.os == env.TEST_OS\n - name: cProfile\n run: |\n python -m cProfile -s cumtime pycm/pycm_profile.py\n", "logs": "##[group]Run python Otherfiles/version_check.py\n\u001b[36;1mpython Otherfiles/version_check.py\u001b[0m\nshell: /usr/bin/bash -e {0}\nenv:\n TEST_PYTHON_VERSION: 3.9\n TEST_OS: ubuntu-20.04\n pythonLocation: /opt/hostedtoolcache/Python/3.9.18/x64\n LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.18/x64/lib\n##[endgroup]\nError in .github/ISSUE_TEMPLATE/bug_report.yaml\nMessage : [Errno 2] No such file or directory: '.github/ISSUE_TEMPLATE/bug_report.yaml'\n\nVersion tag tests failed!\nPassed : 10/11\n##[error]Process completed with exit code 1.\n", "diff": "diff --git a/CHANGELOG.md b/CHANGELOG.md\nindex de22bc3..df0e376 100644\n--- a/CHANGELOG.md\n+++ b/CHANGELOG.md\n@@ -6,7 +6,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.\n \n ## [Unreleased]\n ### Added\n-- `feature_request.yaml` template\n+- `feature_request.yml` template\n - `config.yml` for issue template\n ### Changed\n - Bug report template modified\ndiff --git a/Otherfiles/version_check.py b/Otherfiles/version_check.py\nindex a6605c1..6a5c3ee 100644\n--- a/Otherfiles/version_check.py\n+++ b/Otherfiles/version_check.py\n@@ -35,7 +35,7 @@ FILES = {\n os.path.join(\"Document\", \"Example1_files\", \"cm3.html\"): HTML_ITEMS,\n os.path.join(\"Otherfiles\", \"test.html\"): HTML_ITEMS,\n os.path.join(\"pycm\", \"pycm_param.py\"): PARAMS_ITEMS,\n- os.path.join(\".github\", \"ISSUE_TEMPLATE\", \"bug_report.yaml\"): ISSUE_TEMPLATE_ITEMS,\n+ os.path.join(\".github\", \"ISSUE_TEMPLATE\", \"bug_report.yml\"): ISSUE_TEMPLATE_ITEMS,\n }\n \n TEST_NUMBER = len(FILES.keys())\n"}
data/4.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"head_branch": "master", "contributor": "philipclaesson", "sha_fail": "26f51fa3c88a651ae93633048ce7a11c74f335d8", "sha_success": "8d46775b9b73eb4100895ecba6507451e75945e2", "language": "Python", "repo_owner": "permitio", "repo_name": "opal", "workflow_name": "pre-commit", "workflow_filename": "pre-commit.yml", "workflow_path": ".github/workflows/pre-commit.yml", "workflow": "name: pre-commit\n\non:\n pull_request:\n push:\n branches: [master, main]\n\njobs:\n pre-commit:\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@v3\n - uses: actions/setup-python@v4\n with:\n python-version: 3.x\n - uses: pre-commit/[email protected]\n", "logs": "[INFO]\u001b[m Initializing environment for https://github.com/pre-commit/pre-commit-hooks.\n[INFO]\u001b[m Initializing environment for https://github.com/psf/black.\n[INFO]\u001b[m Initializing environment for https://github.com/pycqa/isort.\n[INFO]\u001b[m Initializing environment for https://github.com/codespell-project/codespell.\n[INFO]\u001b[m Initializing environment for https://github.com/myint/docformatter.\n[INFO]\u001b[m Installing environment for https://github.com/pre-commit/pre-commit-hooks.\n[INFO]\u001b[m Once installed this environment will be reused.\n[INFO]\u001b[m This may take a few minutes...\n[INFO]\u001b[m Installing environment for https://github.com/psf/black.\n[INFO]\u001b[m Once installed this environment will be reused.\n[INFO]\u001b[m This may take a few minutes...\n[INFO]\u001b[m Installing environment for https://github.com/pycqa/isort.\n[INFO]\u001b[m Once installed this environment will be reused.\n[INFO]\u001b[m This may take a few minutes...\n[INFO]\u001b[m Installing environment for https://github.com/codespell-project/codespell.\n[INFO]\u001b[m Once installed this environment will be reused.\n[INFO]\u001b[m This may take a few minutes...\n[INFO]\u001b[m Installing environment for https://github.com/myint/docformatter.\n[INFO]\u001b[m Once installed this environment will be reused.\n[INFO]\u001b[m This may take a few minutes...\ncheck yaml...............................................................\u001b[42mPassed\u001b[m\nfix end of files.........................................................\u001b[42mPassed\u001b[m\ntrim trailing whitespace.................................................\u001b[42mPassed\u001b[m\nblack....................................................................\u001b[42mPassed\u001b[m\nisort....................................................................\u001b[41mFailed\u001b[m\n\u001b[2m- hook id: isort\u001b[m\n\u001b[2m- files were modified by this hook\u001b[m\n\nFixing /home/runner/work/opal/opal/packages/opal-common/opal_common/git/branch_tracker.py\n\ncodespell................................................................\u001b[42mPassed\u001b[m\ndocformatter.............................................................\u001b[42mPassed\u001b[m\npre-commit hook(s) made changes.\nIf you are seeing this message in CI, reproduce locally with: `pre-commit run --all-files`.\nTo run `pre-commit` as part of git workflow, use `pre-commit install`.\nAll changes made by hooks:\n\u001b[1mdiff --git a/packages/opal-common/opal_common/git/branch_tracker.py b/packages/opal-common/opal_common/git/branch_tracker.py\u001b[m\n\u001b[1mindex 9f7021d..3c8b374 100644\u001b[m\n\u001b[1m--- a/packages/opal-common/opal_common/git/branch_tracker.py\u001b[m\n\u001b[1m+++ b/packages/opal-common/opal_common/git/branch_tracker.py\u001b[m\n\u001b[36m@@ -1,7 +1,7 @@\u001b[m\n from functools import partial\u001b[m\n from typing import Optional, Tuple\u001b[m\n \u001b[m\n\u001b[31m-from git import GitCommandError, Head, Remote, Repo, Reference\u001b[m\n\u001b[32m+\u001b[m\u001b[32mfrom git import GitCommandError, Head, Reference, Remote, Repo\u001b[m\n from git.objects.commit import Commit\u001b[m\n from opal_common.git.env import provide_git_ssh_environment\u001b[m\n from opal_common.git.exceptions import GitFailed\u001b[m\n##[error]Process completed with exit code 1.\n", "diff": "diff --git a/packages/opal-common/opal_common/git/branch_tracker.py b/packages/opal-common/opal_common/git/branch_tracker.py\nindex 9f7021d..3c8b374 100644\n--- a/packages/opal-common/opal_common/git/branch_tracker.py\n+++ b/packages/opal-common/opal_common/git/branch_tracker.py\n@@ -1,7 +1,7 @@\n from functools import partial\n from typing import Optional, Tuple\n \n-from git import GitCommandError, Head, Remote, Repo, Reference\n+from git import GitCommandError, Head, Reference, Remote, Repo\n from git.objects.commit import Commit\n from opal_common.git.env import provide_git_ssh_environment\n from opal_common.git.exceptions import GitFailed\n"}
data/5.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"head_branch": "master", "contributor": "getsentry", "sha_fail": "f067af29826a2f765ef43c11734ca01d255271fe", "sha_success": "53a67e0bfc6a7624d3f1a062e5269014ff3be39c", "language": "Python", "repo_owner": "getsentry", "repo_name": "sentry-python", "workflow_name": "CI", "workflow_filename": "ci.yml", "workflow_path": ".github/workflows/ci.yml", "workflow": "name: CI\n\non:\n push:\n branches:\n - master\n - release/**\n\n pull_request:\n\npermissions:\n contents: read\n\nenv:\n BUILD_CACHE_KEY: ${{ github.sha }}\n CACHED_BUILD_PATHS: |\n ${{ github.workspace }}/dist-serverless\n\njobs:\n lint:\n name: Lint Sources\n runs-on: ubuntu-latest\n timeout-minutes: 10\n\n steps:\n - uses: actions/checkout@v4\n - uses: actions/setup-python@v4\n with:\n python-version: 3.11\n\n - run: |\n pip install tox\n tox -e linters\n\n check-ci-config:\n name: Check CI config\n runs-on: ubuntu-latest\n timeout-minutes: 10\n\n steps:\n - uses: actions/checkout@v4\n - uses: actions/setup-python@v4\n with:\n python-version: 3.9\n\n - run: |\n python scripts/split-tox-gh-actions/split-tox-gh-actions.py --fail-on-changes\n\n build_lambda_layer:\n name: Build Package\n runs-on: ubuntu-latest\n timeout-minutes: 10\n\n steps:\n - uses: actions/checkout@v4\n - uses: actions/setup-python@v4\n with:\n python-version: 3.9\n - name: Setup build cache\n uses: actions/cache@v3\n id: build_cache\n with:\n path: ${{ env.CACHED_BUILD_PATHS }}\n key: ${{ env.BUILD_CACHE_KEY }}\n - name: Build Packages\n run: |\n echo \"Creating directory containing Python SDK Lambda Layer\"\n pip install virtualenv\n # This will also trigger \"make dist\" that creates the Python packages\n make aws-lambda-layer\n - name: Upload Python Packages\n uses: actions/upload-artifact@v3\n with:\n name: ${{ github.sha }}\n path: |\n dist/*\n\n docs:\n name: Build SDK API Doc\n runs-on: ubuntu-latest\n timeout-minutes: 10\n\n steps:\n - uses: actions/checkout@v4\n - uses: actions/setup-python@v4\n with:\n python-version: 3.11\n\n - run: |\n pip install virtualenv\n make apidocs\n cd docs/_build && zip -r gh-pages ./\n\n - uses: actions/[email protected]\n with:\n name: ${{ github.sha }}\n path: docs/_build/gh-pages.zip\n", "logs": " Downloading virtualenv-20.24.5-py3-none-any.whl.metadata (4.5 kB)\nCollecting distlib<1,>=0.3.7 (from virtualenv>=20.24.3->tox)\n Obtaining dependency information for distlib<1,>=0.3.7 from https://files.pythonhosted.org/packages/43/a0/9ba967fdbd55293bacfc1507f58e316f740a3b231fc00e3d86dc39bc185a/distlib-0.3.7-py2.py3-none-any.whl.metadata\n Downloading distlib-0.3.7-py2.py3-none-any.whl.metadata (5.1 kB)\nDownloading tox-4.11.3-py3-none-any.whl (153 kB)\n \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 153.8/153.8 kB 10.9 MB/s eta 0:00:00\nDownloading cachetools-5.3.1-py3-none-any.whl (9.3 kB)\nDownloading chardet-5.2.0-py3-none-any.whl (199 kB)\n \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 199.4/199.4 kB 42.9 MB/s eta 0:00:00\nDownloading filelock-3.12.4-py3-none-any.whl (11 kB)\nDownloading packaging-23.2-py3-none-any.whl (53 kB)\n \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 53.0/53.0 kB 23.2 MB/s eta 0:00:00\nDownloading platformdirs-3.11.0-py3-none-any.whl (17 kB)\nDownloading pluggy-1.3.0-py3-none-any.whl (18 kB)\nDownloading pyproject_api-1.6.1-py3-none-any.whl (12 kB)\nDownloading virtualenv-20.24.5-py3-none-any.whl (3.7 MB)\n \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 3.7/3.7 MB 97.0 MB/s eta 0:00:00\nDownloading distlib-0.3.7-py2.py3-none-any.whl (468 kB)\n \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 468.9/468.9 kB 86.8 MB/s eta 0:00:00\nInstalling collected packages: distlib, pluggy, platformdirs, packaging, filelock, colorama, chardet, cachetools, virtualenv, pyproject-api, tox\nSuccessfully installed cachetools-5.3.1 chardet-5.2.0 colorama-0.4.6 distlib-0.3.7 filelock-3.12.4 packaging-23.2 platformdirs-3.11.0 pluggy-1.3.0 pyproject-api-1.6.1 tox-4.11.3 virtualenv-20.24.5\nlinters: install_deps> python -I -m pip install 'werkzeug<2.3.0' -r test-requirements.txt -r linter-requirements.txt\n.pkg: install_requires> python -I -m pip install 'setuptools>=40.8.0' wheel\n.pkg: _optional_hooks> python /opt/hostedtoolcache/Python/3.11.5/x64/lib/python3.11/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__\n.pkg: get_requires_for_build_editable> python /opt/hostedtoolcache/Python/3.11.5/x64/lib/python3.11/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__\n.pkg: install_requires_for_build_editable> python -I -m pip install wheel\n.pkg: freeze> python -m pip freeze --all\n.pkg: pip==23.2.1,setuptools==68.2.0,wheel==0.41.2\n.pkg: build_editable> python /opt/hostedtoolcache/Python/3.11.5/x64/lib/python3.11/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__\nlinters: install_package_deps> python -I -m pip install certifi 'urllib3>=1.25.7; python_version <= \"3.4\"' 'urllib3>=1.26.11; python_version >= \"3.6\"' 'urllib3>=1.26.9; python_version == \"3.5\"'\nlinters: install_package> python -I -m pip install --force-reinstall --no-deps /home/runner/work/sentry-python/sentry-python/.tox/.tmp/package/1/sentry_sdk-1.31.0-0.editable-py2.py3-none-any.whl\nlinters: freeze> python -m pip freeze --all\nlinters: asttokens==2.4.0,attrs==23.1.0,backcall==0.2.0,black==23.9.1,certifi==2023.7.22,cffi==1.16.0,cfgv==3.4.0,charset-normalizer==3.3.0,click==8.1.7,colorama==0.4.6,coverage==7.3.2,cryptography==41.0.4,decorator==5.1.1,distlib==0.3.7,dnspython==2.4.2,docopt==0.6.2,executing==1.2.0,filelock==3.12.4,flake8==5.0.4,flake8-bugbear==23.3.12,identify==2.5.30,idna==3.4,iniconfig==2.0.0,ipdb==0.13.13,ipython==8.16.1,jedi==0.19.1,jsonschema==3.2.0,loguru==0.7.2,MarkupSafe==2.1.3,matplotlib-inline==0.1.6,mccabe==0.7.0,mypy==1.6.0,mypy-extensions==1.0.0,nodeenv==1.8.0,packaging==23.2,parso==0.8.3,pathspec==0.11.2,pep8-naming==0.13.3,pexpect==4.8.0,pickleshare==0.7.5,pip==23.2.1,platformdirs==3.11.0,pluggy==0.13.1,pre-commit==3.4.0,prompt-toolkit==3.0.39,ptyprocess==0.7.0,pure-eval==0.2.2,py==1.11.0,pycodestyle==2.9.1,pycparser==2.21,pyflakes==2.5.0,Pygments==2.16.1,pymongo==4.5.0,pyrsistent==0.16.0,PySocks==1.7.1,pytest==6.2.5,pytest-cov==2.8.1,pytest-forked==1.4.0,pytest-localserver==0.5.0,pytest-watch==4.2.0,PyYAML==6.0.1,requests==2.31.0,responses==0.23.3,sentry-sdk @ file:///home/runner/work/sentry-python/sentry-python/.tox/.tmp/package/1/sentry_sdk-1.31.0-0.editable-py2.py3-none-any.whl#sha256=fe92b2c2c5369696c1802150fa5e2816a8f75e4581830e68ddd6bd2663b9808c,setuptools==68.2.0,six==1.16.0,stack-data==0.6.3,toml==0.10.2,tox==3.7.0,traitlets==5.11.2,types-certifi==2021.10.8.3,types-pyOpenSSL==23.2.0.2,types-PyYAML==6.0.12.12,types-redis==4.6.0.7,types-setuptools==68.2.0.0,typing_extensions==4.8.0,urllib3==2.0.6,virtualenv==20.24.5,watchdog==3.0.0,wcwidth==0.2.8,Werkzeug==2.2.3,wheel==0.41.2\nlinters: commands[0]> flake8 tests sentry_sdk\nlinters: commands[1]> black --check tests sentry_sdk\nAll done! \u2728 \ud83c\udf70 \u2728\n266 files would be left unchanged.\nlinters: commands[2]> mypy sentry_sdk\nsentry_sdk/integrations/gql.py:6: error: Unused \"type: ignore\" comment, use narrower [import-not-found] instead of [import] code [unused-ignore]\nsentry_sdk/integrations/gql.py:7: error: Unused \"type: ignore\" comment, use narrower [import-not-found] instead of [import] code [unused-ignore]\nsentry_sdk/integrations/gql.py:8: error: Unused \"type: ignore\" comment, use narrower [import-not-found] instead of [import] code [unused-ignore]\nsentry_sdk/integrations/gql.py:9: error: Unused \"type: ignore\" comment, use narrower [import-not-found] instead of [import] code [unused-ignore]\nsentry_sdk/integrations/clickhouse_driver.py:33: error: Unused \"type: ignore\" comment, use narrower [import-not-found] instead of [import] code [unused-ignore]\nsentry_sdk/integrations/asyncpg.py:15: error: Unused \"type: ignore\" comment, use narrower [import-not-found] instead of [import] code [unused-ignore]\nFound 6 errors in 3 files (checked 109 source files)\nlinters: exit 1 (9.74 seconds) /home/runner/work/sentry-python/sentry-python> mypy sentry_sdk pid=2062\n.pkg: _exit> python /opt/hostedtoolcache/Python/3.11.5/x64/lib/python3.11/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__\n linters: FAIL code 1 (46.25=setup[26.82]+cmd[5.66,4.04,9.74] seconds)\n evaluation failed :( (49.67 seconds)\n##[error]Process completed with exit code 1.\n", "diff": "diff --git a/sentry_sdk/integrations/asyncpg.py b/sentry_sdk/integrations/asyncpg.py\nindex 8262b2ef..f74b874e 100644\n--- a/sentry_sdk/integrations/asyncpg.py\n+++ b/sentry_sdk/integrations/asyncpg.py\n@@ -12,7 +12,7 @@ from sentry_sdk.tracing_utils import record_sql_queries\n from sentry_sdk.utils import parse_version, capture_internal_exceptions\n \n try:\n- import asyncpg # type: ignore[import]\n+ import asyncpg # type: ignore[import-not-found]\n \n except ImportError:\n raise DidNotEnable(\"asyncpg not installed.\")\ndiff --git a/sentry_sdk/integrations/clickhouse_driver.py b/sentry_sdk/integrations/clickhouse_driver.py\nindex 8a436022..f0955ff7 100644\n--- a/sentry_sdk/integrations/clickhouse_driver.py\n+++ b/sentry_sdk/integrations/clickhouse_driver.py\n@@ -30,7 +30,7 @@ else:\n \n \n try:\n- import clickhouse_driver # type: ignore[import]\n+ import clickhouse_driver # type: ignore[import-not-found]\n \n except ImportError:\n raise DidNotEnable(\"clickhouse-driver not installed.\")\ndiff --git a/sentry_sdk/integrations/gql.py b/sentry_sdk/integrations/gql.py\nindex efdb2fe3..79fc8d02 100644\n--- a/sentry_sdk/integrations/gql.py\n+++ b/sentry_sdk/integrations/gql.py\n@@ -3,10 +3,10 @@ from sentry_sdk.hub import Hub, _should_send_default_pii\n from sentry_sdk.integrations import DidNotEnable, Integration\n \n try:\n- import gql # type: ignore[import]\n- from graphql import print_ast, get_operation_ast, DocumentNode, VariableDefinitionNode # type: ignore[import]\n- from gql.transport import Transport, AsyncTransport # type: ignore[import]\n- from gql.transport.exceptions import TransportQueryError # type: ignore[import]\n+ import gql # type: ignore[import-not-found]\n+ from graphql import print_ast, get_operation_ast, DocumentNode, VariableDefinitionNode # type: ignore[import-not-found]\n+ from gql.transport import Transport, AsyncTransport # type: ignore[import-not-found]\n+ from gql.transport.exceptions import TransportQueryError # type: ignore[import-not-found]\n except ImportError:\n raise DidNotEnable(\"gql is not installed\")\n \n"}
data/6.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"head_branch": "master", "contributor": "cameron-simpson", "sha_fail": "c4a1da23413c5e82f3e9784f8750f56980cddb11", "sha_success": "522abef8e3aeacaac3908d9068cb1ba0e9da9022", "language": "Python", "repo_owner": "getsentry", "repo_name": "sentry-python", "workflow_name": "CI", "workflow_filename": "ci.yml", "workflow_path": ".github/workflows/ci.yml", "workflow": "name: CI\n\non:\n push:\n branches:\n - master\n - release/**\n\n pull_request:\n\npermissions:\n contents: read\n\nenv:\n BUILD_CACHE_KEY: ${{ github.sha }}\n CACHED_BUILD_PATHS: |\n ${{ github.workspace }}/dist-serverless\n\njobs:\n lint:\n name: Lint Sources\n runs-on: ubuntu-latest\n timeout-minutes: 10\n\n steps:\n - uses: actions/checkout@v4\n - uses: actions/setup-python@v4\n with:\n python-version: 3.12\n\n - run: |\n pip install tox\n tox -e linters\n\n check-ci-config:\n name: Check CI config\n runs-on: ubuntu-latest\n timeout-minutes: 10\n\n steps:\n - uses: actions/checkout@v4\n - uses: actions/setup-python@v4\n with:\n python-version: 3.12\n\n - run: |\n python scripts/split-tox-gh-actions/split-tox-gh-actions.py --fail-on-changes\n\n build_lambda_layer:\n name: Build Package\n runs-on: ubuntu-latest\n timeout-minutes: 10\n\n steps:\n - uses: actions/checkout@v4\n - uses: actions/setup-python@v4\n with:\n python-version: 3.12\n - name: Setup build cache\n uses: actions/cache@v3\n id: build_cache\n with:\n path: ${{ env.CACHED_BUILD_PATHS }}\n key: ${{ env.BUILD_CACHE_KEY }}\n - name: Build Packages\n run: |\n echo \"Creating directory containing Python SDK Lambda Layer\"\n pip install virtualenv\n # This will also trigger \"make dist\" that creates the Python packages\n make aws-lambda-layer\n - name: Upload Python Packages\n uses: actions/upload-artifact@v3\n with:\n name: ${{ github.sha }}\n path: |\n dist/*\n\n docs:\n name: Build SDK API Doc\n runs-on: ubuntu-latest\n timeout-minutes: 10\n\n steps:\n - uses: actions/checkout@v4\n - uses: actions/setup-python@v4\n with:\n python-version: 3.12\n\n - run: |\n pip install virtualenv\n make apidocs\n cd docs/_build && zip -r gh-pages ./\n\n - uses: actions/[email protected]\n with:\n name: ${{ github.sha }}\n path: docs/_build/gh-pages.zip\n", "logs": "Collecting pyproject-api>=1.6.1 (from tox)\n Downloading pyproject_api-1.6.1-py3-none-any.whl.metadata (2.8 kB)\nCollecting virtualenv>=20.24.3 (from tox)\n Downloading virtualenv-20.24.6-py3-none-any.whl.metadata (4.5 kB)\nCollecting distlib<1,>=0.3.7 (from virtualenv>=20.24.3->tox)\n Downloading distlib-0.3.7-py2.py3-none-any.whl.metadata (5.1 kB)\nDownloading tox-4.11.3-py3-none-any.whl (153 kB)\n \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 153.8/153.8 kB 10.6 MB/s eta 0:00:00\nDownloading cachetools-5.3.2-py3-none-any.whl (9.3 kB)\nDownloading chardet-5.2.0-py3-none-any.whl (199 kB)\n \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 199.4/199.4 kB 42.6 MB/s eta 0:00:00\nDownloading filelock-3.13.1-py3-none-any.whl (11 kB)\nDownloading packaging-23.2-py3-none-any.whl (53 kB)\n \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 53.0/53.0 kB 17.7 MB/s eta 0:00:00\nDownloading platformdirs-3.11.0-py3-none-any.whl (17 kB)\nDownloading pluggy-1.3.0-py3-none-any.whl (18 kB)\nDownloading pyproject_api-1.6.1-py3-none-any.whl (12 kB)\nDownloading virtualenv-20.24.6-py3-none-any.whl (3.8 MB)\n \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 3.8/3.8 MB 89.0 MB/s eta 0:00:00\nDownloading distlib-0.3.7-py2.py3-none-any.whl (468 kB)\n \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 468.9/468.9 kB 76.6 MB/s eta 0:00:00\nInstalling collected packages: distlib, pluggy, platformdirs, packaging, filelock, colorama, chardet, cachetools, virtualenv, pyproject-api, tox\nSuccessfully installed cachetools-5.3.2 chardet-5.2.0 colorama-0.4.6 distlib-0.3.7 filelock-3.13.1 packaging-23.2 platformdirs-3.11.0 pluggy-1.3.0 pyproject-api-1.6.1 tox-4.11.3 virtualenv-20.24.6\n\n[notice] A new release of pip is available: 23.2.1 -> 23.3.1\n[notice] To update, run: pip install --upgrade pip\nlinters: install_deps> python -I -m pip install 'werkzeug<2.3.0' -r test-requirements.txt -r linter-requirements.txt\n.pkg: install_requires> python -I -m pip install 'setuptools>=40.8.0' wheel\n.pkg: _optional_hooks> python /opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__\n.pkg: get_requires_for_build_editable> python /opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__\n.pkg: install_requires_for_build_editable> python -I -m pip install wheel\n.pkg: freeze> python -m pip freeze --all\n.pkg: pip==23.3.1,setuptools==68.2.2,wheel==0.41.3\n.pkg: build_editable> python /opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__\nlinters: install_package_deps> python -I -m pip install certifi 'urllib3>=1.25.7; python_version <= \"3.4\"' 'urllib3>=1.26.11; python_version >= \"3.6\"' 'urllib3>=1.26.9; python_version == \"3.5\"'\nlinters: install_package> python -I -m pip install --force-reinstall --no-deps /home/runner/work/sentry-python/sentry-python/.tox/.tmp/package/1/sentry_sdk-1.34.0-0.editable-py2.py3-none-any.whl\nlinters: freeze> python -m pip freeze --all\nlinters: asttokens==2.4.1,attrs==23.1.0,black==23.11.0,certifi==2023.7.22,cffi==1.16.0,cfgv==3.4.0,charset-normalizer==3.3.2,click==8.1.7,colorama==0.4.6,coverage==7.3.2,cryptography==41.0.5,decorator==5.1.1,distlib==0.3.7,dnspython==2.4.2,docopt==0.6.2,executing==1.2.0,filelock==3.13.1,flake8==5.0.4,flake8-bugbear==23.3.12,identify==2.5.31,idna==3.4,iniconfig==2.0.0,ipdb==0.13.13,ipython==8.17.2,jedi==0.19.1,jsonschema==3.2.0,loguru==0.7.2,MarkupSafe==2.1.3,matplotlib-inline==0.1.6,mccabe==0.7.0,mypy==1.6.1,mypy-extensions==1.0.0,nodeenv==1.8.0,packaging==23.2,parso==0.8.3,pathspec==0.11.2,pep8-naming==0.13.3,pexpect==4.8.0,pip==23.3.1,platformdirs==3.11.0,pluggy==0.13.1,pre-commit==3.5.0,prompt-toolkit==3.0.39,ptyprocess==0.7.0,pure-eval==0.2.2,py==1.11.0,pycodestyle==2.9.1,pycparser==2.21,pyflakes==2.5.0,Pygments==2.16.1,pymongo==4.6.0,pyrsistent==0.16.0,PySocks==1.7.1,pytest==6.2.5,pytest-cov==2.8.1,pytest-forked==1.4.0,pytest-localserver==0.5.1,pytest-watch==4.2.0,PyYAML==6.0.1,requests==2.31.0,responses==0.24.0,sentry-sdk @ file:///home/runner/work/sentry-python/sentry-python/.tox/.tmp/package/1/sentry_sdk-1.34.0-0.editable-py2.py3-none-any.whl#sha256=8cac6cec867d605ecaedd4461652e22545898c9773ff52416df81028a5ee1889,setuptools==68.2.2,six==1.16.0,stack-data==0.6.3,toml==0.10.2,tox==3.7.0,traitlets==5.13.0,types-certifi==2021.10.8.3,types-protobuf==4.24.0.4,types-pyOpenSSL==23.3.0.0,types-redis==4.6.0.10,types-setuptools==68.2.0.1,typing_extensions==4.8.0,urllib3==2.0.7,virtualenv==20.24.6,watchdog==3.0.0,wcwidth==0.2.9,Werkzeug==2.2.3\nlinters: commands[0]> flake8 tests sentry_sdk\nlinters: commands[1]> black --check tests sentry_sdk\nAll done! \u2728 \ud83c\udf70 \u2728\n267 files would be left unchanged.\nlinters: commands[2]> mypy sentry_sdk\nsentry_sdk/integrations/django/middleware.py:41: error: Incompatible types in assignment (expression has type \"Callable[[Callable[..., Any]], type[object]]\", variable has type \"Callable[[Callable[..., Any]], Any]\") [assignment]\nFound 1 error in 1 file (checked 112 source files)\nlinters: exit 1 (9.69 seconds) /home/runner/work/sentry-python/sentry-python> mypy sentry_sdk pid=2217\n.pkg: _exit> python /opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__\n linters: FAIL code 1 (50.62=setup[31.79]+cmd[3.93,5.21,9.69] seconds)\n evaluation failed :( (53.91 seconds)\n##[error]Process completed with exit code 1.\n", "diff": "diff --git a/sentry_sdk/integrations/celery.py b/sentry_sdk/integrations/celery.py\nindex a0c86ea9..88c85d12 100644\n--- a/sentry_sdk/integrations/celery.py\n+++ b/sentry_sdk/integrations/celery.py\n@@ -444,7 +444,15 @@ def _get_monitor_config(celery_schedule, app, monitor_name):\n if schedule_unit is not None:\n monitor_config[\"schedule\"][\"unit\"] = schedule_unit\n \n- monitor_config[\"timezone\"] = app.conf.timezone or \"UTC\"\n+ monitor_config[\"timezone\"] = (\n+ (\n+ hasattr(celery_schedule, \"tz\")\n+ and celery_schedule.tz is not None\n+ and str(celery_schedule.tz)\n+ )\n+ or app.timezone\n+ or \"UTC\"\n+ )\n \n return monitor_config\n \ndiff --git a/sentry_sdk/integrations/django/middleware.py b/sentry_sdk/integrations/django/middleware.py\nindex b5a23cdc..aa8023db 100644\n--- a/sentry_sdk/integrations/django/middleware.py\n+++ b/sentry_sdk/integrations/django/middleware.py\n@@ -34,11 +34,10 @@ else:\n import_string_name = \"import_string\"\n \n \n-DJANGO_SUPPORTS_ASYNC_MIDDLEWARE = DJANGO_VERSION >= (3, 1)\n-if DJANGO_SUPPORTS_ASYNC_MIDDLEWARE:\n- from .asgi import _asgi_middleware_mixin_factory\n-else:\n+if DJANGO_VERSION < (3, 1):\n _asgi_middleware_mixin_factory = lambda _: object\n+else:\n+ from .asgi import _asgi_middleware_mixin_factory\n \n \n def patch_django_middlewares():\n@@ -127,9 +126,7 @@ def _wrap_middleware(middleware, middleware_name):\n class SentryWrappingMiddleware(\n _asgi_middleware_mixin_factory(_check_middleware_span) # type: ignore\n ):\n- async_capable = DJANGO_SUPPORTS_ASYNC_MIDDLEWARE and getattr(\n- middleware, \"async_capable\", False\n- )\n+ async_capable = getattr(middleware, \"async_capable\", False)\n \n def __init__(self, get_response=None, *args, **kwargs):\n # type: (Optional[Callable[..., Any]], *Any, **Any) -> None\ndiff --git a/tests/integrations/celery/test_celery_beat_crons.py b/tests/integrations/celery/test_celery_beat_crons.py\nindex e42ccdbd..9343b3c9 100644\n--- a/tests/integrations/celery/test_celery_beat_crons.py\n+++ b/tests/integrations/celery/test_celery_beat_crons.py\n@@ -1,3 +1,6 @@\n+import datetime\n+import sys\n+\n import pytest\n \n from sentry_sdk.integrations.celery import (\n@@ -207,25 +210,65 @@ def test_crons_task_retry():\n \n def test_get_monitor_config_crontab():\n app = MagicMock()\n- app.conf = MagicMock()\n- app.conf.timezone = \"Europe/Vienna\"\n+ app.timezone = \"Europe/Vienna\"\n \n+ # schedule with the default timezone\n celery_schedule = crontab(day_of_month=\"3\", hour=\"12\", minute=\"*/10\")\n+\n monitor_config = _get_monitor_config(celery_schedule, app, \"foo\")\n assert monitor_config == {\n \"schedule\": {\n \"type\": \"crontab\",\n \"value\": \"*/10 12 3 * *\",\n },\n- \"timezone\": \"Europe/Vienna\",\n+ \"timezone\": \"UTC\", # the default because `crontab` does not know about the app\n }\n assert \"unit\" not in monitor_config[\"schedule\"]\n \n+ # schedule with the timezone from the app\n+ celery_schedule = crontab(day_of_month=\"3\", hour=\"12\", minute=\"*/10\", app=app)\n+\n+ monitor_config = _get_monitor_config(celery_schedule, app, \"foo\")\n+ assert monitor_config == {\n+ \"schedule\": {\n+ \"type\": \"crontab\",\n+ \"value\": \"*/10 12 3 * *\",\n+ },\n+ \"timezone\": \"Europe/Vienna\", # the timezone from the app\n+ }\n+\n+ # schedule without a timezone, the celery integration will read the config from the app\n+ celery_schedule = crontab(day_of_month=\"3\", hour=\"12\", minute=\"*/10\")\n+ celery_schedule.tz = None\n+\n+ monitor_config = _get_monitor_config(celery_schedule, app, \"foo\")\n+ assert monitor_config == {\n+ \"schedule\": {\n+ \"type\": \"crontab\",\n+ \"value\": \"*/10 12 3 * *\",\n+ },\n+ \"timezone\": \"Europe/Vienna\", # the timezone from the app\n+ }\n+\n+ # schedule without a timezone, and an app without timezone, the celery integration will fall back to UTC\n+ app = MagicMock()\n+ app.timezone = None\n+\n+ celery_schedule = crontab(day_of_month=\"3\", hour=\"12\", minute=\"*/10\")\n+ celery_schedule.tz = None\n+ monitor_config = _get_monitor_config(celery_schedule, app, \"foo\")\n+ assert monitor_config == {\n+ \"schedule\": {\n+ \"type\": \"crontab\",\n+ \"value\": \"*/10 12 3 * *\",\n+ },\n+ \"timezone\": \"UTC\", # default timezone from celery integration\n+ }\n+\n \n def test_get_monitor_config_seconds():\n app = MagicMock()\n- app.conf = MagicMock()\n- app.conf.timezone = \"Europe/Vienna\"\n+ app.timezone = \"Europe/Vienna\"\n \n celery_schedule = schedule(run_every=3) # seconds\n \n@@ -243,10 +286,55 @@ def test_get_monitor_config_seconds():\n \n def test_get_monitor_config_minutes():\n app = MagicMock()\n- app.conf = MagicMock()\n- app.conf.timezone = \"Europe/Vienna\"\n+ app.timezone = \"Europe/Vienna\"\n+\n+ # schedule with the default timezone\n+ celery_schedule = schedule(run_every=60) # seconds\n+\n+ monitor_config = _get_monitor_config(celery_schedule, app, \"foo\")\n+ assert monitor_config == {\n+ \"schedule\": {\n+ \"type\": \"interval\",\n+ \"value\": 1,\n+ \"unit\": \"minute\",\n+ },\n+ \"timezone\": \"UTC\",\n+ }\n+\n+ # schedule with the timezone from the app\n+ celery_schedule = schedule(run_every=60, app=app) # seconds\n+\n+ monitor_config = _get_monitor_config(celery_schedule, app, \"foo\")\n+ assert monitor_config == {\n+ \"schedule\": {\n+ \"type\": \"interval\",\n+ \"value\": 1,\n+ \"unit\": \"minute\",\n+ },\n+ \"timezone\": \"Europe/Vienna\", # the timezone from the app\n+ }\n+\n+ # schedule without a timezone, the celery integration will read the config from the app\n+ celery_schedule = schedule(run_every=60) # seconds\n+ celery_schedule.tz = None\n+\n+ monitor_config = _get_monitor_config(celery_schedule, app, \"foo\")\n+ assert monitor_config == {\n+ \"schedule\": {\n+ \"type\": \"interval\",\n+ \"value\": 1,\n+ \"unit\": \"minute\",\n+ },\n+ \"timezone\": \"Europe/Vienna\", # the timezone from the app\n+ }\n+\n+ # schedule without a timezone, and an app without timezone, the celery integration will fall back to UTC\n+ app = MagicMock()\n+ app.timezone = None\n \n celery_schedule = schedule(run_every=60) # seconds\n+ celery_schedule.tz = None\n+\n monitor_config = _get_monitor_config(celery_schedule, app, \"foo\")\n assert monitor_config == {\n \"schedule\": {\n@@ -254,14 +342,13 @@ def test_get_monitor_config_minutes():\n \"value\": 1,\n \"unit\": \"minute\",\n },\n- \"timezone\": \"Europe/Vienna\",\n+ \"timezone\": \"UTC\", # default timezone from celery integration\n }\n \n \n def test_get_monitor_config_unknown():\n app = MagicMock()\n- app.conf = MagicMock()\n- app.conf.timezone = \"Europe/Vienna\"\n+ app.timezone = \"Europe/Vienna\"\n \n unknown_celery_schedule = MagicMock()\n monitor_config = _get_monitor_config(unknown_celery_schedule, app, \"foo\")\n@@ -270,16 +357,45 @@ def test_get_monitor_config_unknown():\n \n def test_get_monitor_config_default_timezone():\n app = MagicMock()\n- app.conf = MagicMock()\n- app.conf.timezone = None\n+ app.timezone = None\n \n celery_schedule = crontab(day_of_month=\"3\", hour=\"12\", minute=\"*/10\")\n \n- monitor_config = _get_monitor_config(celery_schedule, app, \"foo\")\n+ monitor_config = _get_monitor_config(celery_schedule, app, \"dummy_monitor_name\")\n \n assert monitor_config[\"timezone\"] == \"UTC\"\n \n \n+def test_get_monitor_config_timezone_in_app_conf():\n+ app = MagicMock()\n+ app.timezone = \"Asia/Karachi\"\n+\n+ celery_schedule = crontab(day_of_month=\"3\", hour=\"12\", minute=\"*/10\")\n+ celery_schedule.tz = None\n+\n+ monitor_config = _get_monitor_config(celery_schedule, app, \"dummy_monitor_name\")\n+\n+ assert monitor_config[\"timezone\"] == \"Asia/Karachi\"\n+\n+\[email protected](\n+ sys.version_info < (3, 0),\n+ reason=\"no datetime.timezone for Python 2, so skipping this test.\",\n+)\n+def test_get_monitor_config_timezone_in_celery_schedule():\n+ app = MagicMock()\n+ app.timezone = \"Asia/Karachi\"\n+\n+ panama_tz = datetime.timezone(datetime.timedelta(hours=-5), name=\"America/Panama\")\n+\n+ celery_schedule = crontab(day_of_month=\"3\", hour=\"12\", minute=\"*/10\")\n+ celery_schedule.tz = panama_tz\n+\n+ monitor_config = _get_monitor_config(celery_schedule, app, \"dummy_monitor_name\")\n+\n+ assert monitor_config[\"timezone\"] == str(panama_tz)\n+\n+\n @pytest.mark.parametrize(\n \"task_name,exclude_beat_tasks,task_in_excluded_beat_tasks\",\n [\n"}
data/7.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"head_branch": "m.redis-cluster", "contributor": "md384", "sha_fail": "5c99ddda3d9a3b351827a83e560d416970559c90", "sha_success": "c868892b2710c3698681d3922a2991a11c380cdf", "language": "Python", "repo_owner": "getsentry", "repo_name": "sentry-python", "workflow_name": "CI", "workflow_filename": "ci.yml", "workflow_path": ".github/workflows/ci.yml", "workflow": "name: CI\n\non:\n push:\n branches:\n - master\n - release/**\n\n pull_request:\n\npermissions:\n contents: read\n\nenv:\n BUILD_CACHE_KEY: ${{ github.sha }}\n CACHED_BUILD_PATHS: |\n ${{ github.workspace }}/dist-serverless\n\njobs:\n lint:\n name: Lint Sources\n runs-on: ubuntu-latest\n timeout-minutes: 10\n\n steps:\n - uses: actions/checkout@v4\n - uses: actions/setup-python@v4\n with:\n python-version: 3.12\n\n - run: |\n pip install tox\n tox -e linters\n\n check-ci-config:\n name: Check CI config\n runs-on: ubuntu-latest\n timeout-minutes: 10\n\n steps:\n - uses: actions/checkout@v4\n - uses: actions/setup-python@v4\n with:\n python-version: 3.12\n\n - run: |\n pip install jinja2\n python scripts/split-tox-gh-actions/split-tox-gh-actions.py --fail-on-changes\n\n build_lambda_layer:\n name: Build Package\n runs-on: ubuntu-latest\n timeout-minutes: 10\n\n steps:\n - uses: actions/checkout@v4\n - uses: actions/setup-python@v4\n with:\n python-version: 3.12\n - name: Setup build cache\n uses: actions/cache@v3\n id: build_cache\n with:\n path: ${{ env.CACHED_BUILD_PATHS }}\n key: ${{ env.BUILD_CACHE_KEY }}\n - name: Build Packages\n run: |\n echo \"Creating directory containing Python SDK Lambda Layer\"\n pip install virtualenv\n # This will also trigger \"make dist\" that creates the Python packages\n make aws-lambda-layer\n - name: Upload Python Packages\n uses: actions/upload-artifact@v3\n with:\n name: ${{ github.sha }}\n path: |\n dist/*\n\n docs:\n name: Build SDK API Doc\n runs-on: ubuntu-latest\n timeout-minutes: 10\n\n steps:\n - uses: actions/checkout@v4\n - uses: actions/setup-python@v4\n with:\n python-version: 3.12\n\n - run: |\n pip install virtualenv\n make apidocs\n cd docs/_build && zip -r gh-pages ./\n\n - uses: actions/[email protected]\n with:\n name: ${{ github.sha }}\n path: docs/_build/gh-pages.zip\n", "logs": "Downloading cachetools-5.3.2-py3-none-any.whl (9.3 kB)\nDownloading chardet-5.2.0-py3-none-any.whl (199 kB)\n \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 199.4/199.4 kB 32.7 MB/s eta 0:00:00\nDownloading filelock-3.13.1-py3-none-any.whl (11 kB)\nDownloading packaging-23.2-py3-none-any.whl (53 kB)\n \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 53.0/53.0 kB 15.4 MB/s eta 0:00:00\nDownloading platformdirs-4.0.0-py3-none-any.whl (17 kB)\nDownloading pluggy-1.3.0-py3-none-any.whl (18 kB)\nDownloading pyproject_api-1.6.1-py3-none-any.whl (12 kB)\nDownloading virtualenv-20.24.7-py3-none-any.whl (3.8 MB)\n \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 3.8/3.8 MB 110.2 MB/s eta 0:00:00\nDownloading distlib-0.3.7-py2.py3-none-any.whl (468 kB)\n \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 468.9/468.9 kB 77.5 MB/s eta 0:00:00\nInstalling collected packages: distlib, pluggy, platformdirs, packaging, filelock, colorama, chardet, cachetools, virtualenv, pyproject-api, tox\nSuccessfully installed cachetools-5.3.2 chardet-5.2.0 colorama-0.4.6 distlib-0.3.7 filelock-3.13.1 packaging-23.2 platformdirs-4.0.0 pluggy-1.3.0 pyproject-api-1.6.1 tox-4.11.4 virtualenv-20.24.7\n\n[notice] A new release of pip is available: 23.2.1 -> 23.3.1\n[notice] To update, run: pip install --upgrade pip\nlinters: install_deps> python -I -m pip install 'werkzeug<2.3.0' -r test-requirements.txt -r linter-requirements.txt\n.pkg: install_requires> python -I -m pip install 'setuptools>=40.8.0' wheel\n.pkg: _optional_hooks> python /opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__\n.pkg: get_requires_for_build_editable> python /opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__\n.pkg: install_requires_for_build_editable> python -I -m pip install wheel\n.pkg: freeze> python -m pip freeze --all\n.pkg: pip==23.3.1,setuptools==69.0.2,wheel==0.42.0\n.pkg: build_editable> python /opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__\nlinters: install_package_deps> python -I -m pip install certifi 'urllib3>=1.25.7; python_version <= \"3.4\"' 'urllib3>=1.26.11; python_version >= \"3.6\"' 'urllib3>=1.26.9; python_version == \"3.5\"'\nlinters: install_package> python -I -m pip install --force-reinstall --no-deps /home/runner/work/sentry-python/sentry-python/.tox/.tmp/package/1/sentry_sdk-1.38.0-0.editable-py2.py3-none-any.whl\nlinters: freeze> python -m pip freeze --all\nlinters: asttokens==2.4.1,attrs==23.1.0,black==23.11.0,certifi==2023.11.17,cffi==1.16.0,cfgv==3.4.0,charset-normalizer==3.3.2,click==8.1.7,colorama==0.4.6,coverage==7.3.2,cryptography==41.0.7,decorator==5.1.1,distlib==0.3.7,dnspython==2.4.2,docopt==0.6.2,executing==1.2.0,filelock==3.13.1,flake8==5.0.4,flake8-bugbear==23.3.12,identify==2.5.32,idna==3.6,iniconfig==2.0.0,ipdb==0.13.13,ipython==8.18.1,jedi==0.19.1,jsonschema==3.2.0,loguru==0.7.2,MarkupSafe==2.1.3,matplotlib-inline==0.1.6,mccabe==0.7.0,mypy==1.7.1,mypy-extensions==1.0.0,nodeenv==1.8.0,packaging==23.2,parso==0.8.3,pathspec==0.11.2,pep8-naming==0.13.3,pexpect==4.9.0,pip==23.3.1,platformdirs==4.0.0,pluggy==0.13.1,pre-commit==3.5.0,prompt-toolkit==3.0.41,ptyprocess==0.7.0,pure-eval==0.2.2,py==1.11.0,pycodestyle==2.9.1,pycparser==2.21,pyflakes==2.5.0,Pygments==2.17.2,pymongo==4.6.1,pyrsistent==0.16.0,PySocks==1.7.1,pytest==7.4.3,pytest-cov==2.8.1,pytest-forked==1.4.0,pytest-localserver==0.5.1,pytest-watch==4.2.0,PyYAML==6.0.1,requests==2.31.0,responses==0.24.1,sentry-sdk @ file:///home/runner/work/sentry-python/sentry-python/.tox/.tmp/package/1/sentry_sdk-1.38.0-0.editable-py2.py3-none-any.whl#sha256=0600ca84a4e5a0d0bd5f3f907f2806001272fb2955a950dd53ebd77aa23ee3bd,setuptools==69.0.2,six==1.16.0,stack-data==0.6.3,toml==0.10.2,tox==3.7.0,traitlets==5.14.0,types-certifi==2021.10.8.3,types-protobuf==4.24.0.4,types-pyOpenSSL==23.3.0.0,types-redis==4.6.0.11,types-setuptools==69.0.0.0,typing_extensions==4.8.0,urllib3==2.1.0,virtualenv==20.24.7,watchdog==3.0.0,wcwidth==0.2.12,Werkzeug==2.2.3\nlinters: commands[0]> flake8 tests sentry_sdk\nlinters: commands[1]> black --check tests sentry_sdk\nAll done! \u2728 \ud83c\udf70 \u2728\n274 files would be left unchanged.\nlinters: commands[2]> mypy sentry_sdk\nsentry_sdk/integrations/redis/__init__.py:143: error: Missing type parameters for generic type \"Redis\" [type-arg]\nsentry_sdk/integrations/redis/__init__.py:151: error: Missing type parameters for generic type \"RedisCluster\" [type-arg]\nsentry_sdk/integrations/redis/__init__.py:160: error: Missing type parameters for generic type \"RedisCluster\" [type-arg]\nsentry_sdk/integrations/redis/__init__.py:167: error: Missing type parameters for generic type \"ClusterPipeline\" [type-arg]\nsentry_sdk/integrations/redis/__init__.py:169: error: \"ClusterPipeline[Any]\" has no attribute \"_client\" [attr-defined]\nsentry_sdk/integrations/redis/asyncio.py:24: error: \"type\" has no attribute \"execute\" [attr-defined]\nsentry_sdk/integrations/redis/asyncio.py:48: error: \"type\" has no attribute \"execute\" [attr-defined]\nsentry_sdk/integrations/redis/asyncio.py:53: error: \"type\" has no attribute \"execute_command\" [attr-defined]\nsentry_sdk/integrations/redis/asyncio.py:70: error: \"type\" has no attribute \"execute_command\" [attr-defined]\nFound 9 errors in 2 files (checked 113 source files)\nlinters: exit 1 (9.18 seconds) /home/runner/work/sentry-python/sentry-python> mypy sentry_sdk pid=2111\n.pkg: _exit> python /opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__\n linters: FAIL code 1 (48.73=setup[30.06]+cmd[4.06,5.42,9.18] seconds)\n evaluation failed :( (51.86 seconds)\n##[error]Process completed with exit code 1.\n", "diff": "diff --git a/sentry_sdk/integrations/redis/__init__.py b/sentry_sdk/integrations/redis/__init__.py\nindex 2e4e43a5..adb3380e 100644\n--- a/sentry_sdk/integrations/redis/__init__.py\n+++ b/sentry_sdk/integrations/redis/__init__.py\n@@ -141,7 +141,7 @@ def _set_db_data_on_span(span, connection_params):\n \n \n def _set_db_data(span, redis_instance):\n- # type: (Span, Redis) -> None\n+ # type: (Span, Redis[Any]) -> None\n try:\n _set_db_data_on_span(span, redis_instance.connection_pool.connection_kwargs)\n except AttributeError:\n@@ -149,7 +149,7 @@ def _set_db_data(span, redis_instance):\n \n \n def _set_cluster_db_data(span, redis_cluster_instance):\n- # type: (Span, RedisCluster) -> None\n+ # type: (Span, RedisCluster[Any]) -> None\n default_node = redis_cluster_instance.get_default_node()\n if default_node is not None:\n _set_db_data_on_span(\n@@ -158,15 +158,20 @@ def _set_cluster_db_data(span, redis_cluster_instance):\n \n \n def _set_async_cluster_db_data(span, async_redis_cluster_instance):\n- # type: (Span, AsyncRedisCluster) -> None\n+ # type: (Span, AsyncRedisCluster[Any]) -> None\n default_node = async_redis_cluster_instance.get_default_node()\n if default_node is not None and default_node.connection_kwargs is not None:\n _set_db_data_on_span(span, default_node.connection_kwargs)\n \n \n def _set_async_cluster_pipeline_db_data(span, async_redis_cluster_pipeline_instance):\n- # type: (Span, AsyncClusterPipeline) -> None\n- _set_async_cluster_db_data(span, async_redis_cluster_pipeline_instance._client)\n+ # type: (Span, AsyncClusterPipeline[Any]) -> None\n+ _set_async_cluster_db_data(\n+ span,\n+ # the AsyncClusterPipeline has always had a `_client` attr but it is private so potentially problematic and mypy\n+ # does not recognize it - see https://github.com/redis/redis-py/blame/v5.0.0/redis/asyncio/cluster.py#L1386\n+ async_redis_cluster_pipeline_instance._client, # type: ignore[attr-defined]\n+ )\n \n \n def patch_redis_pipeline(pipeline_cls, is_cluster, get_command_args_fn, set_db_data_fn):\ndiff --git a/sentry_sdk/integrations/redis/asyncio.py b/sentry_sdk/integrations/redis/asyncio.py\nindex 8da323be..09fad342 100644\n--- a/sentry_sdk/integrations/redis/asyncio.py\n+++ b/sentry_sdk/integrations/redis/asyncio.py\n@@ -14,13 +14,15 @@ from sentry_sdk.utils import capture_internal_exceptions\n \n if TYPE_CHECKING:\n from collections.abc import Callable\n- from typing import Any\n+ from typing import Any, Union\n+ from redis.asyncio.client import Pipeline, StrictRedis\n+ from redis.asyncio.cluster import ClusterPipeline, RedisCluster\n \n \n def patch_redis_async_pipeline(\n pipeline_cls, is_cluster, get_command_args_fn, set_db_data_fn\n ):\n- # type: (type, bool, Any, Callable[[Span, Any], None]) -> None\n+ # type: (Union[type[Pipeline[Any]], type[ClusterPipeline[Any]]], bool, Any, Callable[[Span, Any], None]) -> None\n old_execute = pipeline_cls.execute\n \n async def _sentry_execute(self, *args, **kwargs):\n@@ -45,11 +47,11 @@ def patch_redis_async_pipeline(\n \n return await old_execute(self, *args, **kwargs)\n \n- pipeline_cls.execute = _sentry_execute\n+ pipeline_cls.execute = _sentry_execute # type: ignore[method-assign]\n \n \n def patch_redis_async_client(cls, is_cluster, set_db_data_fn):\n- # type: (type, bool, Callable[[Span, Any], None]) -> None\n+ # type: (Union[type[StrictRedis[Any]], type[RedisCluster[Any]]], bool, Callable[[Span, Any], None]) -> None\n old_execute_command = cls.execute_command\n \n async def _sentry_execute_command(self, name, *args, **kwargs):\n@@ -67,4 +69,4 @@ def patch_redis_async_client(cls, is_cluster, set_db_data_fn):\n \n return await old_execute_command(self, name, *args, **kwargs)\n \n- cls.execute_command = _sentry_execute_command\n+ cls.execute_command = _sentry_execute_command # type: ignore[method-assign]\ndiff --git a/tests/integrations/redis/cluster/test_redis_cluster.py b/tests/integrations/redis/cluster/test_redis_cluster.py\nindex 95e6627a..d04bd7ba 100644\n--- a/tests/integrations/redis/cluster/test_redis_cluster.py\n+++ b/tests/integrations/redis/cluster/test_redis_cluster.py\n@@ -17,7 +17,7 @@ def monkeypatch_rediscluster_class(reset_integrations):\n \"localhost\", 6379\n )\n pipeline_cls.execute = lambda *_, **__: None\n- redis.RedisCluster.execute_command = lambda *_, **__: None\n+ redis.RedisCluster.execute_command = lambda *_, **__: []\n \n \n def test_rediscluster_breadcrumb(sentry_init, capture_events):\n@@ -29,7 +29,15 @@ def test_rediscluster_breadcrumb(sentry_init, capture_events):\n capture_message(\"hi\")\n \n (event,) = events\n- (crumb,) = event[\"breadcrumbs\"][\"values\"]\n+ crumbs = event[\"breadcrumbs\"][\"values\"]\n+\n+ # on initializing a RedisCluster, a COMMAND call is made - this is not important for the test\n+ # but must be accounted for\n+ assert len(crumbs) <= 2\n+ if len(crumbs) == 2:\n+ assert event[\"breadcrumbs\"][\"values\"][0][\"message\"] == \"COMMAND\"\n+\n+ crumb = event[\"breadcrumbs\"][\"values\"][-1]\n \n assert crumb == {\n \"category\": \"redis\",\n@@ -65,7 +73,15 @@ def test_rediscluster_basic(sentry_init, capture_events, send_default_pii, descr\n rc.set(\"bar\", 1)\n \n (event,) = events\n- (span,) = event[\"spans\"]\n+ spans = event[\"spans\"]\n+\n+ # on initializing a RedisCluster, a COMMAND call is made - this is not important for the test\n+ # but must be accounted for\n+ assert len(spans) <= 2\n+ if len(spans) == 2:\n+ assert event[\"spans\"][0][\"description\"] == \"COMMAND\"\n+\n+ span = event[\"spans\"][-1]\n assert span[\"op\"] == \"db.redis\"\n assert span[\"description\"] == description\n assert span[\"data\"] == {\n"}
data/8.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"head_branch": "add-hardswish-to-nn", "contributor": "james77777778", "sha_fail": "17a3c1dd96375907ff0d0458977600577df3b4c6", "sha_success": "9d86dee1022aecc12faaccf57f2acd405164db1f", "language": "Python", "repo_owner": "keras-team", "repo_name": "keras", "workflow_name": "Tests", "workflow_filename": "actions.yml", "workflow_path": ".github/workflows/actions.yml", "workflow": "name: Tests\n\non:\n push:\n branches: [ master ]\n pull_request:\n release:\n types: [created]\n\npermissions:\n contents: read\n\njobs:\n build:\n strategy:\n fail-fast: false\n matrix:\n python-version: [3.9]\n backend: [tensorflow, jax, torch, numpy]\n name: Run tests\n runs-on: ubuntu-latest\n env:\n PYTHON: ${{ matrix.python-version }}\n KERAS_HOME: .github/workflows/config/${{ matrix.backend }}\n steps:\n - uses: actions/checkout@v4\n - name: Check for changes in keras/applications\n uses: dorny/paths-filter@v2\n id: filter\n with:\n filters: |\n applications:\n - 'keras/applications/**'\n - name: Set up Python\n uses: actions/setup-python@v4\n with:\n python-version: ${{ matrix.python-version }}\n - name: Get pip cache dir\n id: pip-cache\n run: |\n python -m pip install --upgrade pip setuptools\n echo \"dir=$(pip cache dir)\" >> $GITHUB_OUTPUT\n - name: pip cache\n uses: actions/cache@v3\n with:\n path: ${{ steps.pip-cache.outputs.dir }}\n key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements.txt') }}\n - name: Install dependencies\n run: |\n pip install -r requirements.txt --progress-bar off --upgrade\n pip uninstall -y keras keras-nightly\n pip install -e \".\" --progress-bar off --upgrade\n - name: Test applications with pytest\n if: ${{ steps.filter.outputs.applications == 'true' }}\n run: |\n pytest keras/applications --cov=keras/applications\n coverage xml --include='keras/applications/*' -o apps-coverage.xml\n - name: Codecov keras.applications\n if: ${{ steps.filter.outputs.applications == 'true' }}\n uses: codecov/codecov-action@v3\n with:\n env_vars: PYTHON,KERAS_HOME\n flags: keras.applications,keras.applications-${{ matrix.backend }}\n files: apps-coverage.xml\n fail_ci_if_error: false\n - name: Test integrations\n if: ${{ matrix.backend != 'numpy'}}\n run: |\n python integration_tests/import_test.py\n - name: Test TF-specific integrations\n if: ${{ matrix.backend == 'tensorflow'}}\n run: |\n python integration_tests/tf_distribute_training_test.py\n - name: Test Torch-specific integrations\n if: ${{ matrix.backend == 'torch'}}\n run: |\n pytest integration_tests/torch_workflow_test.py\n - name: Test with pytest\n run: |\n pytest keras --ignore keras/applications --cov=keras\n coverage xml --omit='keras/applications/*' -o core-coverage.xml\n - name: Codecov keras\n uses: codecov/codecov-action@v3\n with:\n env_vars: PYTHON,KERAS_HOME\n flags: keras,keras-${{ matrix.backend }}\n files: core-coverage.xml\n fail_ci_if_error: false\n\n format:\n name: Check the code format\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@v4\n - name: Set up Python 3.9\n uses: actions/setup-python@v4\n with:\n python-version: '3.9'\n - name: Get pip cache dir\n id: pip-cache\n run: |\n python -m pip install --upgrade pip setuptools\n echo \"dir=$(pip cache dir)\" >> $GITHUB_OUTPUT\n - name: pip cache\n uses: actions/cache@v3\n with:\n path: ${{ steps.pip-cache.outputs.dir }}\n key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements.txt') }}\n - name: Install dependencies\n run: |\n pip install -r requirements.txt --progress-bar off --upgrade\n pip uninstall -y keras keras-nightly\n pip install -e \".\" --progress-bar off --upgrade\n - name: Lint\n run: bash shell/lint.sh\n", "logs": "keras/trainers/__init__.py 0 0 0 0 100%\nkeras/trainers/compile_utils.py 367 55 289 41 81%\nkeras/trainers/data_adapters/__init__.py 58 17 44 9 65%\nkeras/trainers/data_adapters/array_data_adapter.py 141 15 58 9 88%\nkeras/trainers/data_adapters/data_adapter.py 13 0 0 0 100%\nkeras/trainers/data_adapters/data_adapter_utils.py 92 19 61 13 74%\nkeras/trainers/data_adapters/generator_data_adapter.py 63 16 16 4 70%\nkeras/trainers/data_adapters/py_dataset_adapter.py 254 49 82 17 76%\nkeras/trainers/data_adapters/tf_dataset_adapter.py 57 1 24 1 98%\nkeras/trainers/data_adapters/torch_data_loader_adapter.py 46 30 10 0 29%\nkeras/trainers/epoch_iterator.py 54 3 28 7 88%\nkeras/trainers/trainer.py 194 25 92 15 83%\nkeras/utils/__init__.py 24 0 0 0 100%\nkeras/utils/argument_validation.py 43 10 26 5 78%\nkeras/utils/audio_dataset_utils.py 87 16 52 4 83%\nkeras/utils/backend_utils.py 37 10 12 2 63%\nkeras/utils/code_stats.py 40 3 34 2 91%\nkeras/utils/dataset_utils.py 295 64 216 47 74%\nkeras/utils/dtype_utils.py 25 0 16 0 100%\nkeras/utils/file_utils.py 221 52 129 23 71%\nkeras/utils/image_dataset_utils.py 97 9 54 9 87%\nkeras/utils/image_utils.py 150 73 80 13 45%\nkeras/utils/io_utils.py 34 0 10 0 100%\nkeras/utils/jax_utils.py 7 3 4 1 45%\nkeras/utils/model_visualization.py 193 169 90 0 8%\nkeras/utils/module_utils.py 32 1 6 1 95%\nkeras/utils/naming.py 34 1 8 1 95%\nkeras/utils/nest.py 42 9 18 3 77%\nkeras/utils/numerical_utils.py 58 4 26 5 89%\nkeras/utils/progbar.py 133 24 60 8 79%\nkeras/utils/python_utils.py 67 5 32 5 90%\nkeras/utils/rng_utils.py 16 3 6 3 73%\nkeras/utils/sequence_utils.py 41 8 24 6 78%\nkeras/utils/shape_utils.py 15 1 19 1 94%\nkeras/utils/summary_utils.py 212 39 116 17 77%\nkeras/utils/text_dataset_utils.py 68 4 40 5 90%\nkeras/utils/tf_utils.py 68 24 38 6 62%\nkeras/utils/timeseries_dataset_utils.py 62 4 48 5 92%\nkeras/utils/torch_utils.py 56 38 16 0 28%\nkeras/utils/traceback_utils.py 107 63 48 4 35%\nkeras/utils/tracking.py 114 13 62 7 81%\nkeras/version.py 5 1 0 0 80%\n----------------------------------------------------------------------------------------------\nTOTAL 37070 13646 14503 1409 61%\n\n=========================== short test summary info ============================\nFAILED keras/ops/nn_test.py::NNOpsDtypeTest::test_hard_sigmoid_bfloat16 - numpy.exceptions.DTypePromotionError: The DTypes <class 'numpy.dtype[bfloat16]'> and <class 'numpy.dtypes.Float16DType'> do not have a common DType. For example they cannot be stored in a single array unless the dtype is `object`.\nFAILED keras/ops/nn_test.py::NNOpsDtypeTest::test_hard_swish_bfloat16 - numpy.exceptions.DTypePromotionError: The DTypes <class 'numpy.dtype[bfloat16]'> and <class 'numpy.dtypes.Float16DType'> do not have a common DType. For example they cannot be stored in a single array unless the dtype is `object`.\n====== 2 failed, 8384 passed, 219 skipped, 1 xpassed in 309.91s (0:05:09) ======\n##[error]Process completed with exit code 1.\n", "diff": "diff --git a/keras/backend/tensorflow/nn.py b/keras/backend/tensorflow/nn.py\nindex 0e979656c7..e74155f6a4 100644\n--- a/keras/backend/tensorflow/nn.py\n+++ b/keras/backend/tensorflow/nn.py\n@@ -9,6 +9,7 @@ from keras.backend.common.backend_utils import (\n )\n from keras.backend.config import epsilon\n from keras.backend.tensorflow.core import cast\n+from keras.backend.tensorflow.core import convert_to_tensor\n \n \n def relu(x):\n@@ -51,7 +52,8 @@ def leaky_relu(x, negative_slope=0.2):\n \n \n def hard_sigmoid(x):\n- x = x / 6.0 + 0.5\n+ x = convert_to_tensor(x)\n+ x = x / tf.constant(6.0, dtype=x.dtype) + tf.constant(0.5, dtype=x.dtype)\n return tf.clip_by_value(x, 0.0, 1.0)\n \n \ndiff --git a/keras/ops/nn_test.py b/keras/ops/nn_test.py\nindex f3f464f816..3a15fca0eb 100644\n--- a/keras/ops/nn_test.py\n+++ b/keras/ops/nn_test.py\n@@ -1,6 +1,7 @@\n import numpy as np\n import pytest\n from absl.testing import parameterized\n+from tensorflow.python.ops.numpy_ops import np_config\n \n from keras import backend\n from keras import layers\n@@ -24,6 +25,9 @@ from keras.ops import nn as knn\n from keras.ops import numpy as knp\n from keras.testing.test_utils import named_product\n \n+# TODO: remove reliance on this (or alternatively, turn it on by default).\n+np_config.enable_numpy_behavior()\n+\n \n class NNOpsDynamicShapeTest(testing.TestCase, parameterized.TestCase):\n def test_relu(self):\n"}
data/9.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"head_branch": "master", "contributor": "keras-team", "sha_fail": "2989b6f8fc2aca8bf8d0ffa32e58ceeaa3ef35ef", "sha_success": "0484165fa7cba3c095d95da19b1c45945b47c60b", "language": "Python", "repo_owner": "keras-team", "repo_name": "keras", "workflow_name": "Tests", "workflow_filename": "actions.yml", "workflow_path": ".github/workflows/actions.yml", "workflow": "name: Tests\n\non:\n push:\n branches: [ master ]\n pull_request:\n release:\n types: [created]\n\npermissions:\n contents: read\n\njobs:\n build:\n strategy:\n fail-fast: false\n matrix:\n python-version: [3.9]\n backend: [tensorflow, jax, torch, numpy]\n name: Run tests\n runs-on: ubuntu-latest\n env:\n PYTHON: ${{ matrix.python-version }}\n KERAS_BACKEND: ${{ matrix.backend }}\n steps:\n - uses: actions/checkout@v3\n - name: Check for changes in keras/applications\n uses: dorny/paths-filter@v2\n id: filter\n with:\n filters: |\n applications:\n - 'keras/applications/**'\n - name: Set up Python\n uses: actions/setup-python@v4\n with:\n python-version: ${{ matrix.python-version }}\n - name: Get pip cache dir\n id: pip-cache\n run: |\n python -m pip install --upgrade pip setuptools\n echo \"dir=$(pip cache dir)\" >> $GITHUB_OUTPUT\n - name: pip cache\n uses: actions/cache@v3\n with:\n path: ${{ steps.pip-cache.outputs.dir }}\n key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements.txt') }}\n - name: Install dependencies\n run: |\n pip install -r requirements.txt --progress-bar off --upgrade\n pip install -e \".\" --progress-bar off --upgrade\n - name: Test applications with pytest\n if: ${{ steps.filter.outputs.applications == 'true' }}\n run: |\n pytest keras/applications --cov=keras.applications\n coverage xml --include='keras/applications/*' -o apps-coverage.xml\n - name: Codecov keras.applications\n if: ${{ steps.filter.outputs.applications == 'true' }}\n uses: codecov/codecov-action@v3\n with:\n env_vars: PYTHON,KERAS_BACKEND\n flags: keras.applications,keras.applications-${{ matrix.backend }}\n files: apps-coverage.xml\n fail_ci_if_error: true\n - name: Test with pytest\n run: |\n pytest keras --ignore keras/applications --cov=keras\n coverage xml --omit='keras/applications/*' -o core-coverage.xml\n - name: Codecov keras\n uses: codecov/codecov-action@v3\n with:\n env_vars: PYTHON,KERAS_BACKEND\n flags: keras,keras-${{ matrix.backend }}\n files: core-coverage.xml\n fail_ci_if_error: true\n\n format:\n name: Check the code format\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@v3\n - name: Set up Python 3.9\n uses: actions/setup-python@v4\n with:\n python-version: '3.9'\n - name: Get pip cache dir\n id: pip-cache\n run: |\n python -m pip install --upgrade pip setuptools\n echo \"dir=$(pip cache dir)\" >> $GITHUB_OUTPUT\n - name: pip cache\n uses: actions/cache@v3\n with:\n path: ${{ steps.pip-cache.outputs.dir }}\n key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements.txt') }}\n - name: Install dependencies\n run: |\n pip install -r requirements.txt --progress-bar off --upgrade\n pip install -e \".\" --progress-bar off --upgrade\n - name: Lint\n run: bash shell/lint.sh\n", "logs": "keras/testing/test_utils.py 11 1 4 1 87%\nkeras/trainers/__init__.py 0 0 0 0 100%\nkeras/trainers/compile_utils.py 356 54 281 39 81%\nkeras/trainers/data_adapters/__init__.py 0 0 0 0 100%\nkeras/trainers/data_adapters/array_data_adapter.py 141 19 58 11 84%\nkeras/trainers/data_adapters/data_adapter.py 13 0 0 0 100%\nkeras/trainers/data_adapters/data_adapter_utils.py 92 21 61 13 73%\nkeras/trainers/data_adapters/generator_data_adapter.py 41 3 8 3 88%\nkeras/trainers/data_adapters/py_dataset_adapter.py 252 49 80 17 76%\nkeras/trainers/data_adapters/tf_dataset_adapter.py 47 0 20 0 100%\nkeras/trainers/data_adapters/torch_data_adapter.py 46 3 10 3 89%\nkeras/trainers/epoch_iterator.py 105 13 72 13 83%\nkeras/trainers/trainer.py 193 23 89 14 84%\nkeras/utils/__init__.py 24 0 0 0 100%\nkeras/utils/argument_validation.py 43 10 26 5 78%\nkeras/utils/audio_dataset_utils.py 87 16 52 4 83%\nkeras/utils/backend_utils.py 37 6 12 3 78%\nkeras/utils/code_stats.py 40 3 34 2 91%\nkeras/utils/dataset_utils.py 286 61 202 45 74%\nkeras/utils/dtype_utils.py 25 0 16 0 100%\nkeras/utils/file_utils.py 221 52 129 23 71%\nkeras/utils/image_dataset_utils.py 91 6 48 6 90%\nkeras/utils/image_utils.py 149 73 80 13 45%\nkeras/utils/io_utils.py 34 0 10 0 100%\nkeras/utils/jax_utils.py 7 3 4 1 45%\nkeras/utils/model_visualization.py 193 169 90 0 8%\nkeras/utils/module_utils.py 32 1 6 1 95%\nkeras/utils/naming.py 34 1 8 1 95%\nkeras/utils/nest.py 42 9 18 3 77%\nkeras/utils/numerical_utils.py 58 4 26 5 89%\nkeras/utils/progbar.py 132 25 60 9 78%\nkeras/utils/python_utils.py 62 5 28 4 90%\nkeras/utils/rng_utils.py 16 1 6 3 82%\nkeras/utils/sequence_utils.py 41 8 24 6 78%\nkeras/utils/shape_utils.py 15 1 19 1 94%\nkeras/utils/summary_utils.py 212 39 116 18 77%\nkeras/utils/text_dataset_utils.py 68 4 40 5 90%\nkeras/utils/tf_utils.py 68 32 38 6 53%\nkeras/utils/timeseries_dataset_utils.py 62 4 48 5 92%\nkeras/utils/torch_utils.py 23 2 6 1 90%\nkeras/utils/traceback_utils.py 107 79 48 1 19%\nkeras/utils/tracking.py 97 10 54 5 82%\nkeras/version.py 1 0 0 0 100%\n----------------------------------------------------------------------------------------------\nTOTAL 34210 12322 13279 1442 62%\n\n=========================== short test summary info ============================\nFAILED keras/callbacks/model_checkpoint_test.py::ModelCheckpointTest::test_model_checkpoint_loading - ValueError: Arguments `target` and `output` must have the same shape. Received: target.shape=torch.Size([5, 1]), output.shape=torch.Size([5, 2])\n=========== 1 failed, 2902 passed, 306 skipped, 1 xpassed in 54.27s ============\n##[error]Process completed with exit code 1.\n", "diff": "diff --git a/examples/keras_io/vision/knowledge_distillation.py b/examples/keras_io/vision/knowledge_distillation.py\nnew file mode 100644\nindex 0000000000..8b0f2796a8\n--- /dev/null\n+++ b/examples/keras_io/vision/knowledge_distillation.py\n@@ -0,0 +1,246 @@\n+\"\"\"\n+Title: Knowledge Distillation\n+Author: [Kenneth Borup](https://twitter.com/Kennethborup)\n+Converted to Keras 3 by: [Md Awsafur Rahman](https://awsaf49.github.io)\n+Date created: 2020/09/01\n+Last modified: 2020/09/01\n+Description: Implementation of classical Knowledge Distillation.\n+Accelerator: GPU\n+\"\"\"\n+\"\"\"\n+## Introduction to Knowledge Distillation\n+\n+Knowledge Distillation is a procedure for model\n+compression, in which a small (student) model is trained to match a large pre-trained\n+(teacher) model. Knowledge is transferred from the teacher model to the student\n+by minimizing a loss function, aimed at matching softened teacher logits as well as\n+ground-truth labels.\n+\n+The logits are softened by applying a \"temperature\" scaling function in the softmax,\n+effectively smoothing out the probability distribution and revealing\n+inter-class relationships learned by the teacher.\n+\n+**Reference:**\n+\n+- [Hinton et al. (2015)](https://arxiv.org/abs/1503.02531)\n+\"\"\"\n+\n+\"\"\"\n+## Setup\n+\"\"\"\n+\n+import os\n+\n+os.environ[\"KERAS_BACKEND\"] = \"tensorflow\"\n+\n+import keras\n+from keras import layers\n+from keras import ops\n+import tensorflow as tf\n+import numpy as np\n+\n+\"\"\"\n+## Construct `Distiller()` class\n+\n+The custom `Distiller()` class, overrides the `Model` methods `compile`, `compute_loss`,\n+and `call`. In order to use the distiller, we need:\n+\n+- A trained teacher model\n+- A student model to train\n+- A student loss function on the difference between student predictions and ground-truth\n+- A distillation loss function, along with a `temperature`, on the difference between the\n+soft student predictions and the soft teacher labels\n+- An `alpha` factor to weight the student and distillation loss\n+- An optimizer for the student and (optional) metrics to evaluate performance\n+\n+In the `compute_loss` method, we perform a forward pass of both the teacher and student,\n+calculate the loss with weighting of the `student_loss` and `distillation_loss` by `alpha`\n+and `1 - alpha`, respectively. Note: only the student weights are updated.\n+\"\"\"\n+\n+\n+class Distiller(keras.Model):\n+ def __init__(self, student, teacher):\n+ super().__init__()\n+ self.teacher = teacher\n+ self.student = student\n+\n+ def compile(\n+ self,\n+ optimizer,\n+ metrics,\n+ student_loss_fn,\n+ distillation_loss_fn,\n+ alpha=0.1,\n+ temperature=3,\n+ ):\n+ \"\"\"Configure the distiller.\n+\n+ Args:\n+ optimizer: Keras optimizer for the student weights\n+ metrics: Keras metrics for evaluation\n+ student_loss_fn: Loss function of difference between student\n+ predictions and ground-truth\n+ distillation_loss_fn: Loss function of difference between soft\n+ student predictions and soft teacher predictions\n+ alpha: weight to student_loss_fn and 1-alpha to distillation_loss_fn\n+ temperature: Temperature for softening probability distributions.\n+ Larger temperature gives softer distributions.\n+ \"\"\"\n+ super().compile(optimizer=optimizer, metrics=metrics)\n+ self.student_loss_fn = student_loss_fn\n+ self.distillation_loss_fn = distillation_loss_fn\n+ self.alpha = alpha\n+ self.temperature = temperature\n+\n+ def compute_loss(\n+ self, x=None, y=None, y_pred=None, sample_weight=None, allow_empty=False\n+ ):\n+ teacher_pred = self.teacher(x, training=False)\n+ student_loss = self.student_loss_fn(y, y_pred)\n+\n+ distillation_loss = self.distillation_loss_fn(\n+ ops.softmax(teacher_pred / self.temperature, axis=1),\n+ ops.softmax(y_pred / self.temperature, axis=1),\n+ ) * (self.temperature**2)\n+\n+ loss = self.alpha * student_loss + (1 - self.alpha) * distillation_loss\n+ return loss\n+\n+ def call(self, x):\n+ return self.student(x)\n+\n+\n+\"\"\"\n+## Create student and teacher models\n+\n+Initialy, we create a teacher model and a smaller student model. Both models are\n+convolutional neural networks and created using `Sequential()`,\n+but could be any Keras model.\n+\"\"\"\n+\n+# Create the teacher\n+teacher = keras.Sequential(\n+ [\n+ keras.Input(shape=(28, 28, 1)),\n+ layers.Conv2D(256, (3, 3), strides=(2, 2), padding=\"same\"),\n+ layers.LeakyReLU(negative_slope=0.2),\n+ layers.MaxPooling2D(pool_size=(2, 2), strides=(1, 1), padding=\"same\"),\n+ layers.Conv2D(512, (3, 3), strides=(2, 2), padding=\"same\"),\n+ layers.Flatten(),\n+ layers.Dense(10),\n+ ],\n+ name=\"teacher\",\n+)\n+\n+# Create the student\n+student = keras.Sequential(\n+ [\n+ keras.Input(shape=(28, 28, 1)),\n+ layers.Conv2D(16, (3, 3), strides=(2, 2), padding=\"same\"),\n+ layers.LeakyReLU(negative_slope=0.2),\n+ layers.MaxPooling2D(pool_size=(2, 2), strides=(1, 1), padding=\"same\"),\n+ layers.Conv2D(32, (3, 3), strides=(2, 2), padding=\"same\"),\n+ layers.Flatten(),\n+ layers.Dense(10),\n+ ],\n+ name=\"student\",\n+)\n+\n+# Clone student for later comparison\n+student_scratch = keras.models.clone_model(student)\n+\n+\"\"\"\n+## Prepare the dataset\n+\n+The dataset used for training the teacher and distilling the teacher is\n+[MNIST](https://keras.io/api/datasets/mnist/), and the procedure would be equivalent for\n+any other\n+dataset, e.g. [CIFAR-10](https://keras.io/api/datasets/cifar10/), with a suitable choice\n+of models. Both the student and teacher are trained on the training set and evaluated on\n+the test set.\n+\"\"\"\n+\n+# Prepare the train and test dataset.\n+batch_size = 64\n+(x_train, y_train), (x_test, y_test) = keras.datasets.mnist.load_data()\n+\n+# Normalize data\n+x_train = x_train.astype(\"float32\") / 255.0\n+x_train = np.reshape(x_train, (-1, 28, 28, 1))\n+\n+x_test = x_test.astype(\"float32\") / 255.0\n+x_test = np.reshape(x_test, (-1, 28, 28, 1))\n+\n+\n+\"\"\"\n+## Train the teacher\n+\n+In knowledge distillation we assume that the teacher is trained and fixed. Thus, we start\n+by training the teacher model on the training set in the usual way.\n+\"\"\"\n+\n+# Train teacher as usual\n+teacher.compile(\n+ optimizer=keras.optimizers.Adam(),\n+ loss=keras.losses.SparseCategoricalCrossentropy(from_logits=True),\n+ metrics=[keras.metrics.SparseCategoricalAccuracy()],\n+)\n+\n+# Train and evaluate teacher on data.\n+teacher.fit(x_train, y_train, epochs=5)\n+teacher.evaluate(x_test, y_test)\n+\n+\"\"\"\n+## Distill teacher to student\n+\n+We have already trained the teacher model, and we only need to initialize a\n+`Distiller(student, teacher)` instance, `compile()` it with the desired losses,\n+hyperparameters and optimizer, and distill the teacher to the student.\n+\"\"\"\n+\n+# Initialize and compile distiller\n+distiller = Distiller(student=student, teacher=teacher)\n+distiller.compile(\n+ optimizer=keras.optimizers.Adam(),\n+ metrics=[keras.metrics.SparseCategoricalAccuracy()],\n+ student_loss_fn=keras.losses.SparseCategoricalCrossentropy(\n+ from_logits=True\n+ ),\n+ distillation_loss_fn=keras.losses.KLDivergence(),\n+ alpha=0.1,\n+ temperature=10,\n+)\n+\n+# Distill teacher to student\n+distiller.fit(x_train, y_train, epochs=3)\n+\n+# Evaluate student on test dataset\n+distiller.evaluate(x_test, y_test)\n+\n+\"\"\"\n+## Train student from scratch for comparison\n+\n+We can also train an equivalent student model from scratch without the teacher, in order\n+to evaluate the performance gain obtained by knowledge distillation.\n+\"\"\"\n+\n+# Train student as doen usually\n+student_scratch.compile(\n+ optimizer=keras.optimizers.Adam(),\n+ loss=keras.losses.SparseCategoricalCrossentropy(from_logits=True),\n+ metrics=[keras.metrics.SparseCategoricalAccuracy()],\n+)\n+\n+# Train and evaluate student trained from scratch.\n+student_scratch.fit(x_train, y_train, epochs=3)\n+student_scratch.evaluate(x_test, y_test)\n+\n+\"\"\"\n+If the teacher is trained for 5 full epochs and the student is distilled on this teacher\n+for 3 full epochs, you should in this example experience a performance boost compared to\n+training the same student model from scratch, and even compared to the teacher itself.\n+You should expect the teacher to have accuracy around 97.6%, the student trained from\n+scratch should be around 97.6%, and the distilled student should be around 98.1%. Remove\n+or try out different seeds to use different weight initializations.\n+\"\"\"\n"}