https://pantsbuild.org/ logo
r

rapid-bird-79300

06/18/2021, 2:24 PM
Hey Pants Team, saw a new error from
isort
when running
./pants fmt --changed-since=origin/master
. The BUILD file in the changed targets has
skip_isort=True
and it seems pants is executing
isort
with 0 files which causes an error.
Copy code
07:22:13.36 [DEBUG] Completed: Run isort on 0 files.
07:22:13.36 [DEBUG] Completed: (Waiting) Run isort on 0 files.
07:22:13.36 [DEBUG] Completed: Format with isort
07:22:13.36 [DEBUG] Completed: `fmt` goal
07:22:13.36 [DEBUG] computed 1 nodes in 2.802568 seconds. there are 448 total nodes.
07:22:13.36 [ERROR] Exception caught: (pants.engine.internals.scheduler.ExecutionError)
  File "/Users/njgrisafi/.cache/pants/setup/bootstrap-Darwin-x86_64/2.5.0_py37/lib/python3.7/site-packages/pants/bin/local_pants_runner.py", line 234, in _run_inner
    return self._perform_run(goals)
  File "/Users/njgrisafi/.cache/pants/setup/bootstrap-Darwin-x86_64/2.5.0_py37/lib/python3.7/site-packages/pants/bin/local_pants_runner.py", line 173, in _perform_run
    return self._perform_run_body(goals, poll=False)
  File "/Users/njgrisafi/.cache/pants/setup/bootstrap-Darwin-x86_64/2.5.0_py37/lib/python3.7/site-packages/pants/bin/local_pants_runner.py", line 195, in _perform_run_body
    poll_delay=(0.1 if poll else None),
  File "/Users/njgrisafi/.cache/pants/setup/bootstrap-Darwin-x86_64/2.5.0_py37/lib/python3.7/site-packages/pants/init/engine_initializer.py", line 136, in run_goal_rules
    goal_product, params, poll=poll, poll_delay=poll_delay
  File "/Users/njgrisafi/.cache/pants/setup/bootstrap-Darwin-x86_64/2.5.0_py37/lib/python3.7/site-packages/pants/engine/internals/scheduler.py", line 530, in run_goal_rule
    self._raise_on_error([t for _, t in throws])
  File "/Users/njgrisafi/.cache/pants/setup/bootstrap-Darwin-x86_64/2.5.0_py37/lib/python3.7/site-packages/pants/engine/internals/scheduler.py", line 494, in _raise_on_error
    wrapped_exceptions=tuple(t.exc for t in throws),

Exception message: 1 Exception encountered:

Engine traceback:
  in select
  in pants.core.goals.fmt.fmt
  in pants.backend.python.lint.python_fmt.format_python_target
  in pants.core.goals.fmt.enrich_fmt_result
  in pants.backend.python.lint.isort.rules.isort_fmt
  in pants.engine.process.fallible_to_exec_result_or_raise
Traceback (most recent call last):
  File "/Users/njgrisafi/.cache/pants/setup/bootstrap-Darwin-x86_64/2.5.0_py37/lib/python3.7/site-packages/pants/engine/process.py", line 254, in fallible_to_exec_result_or_raise
    description.value,
pants.engine.process.ProcessExecutionFailure: Process 'Run isort on 0 files.' failed with exit code 1.
stdout:


                 _                 _
                (_) ___  ___  _ __| |_
                | |/ _/ / _ \/ '__  _/
                | |\__ \/\_\/| |  | |_
                |_|\___/\___/\_/   \_/

      isort your imports, so you don't have to.

                    VERSION 5.5.5


Nothing to do: no files or paths have have been passed in!

Try one of the following:

    `isort .` - sort all Python files, starting from the current directory, recursively.
    `isort . --interactive` - Do the same, but ask before making any changes.
    `isort . --check --diff` - Check to see if imports are correctly sorted within this project.
    `isort --help` - In-depth information about isort's available command-line options.

Visit <https://pycqa.github.io/isort/> for complete information about how to use isort.


stderr:
Error: arguments passed in without any paths or content.
Has anyone seen this before?
Black does not seem to have this issue:
Copy code
07:39:59.88 [DEBUG] Completed: Run Black on 0 files.
07:39:59.88 [DEBUG] Completed: (Waiting) Run Black on 0 files.
07:39:59.88 [DEBUG] Completed: Format with Black
07:39:59.88 [INFO] Completed: fmt - Black made no changes.
No Path provided. Nothing to do šŸ˜“



āœ“ Black made no changes.
- isort skipped.
07:39:59.88 [DEBUG] Completed: `fmt` goal
07:39:59.88 [DEBUG] computed 1 nodes in 9.962709 seconds. there are 489 total nodes.
h

hundreds-father-404

06/18/2021, 2:41 PM
Thanks for the report! I'll try to reproduce in a couple minutes and cherry pick to 2.5
šŸ‘ 1
r

rapid-bird-79300

06/18/2021, 2:49 PM
@hundreds-father-404 I pushed an example branch here to repro this: https://github.com/njgrisafi/pants-example/tree/break-isort if you run
./pants fmt --changed-since=origin/main
you should see the error
šŸ™Œ 1
I think this only occurs with the
--changed-since
subsystem
h

hundreds-father-404

