Repository: lightly-ai/lightly (branch: master)
Commit date: 2024-01-05T14:11:57Z

Workflow file: .github/workflows/test_setup.yml (check setup.py)
name: check setup.py

on:
  push:
    paths-ignore:
      - 'docs/**'
  pull_request:
    paths-ignore:
      - 'docs/**'
  workflow_dispatch:

jobs:
  test:
    name: Test setup.py
    runs-on: ubuntu-latest
    services:
      pypi_wayback:
        image: ghcr.io/waleko/pypi-wayback
        ports:
          - 8629:8080


    steps:
    - name: Checkout Code
      uses: actions/checkout@v3
    - name: Hack to get setup-python to work on nektos/act
      run: |
        if [ ! -f "/etc/lsb-release" ] ; then
          echo "DISTRIB_RELEASE=18.04" > /etc/lsb-release
        fi
    - name: Set up Python 3.7
      uses: actions/setup-python@v4
      with:
        python-version: 3.7
    - uses: actions/cache@v2
      with:
        path: ${{ env.pythonLocation }}
        key: cache_v2_${{ env.pythonLocation }}-${{ hashFiles('requirements/**') }}
    - name: Install Dependencies and lightly
      run: pip install .
    - name: basic tests of CLI
      run: |
        LIGHTLY_SERVER_LOCATION="localhost:-1"
        lightly-crop --help
        lightly-train --help
        lightly-embed --help
        lightly-magic --help
        lightly-download --help
        lightly-version
    - name: test of CLI on a real dataset
      run: |
        LIGHTLY_SERVER_LOCATION="localhost:-1"
        git clone https://github.com/alexeygrigorev/clothing-dataset-small clothing_dataset_small
        INPUT_DIR_1="clothing_dataset_small/test/dress"
        lightly-train input_dir=$INPUT_DIR_1 trainer.max_epochs=1 loader.num_workers=6
        lightly-embed input_dir=$INPUT_DIR_1

env:
  PIP_INDEX_URL: http://localhost:8629/2024-01-05
  UV_INDEX_URL: http://localhost:8629/2024-01-05


Failed build logs:
step_name: Test setup.py/7_basic tests of CLI.txt
log: ##[group]Run LIGHTLY_SERVER_LOCATION="localhost:-1"
[36;1mLIGHTLY_SERVER_LOCATION="localhost:-1"[0m
[36;1mlightly-crop --help[0m
[36;1mlightly-train --help[0m
[36;1mlightly-embed --help[0m
[36;1mlightly-magic --help[0m
[36;1mlightly-download --help[0m
[36;1mlightly-version[0m
shell: /usr/bin/bash -e {0}
env:
  pythonLocation: /opt/hostedtoolcache/Python/3.7.17/x64
  PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.7.17/x64/lib/pkgconfig
  Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.7.17/x64
  Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.7.17/x64
  Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.7.17/x64
  LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.7.17/x64/lib
##[endgroup]
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.7.17/x64/bin/lightly-crop", line 5, in <module>
    from lightly.cli.crop_cli import entry
  File "/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/lightly/cli/__init__.py", line 12, in <module>
    from lightly.cli.lightly_cli import lightly_cli
  File "/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/lightly/cli/lightly_cli.py", line 16, in <module>
    from lightly.cli.train_cli import _train_cli
  File "/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/lightly/cli/train_cli.py", line 31, in <module>
    from lightly.loss import NTXentLoss
  File "/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/lightly/loss/__init__.py", line 6, in <module>
    from lightly.loss.dcl_loss import DCLLoss, DCLWLoss
  File "/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/lightly/loss/dcl_loss.py", line 9, in <module>
    from lightly.utils import dist
  File "/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/lightly/utils/dist.py", line 1, in <module>
    from typing import Any, Callable, Literal, Optional, Tuple, TypeVar, Union
ImportError: cannot import name 'Literal' from 'typing' (/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/typing.py)
##[error]Process completed with exit code 1.


Changed files:
lightly/utils/dist.py

Fix diff:
diff --git a/lightly/utils/dist.py b/lightly/utils/dist.py
index e56b43a3..7c8c7f77 100644
--- a/lightly/utils/dist.py
+++ b/lightly/utils/dist.py
@@ -1,4 +1,4 @@
-from typing import Any, Callable, Literal, Optional, Tuple, TypeVar, Union
+from typing import Any, Callable, Optional, Tuple, TypeVar, Union
 
 import torch
 import torch.distributed as dist