Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make test-types fails for plugins when tutor is installed in editable mode #956

Open
regisb opened this issue Dec 6, 2023 · 6 comments
Open
Labels
bug Bugs will be investigated and fixed as quickly as possible.

Comments

@regisb
Copy link
Contributor

regisb commented Dec 6, 2023

Bug description

Type tests fail when tutor is installed in editable mode. This is inconvenient when testing plugins locally.

How to reproduce

Install tutor in editable mode:

cd tutor/
pip install -e .[dev]

Run type tests for a plugin:

cd tutorcairn/
make test-types
mypy --exclude=templates --ignore-missing-imports --implicit-reexport --strict ./tutorcairn
tutorcairn/plugin.py:122: error: Untyped decorator makes function "_print_superset_host" untyped  [misc]
Found 1 error in 1 file (checked 3 source files)
make: *** [Makefile:16: test-types] Error 1

That error is caused by the fact that mypy does not find the tutor module, has the following attests:

$ mypy -m tutor
mypy: can't find module 'tutor'

Additional context

This is a known issue. See the upstream tickets in mypy and setuptools:

python/mypy#13392
pypa/setuptools#3518

The issue can be bypassed by installing tutor in legacy mode:

pip install -e . --config-settings editable_mode=compat

Or by installing in non-editable mode:

pip install .
@regisb regisb added the bug Bugs will be investigated and fixed as quickly as possible. label Dec 6, 2023
@Abdul-Muqadim-Arbisoft Abdul-Muqadim-Arbisoft moved this from Backlog to In Progress in Tutor project management Dec 12, 2023
@Abdul-Muqadim-Arbisoft
Copy link
Contributor

Abdul-Muqadim-Arbisoft commented Dec 13, 2023

Looking into it

@regisb
Copy link
Contributor Author

regisb commented Dec 14, 2023

Here's a Dockerfile to reproduce the issue:

# syntax=docker/dockerfile:1
FROM python:3.10

RUN mkdir -p /test

ADD --keep-git-dir=true https://github.com/overhangio/tutor.git#master /test/tutor
ADD --keep-git-dir=true https://github.com/overhangio/tutor-cairn.git#master /test/tutor-cairn

RUN python -m venv /test/venv
ENV PATH /test/venv/bin:${PATH}
RUN pip install --upgrade pip setuptools
RUN pip install -e '/test/tutor[dev]'

WORKDIR /test/tutor-cairn
RUN make test-types
$ docker build .
...
 => ERROR [9/9] RUN make test-types                                                                                                                                                                    2.7s 
------                                                                                                                                                                                                      
 > [9/9] RUN make test-types:                                                                                                                                                                               
0.271 mypy --exclude=templates --ignore-missing-imports --implicit-reexport --strict ./tutorcairn                                                                                                           
2.636 tutorcairn/plugin.py:120: error: Untyped decorator makes function "_print_superset_host" untyped  [misc]                                                                                              
2.638 Found 1 error in 1 file (checked 3 source files)
2.644 make: *** [Makefile:16: test-types] Error 1
------
Dockerfile:15
--------------------
  13 |     
  14 |     WORKDIR /test/tutor-cairn
  15 | >>> RUN make test-types
  16 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c make test-types" did not complete successfully: exit code: 2

Building the image succeeds when we replace pip install -e by pip install.

@regisb regisb moved this from In Progress to Backlog in Tutor project management Dec 19, 2023
@Abdul-Muqadim-Arbisoft Abdul-Muqadim-Arbisoft removed their assignment Dec 19, 2023
@regisb
Copy link
Contributor Author

regisb commented Jan 23, 2024

See this issue in practice in this failed test run: https://github.com/overhangio/tutor-credentials/actions/runs/7568050350/job/20608428713

@rohan-saeed
Copy link
Contributor

The strict mode also seems to does the trick. It can be acheived through:
pip install -e . --config-settings editable_mode=strict

@hinakhadim
Copy link
Contributor

@regisb Can you please provide insights on it? If there is no more discussion on it, we can close this.

@regisb
Copy link
Contributor Author

regisb commented Apr 9, 2024

This issue is still open. For instance, consider the case of nightly. We are telling people to install tutor with pip install -e ., as they are used to. But that means that they won't be able to run make test-types on their plugins, which is a shame. It's an upstream issue, and I don't know if we can address it in Tutor, but I don't think it should be closed.

@DawoudSheraz DawoudSheraz moved this from In Progress to Blocked in Tutor project management Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugs will be investigated and fixed as quickly as possible.
Projects
Development

No branches or pull requests

4 participants