Hi, a question on MyPy. It seems it takes a long t...
# general
w
Hi, a question on MyPy. It seems it takes a long time to build mypy.pex
Copy code
[2022-04-12T14:27:05.810Z] 10:27:05.59 [INFO] Completed: Building mypy.pex from build-support/mypy_lockfile.txt
[2022-04-12T14:28:27.628Z] 10:28:22.84 [INFO] Long running tasks:
[2022-04-12T14:28:27.628Z]   86.52s	Installing build-support/lockfile.txt for the resolve `python-default`
[2022-04-12T14:28:54.377Z] 10:28:52.92 [INFO] Long running tasks:
[2022-04-12T14:28:54.377Z]   116.60s	Installing build-support/lockfile.txt for the resolve `python-default`
[2022-04-12T14:29:26.494Z] 10:29:22.95 [INFO] Long running tasks:
[2022-04-12T14:29:26.494Z]   146.63s	Installing build-support/lockfile.txt for the resolve `python-default`
[2022-04-12T14:29:53.033Z] 10:29:52.98 [INFO] Long running tasks:
[2022-04-12T14:29:53.033Z]   176.66s	Installing build-support/lockfile.txt for the resolve `python-default`
[2022-04-12T14:30:25.092Z] 10:30:23.03 [INFO] Long running tasks:
[2022-04-12T14:30:25.092Z]   206.71s	Installing build-support/lockfile.txt for the resolve `python-default`
[2022-04-12T14:30:57.197Z] 10:30:53.08 [INFO] Long running tasks:
[2022-04-12T14:30:57.197Z]   236.76s	Installing build-support/lockfile.txt for the resolve `python-default`
[2022-04-12T14:31:23.761Z] 10:31:23.12 [INFO] Long running tasks:
[2022-04-12T14:31:23.761Z]   266.80s	Installing build-support/lockfile.txt for the resolve `python-default`
[2022-04-12T14:31:56.020Z] 10:31:53.18 [INFO] Long running tasks:
[2022-04-12T14:31:56.020Z]   296.86s	Installing build-support/lockfile.txt for the resolve `python-default`
[2022-04-12T14:32:28.129Z] 10:32:23.22 [INFO] Long running tasks:
[2022-04-12T14:32:28.129Z]   326.90s	Installing build-support/lockfile.txt for the resolve `python-default`
[2022-04-12T14:32:54.681Z] 10:32:53.28 [INFO] Long running tasks:
[2022-04-12T14:32:54.681Z]   356.96s	Installing build-support/lockfile.txt for the resolve `python-default`
[2022-04-12T14:33:27.350Z] 10:33:23.34 [INFO] Long running tasks:
[2022-04-12T14:33:27.350Z]   387.02s	Installing build-support/lockfile.txt for the resolve `python-default`
I am wondering if it is related to the cache issue in MyPy mentioned here https://www.pantsbuild.org/docs/python-check-goal#performance-is-often-slower-than-normal?
b
So there's a few things here: • Building
mypy.pex
finished (probably quickly)
Completed: Building mypy.pex from build-support/mypy_lockfile.txt
• What you're seeing is Pants installing of the dependencies in your resolve. Depending on the size of your resolve, or the size of those deps it can take a while. ◦ This also depends on your settings, which Pants version you're using, and if you're using the new PEX lockfiles • The linked MyPy issue has to do with the performance of running mypy, which you haven't gotten to that step yet 😅
There's tradeoffs to this, but you could disable `[python.resolve_all_constraints`: https://www.pantsbuild.org/v2.11/docs/reference-python#section-resolve-all-constraints Or if you're on Pants 2.11.x, using a PEX lockfile would be extremely performant
w
@bitter-ability-32190 thanks for info. I am using a lockfile for mypy since I need a different version of MpPy in Pants 2.10, which is the version of Pants I am using.
b
Ah, so Pants 2.11.x introduces a new kind of lockfile: a PEX (JSON) lockfile. When 2.11.x goes non-rc I recommend trying ti out 😃 In the meantime your options are
resolve_all_constraints
or not.
1
👍 1
w
I am just wondering why it only happens for MyPy? I dont see the same for isort/black/etc.
b
Good question! Formatters like
isort
and
black
don't require any of your dependencies to run. linters/checkers like
pylint
or
mypy
do require dependencies, so you just happen to be executing your first command which requires deps.
👍 1
w
Thanks. It is clear to me. Btw, is there any docs already available on the new PEX lockfile in 2.11?
Another question is about, when Pants will re-build the mypy.pex and install those dependencies? Does it only run once, or it will only run when pants detects some change in the dependencies? From my observation, it does not happen everytime when I run
pants check
.
b
(Don't forget the
mypy.pex
just contains mypy and friends (and not your deps)._
👍 1
But for the
pex
containing all of your deps. Yes that'll only rebuild when your lockfile changes
h
I am updating our docs for pants 2.11 this week, so we will have docs soon about the new pex lock files
1
❤️ 1
w
Hi @hundreds-father-404 I am wondering if you have the relevant docs for pants 2.11. The problem I am facing now is that, in our CI, the unittests are used to complete very fast assuming the conda env is there. But with Pants, given it needs to resolve those dependencies, running unittest become very slow. I am wondering if the PEX lockfile can solve/help this issue? or do you have any other suggestion?
Another related question: we are tying to use Pants in our Jenkins CI. In our CI, we run all unittest first, then integration test. Translate it to pants, we have something like
./pants --tag='unit_test' ::
and
./pants --tag='int_test' ::
, but i found the following in both steps.
Copy code
[2022-04-21T17:10:57.265Z] 13:10:50.51 [INFO] Long running tasks:
[2022-04-21T17:10:57.265Z]   82.29s	Installing build-support/lockfile.txt for the resolve `python-default`
[2022-04-21T17:11:22.031Z] 13:11:20.54 [INFO] Long running tasks:
[2022-04-21T17:11:22.031Z]   112.32s	Installing build-support/lockfile.txt for the resolve `python-default`
I am wondering why this step needs to repeat? @hundreds-father-404
@witty-crayon-22786 just wondering if you know anything about the question above?
b
Are you sure the cache is persisting between each step?
w
what do you mean by cache each step?
b
Pants stores cached results in
~/.cache/pants
by default. Is that dir persisting between the call to unit tests and integration tests?
w
em the unittest and integration tests are different stages in a Jenkins CI pipeline. I believe they are shared. No?
b
🤷‍♂️ I know nothing of Jenkins implmentation details. That's where I'd start investigating
w
thanks! I will take a look
I think the cache is there. But i still see `Installing build-support/lockfile.txt for the resolve `python-default`` multiple times across different places.
w
which version is this? if you can confirm that you are definitely preserving the cache, filing an issue with some more details about which commands you’re running in which sequence would be good. there are some contexts in which you might not be able to reuse a lockfile resolve: across
test
and
package
you might not be able to in some cases, for example. but between tests you always should be able to.
also: do you have multiple sets of interpreter constraints in this repository?
w
there are some contexts in which you might not be able to reuse a lockfile resolve: across
test
and
package
do you mind sharing some more info or example?
also: do you have multiple sets of interpreter constraints in this repository?
No
I just take more close look at our pipeline. As I mentioned that we have unittest, int test and we also have system test in addition. I dont see lockfile resolve in the system test. It seems for some reason, the int test just cannot reuse what unittest resolves.
w
do you mind sharing some more info or example?
there isn’t a very concise explanation, except to say that
test
runs on exactly one interpreter chosen by pants per-run (“internal”), and that interpreter is part of the cache key. whereas
package
is building a portable
PEX
file, and so it will attempt to maximize compatibility with your interpreter constraints, rather than matching exactly one.
w
Copy code
interpreter_constraints = ["==3.9.*"]
This is what I have. i can pin it to a particular version and see.
I turned on the lsdebug model. where I can see the following from in the sys test step. But the int test are still resolving ‘python-default’ which is already done once in the unit test stage.
Copy code
[2022-04-22T19:11:50.654Z] 15:11:50.52 [DEBUG] Starting: Scheduling: Building pytest.pex from pytest_default_lockfile.txt
[2022-04-22T19:11:50.654Z] 15:11:50.52 [DEBUG] Starting: Scheduling: Installing build-support/lockfile.txt for the resolve `python-default`
[2022-04-22T19:11:50.654Z] 15:11:50.52 [DEBUG] Completed: Hit: Local cache lookup: Building pytest.pex from pytest_default_lockfile.txt
Hi @hundreds-father-404 @witty-crayon-22786 could you remind me where Pants put the cache for `Installing build-support/lockfile.txt for the resolve `python-default``?
w
w
I think i find the answer to my question. It seem the env vars in our jenkins pipeline for unit and int tests are different. I believe when env vars are differernt, the pants will resolve the dependencies again.
b
Ah yeah that makes sense. Pants today takes a very conservative approach to hermeticity, and invalidates eagerly. Who is to say an env car doesn't change the behavior of a Python install? (After all, setup.py is just code, it could do anything)