06/18/2021, 6:50 PM
@rapid-bird-79300 if you still have access, can you please run something like
git diff --stat  origin/master
? I'm not reproducing
r

rapid-bird-79300

06/18/2021, 7:21 PM
Some output:
Copy code
njgrisafi@Nicholass-MBP ~/workspace/pants-example (break-isort)$ git diff --stat  origin/main
 app/BUILD                | 4 +++-
 app/module_1/BUILD       | 4 +++-
 app/module_1/tests/BUILD | 5 ++++-
 pants.toml               | 9 +++++----
 pyproject.toml           | 8 ++++++++
 5 files changed, 23 insertions(+), 7 deletions(-)
also output from error on that branch:
Copy code
njgrisafi@Nicholass-MBP ~/workspace/pants-example (break-isort)$ ./pants fmt --changed-since=origin/main
12:21:04.42 [ERROR] Exception caught: (pants.engine.internals.scheduler.ExecutionError)
  File "/Users/njgrisafi/.cache/pants/setup/bootstrap-Darwin-x86_64/2.5.0_py37/lib/python3.7/site-packages/pants/bin/local_pants_runner.py", line 234, in _run_inner
    return self._perform_run(goals)
  File "/Users/njgrisafi/.cache/pants/setup/bootstrap-Darwin-x86_64/2.5.0_py37/lib/python3.7/site-packages/pants/bin/local_pants_runner.py", line 173, in _perform_run
    return self._perform_run_body(goals, poll=False)
  File "/Users/njgrisafi/.cache/pants/setup/bootstrap-Darwin-x86_64/2.5.0_py37/lib/python3.7/site-packages/pants/bin/local_pants_runner.py", line 195, in _perform_run_body
    poll_delay=(0.1 if poll else None),
  File "/Users/njgrisafi/.cache/pants/setup/bootstrap-Darwin-x86_64/2.5.0_py37/lib/python3.7/site-packages/pants/init/engine_initializer.py", line 136, in run_goal_rules
    goal_product, params, poll=poll, poll_delay=poll_delay
  File "/Users/njgrisafi/.cache/pants/setup/bootstrap-Darwin-x86_64/2.5.0_py37/lib/python3.7/site-packages/pants/engine/internals/scheduler.py", line 530, in run_goal_rule
    self._raise_on_error([t for _, t in throws])
  File "/Users/njgrisafi/.cache/pants/setup/bootstrap-Darwin-x86_64/2.5.0_py37/lib/python3.7/site-packages/pants/engine/internals/scheduler.py", line 500, in _raise_on_error
    wrapped_exceptions=tuple(t.exc for t in throws),

Exception message: 1 Exception encountered:

  ProcessExecutionFailure: Process 'Run isort on 0 files.' failed with exit code 1.
stdout:


                 _                 _
                (_) ___  ___  _ __| |_
                | |/ _/ / _ \/ '__  _/
                | |\__ \/\_\/| |  | |_
                |_|\___/\___/\_/   \_/

      isort your imports, so you don't have to.

                    VERSION 5.5.5


Nothing to do: no files or paths have have been passed in!

Try one of the following:

    `isort .` - sort all Python files, starting from the current directory, recursively.
    `isort . --interactive` - Do the same, but ask before making any changes.
    `isort . --check --diff` - Check to see if imports are correctly sorted within this project.
    `isort --help` - In-depth information about isort's available command-line options.

Visit <https://pycqa.github.io/isort/> for complete information about how to use isort.


stderr:
Error: arguments passed in without any paths or content.



(Use --print-stacktrace to see more error details.)
h

hundreds-father-404

06/18/2021, 7:22 PM
interestingggg, so you only changed BUILD files, not Python files. Are you able to post or DM those BUILD files please?
r

rapid-bird-79300

06/18/2021, 7:22 PM
yeah everything is on this branch here: https://github.com/njgrisafi/pants-example/tree/break-isort
šŸ™Œ 1
just to be sure
origin/master
->
origin/main
for that repo if you are testing there
šŸ‘ 1
we got more reports of this and I did a quick hack for a work around. I pushed the another branch to show the work around we're considering using: https://github.com/njgrisafi/pants-example/tree/break-isort-hack we added a check to make sure we don't run isort when the number of files is 0: https://github.com/njgrisafi/pants-example/blob/a1c4e270dbde9d7ef792ec88c3b2696c1508ba36/pants-plugins/custom_isort/rules.py#L137-L138
h

hundreds-father-404

06/19/2021, 12:05 AM
btw your
./pants
script is out of date: https://raw.githubusercontent.com/pantsbuild/setup/gh-pages/pants And you can remove
[isort].config
if using Pants 2.5. It should be auto-discovered
šŸ‘€ 1
Oh interesting. This only happens for
fmt
, not
lint
šŸ‘ 1
r

rapid-bird-79300

06/19/2021, 12:09 AM
yeah it only happens for
fmt
with
--changed-since
we use this script in CI and for local environment fixes
h

hundreds-father-404

06/19/2021, 12:19 AM
Ah, I see the fix! Thanks! Will cherry-pick to 2.5
šŸ™Œ 1
šŸš€ 1
https://github.com/pantsbuild/pants/pull/12230 thanks for the example repo, that was super helpful to debug!
šŸ™‡ 1
šŸ™Œ 1
2 Views