https://pantsbuild.org/ logo
s

strong-toothbrush-37759

09/23/2022, 11:50 AM
I’m experiencing an indefinite `Filesystem changed during run: retrying
Test
in 500ms...` loop while trying to run multiple tests. I was AFK for about 20 minutes and came back to this (thread). Any experience here or any good advice?
Copy code
❯ p test src/core/tests/
13:24:17.25 [INFO] Completed: Run Pytest - src/core/tests/test_feedback.py:tests0 succeeded.
13:24:25.86 [INFO] Filesystem changed during run: retrying `Test` in 500ms...
13:24:26.87 [INFO] Filesystem changed during run: retrying `Test` in 500ms...
13:25:25.85 [INFO] Filesystem changed during run: retrying `Test` in 500ms...
...
13:30:25.86 [INFO] Filesystem changed during run: retrying `Test` in 500ms...
...
13:48:26.89 [INFO] Filesystem changed during run: retrying `Test` in 500ms...
Side fact: • Mac OSX 12.5.1 • Terminal ->
tmux
->
fish-shell
->
<http://startship.rs|startship.rs>
prompt
w

wide-midnight-78598

09/23/2022, 11:56 AM
Does your
python_test
target include anything other than
.py
files?
s

strong-toothbrush-37759

09/23/2022, 11:57 AM
src/core/tests/BUILD
contains:
Copy code
python_sources(
    dependencies=[
        "src/config",
        "src:requirements.txt#periodiq",
        "src:requirements.txt#django-extensions",
    ],
)

python_tests(
    name="tests0",
    dependencies=[
        "src/config",
    ],
)
Nothing other than Python-files I think 🤔
./pants dependencies src/core/tests/
:
Copy code
src/config/__init__.py
src/config/admin.py
src/config/apps.py
src/config/asgi.py
src/config/gunicorn.py
src/config/settings.py
src/config/settings_production.py
src/config/settings_staging.py
src/config/settings_testing.py
src/config/urls.py
src/config/wsgi.py
src/conftest.py:test_utils
src/core/__init__.py
src/core/models/__init__.py
src/core/tests/factories/__init__.py
src:requirements-dev.txt#Faker
src:requirements-dev.txt#factory-boy
src:requirements-dev.txt#pytest
src:requirements.txt#django-extensions
src:requirements.txt#periodiq
To clarify dependencies
w

wide-midnight-78598

09/23/2022, 11:59 AM
Not by default, no - I was wondering if there was something simple that was writing a file to a tracked target. I've done that by accident before
s

strong-toothbrush-37759

09/23/2022, 12:00 PM
Like a test that is writing to a watched directory?
w

wide-midnight-78598

09/23/2022, 12:00 PM
More or less, yeah - it was silly because I was also keeping a Pants-eye on some text file for some reason
But, I would think that if it's not included in the target - then it shouldn't cause this
s

strong-toothbrush-37759

09/23/2022, 12:01 PM
I’m sure that’s not what’s happening here. The tests in src/core/tests are basically factories being validated. All just like this:
Copy code
@pytest.mark.django_db()
def test_company_complete_factory():
    data = CompanyCompleteFactory.create_batch(5)
    assert len(data) == 5
w

wide-midnight-78598

09/23/2022, 12:01 PM
Is
p
an alias? Or a wrapper?
s

strong-toothbrush-37759

09/23/2022, 12:02 PM
Ah, yeah sorry it’s an alias:
alias p "./pants"
😄
w

wide-midnight-78598

09/23/2022, 12:04 PM
I figured 🙂 just checking if it was a wrapper as I've seen before. Actually, one thing I honestly don't know about, is the behaviour any different when using the directory convention vs target.
./pants test src/core/tests/
vs something like
./pants test src/core::
I assume not, but I can't remember having tested it before
s

strong-toothbrush-37759

09/23/2022, 12:05 PM
Copy code
❯ p test src/core/tests:tests0
14:05:12.26 [INFO] Completed: Run Pytest - src/core/tests/test_feedback.py:tests0 succeeded.
14:05:25.86 [INFO] Filesystem changed during run: retrying `Test` in 500ms...
14:05:26.84 [INFO] Filesystem changed during run: retrying `Test` in 500ms...
⠉ 11.65s Run Pytest for src/core/tests/test_study.py:tests0
⠉ 11.65s Run Pytest for src/core/tests/test_companies.py:tests0
⠉ 11.65s Run Pytest for src/core/tests/test_tenant.py:tests0
I think it renders the same results.
w

wide-midnight-78598

09/23/2022, 12:06 PM
🤯
Which version of pants?
s

strong-toothbrush-37759

09/23/2022, 12:06 PM
Funny thing is that it happens randomly that pants tells me that my Filesystem changed.
2.13.0
I’m on a M1 processor, if that makes any difference to pants or the implementation in rust.
w

wide-midnight-78598

09/23/2022, 12:10 PM
Hmm, that'd have to be a question for someone else with an M1 - typically that line means that one of your watched files has changed, but that doesn't seem like it -should- happen here
s

strong-toothbrush-37759

09/23/2022, 12:10 PM
I’m gonna reboot and try with a fresh env
w

wide-midnight-78598

09/23/2022, 12:11 PM
When in doubt, reboot 🙂 Good luck! And maybe someone more knowledgeable can help when they come online
s

strong-toothbrush-37759

09/23/2022, 12:15 PM
No luck unfortunately with the reboot 😄
b

bitter-ability-32190

09/23/2022, 12:19 PM
.pants.d/pants.log
usually has a log line pertaining to the file which inotify has told pants has changed
Also, it's any file in Pants' purview that could change, not just the ones relevant for the goal
s

strong-toothbrush-37759

09/23/2022, 12:20 PM
taken from
.pants.d/pants.log
:
Copy code
14:19:46.60 [INFO] handling request: `--pants-bin-name=/<projectfolder>/pants --pants-version=2.13.0 test src/core/tests:tests0`
14:20:04.93 [INFO] notify invalidation: cleared 0 and dirtied 0 nodes for: {".git/FETCH_HEAD", ".git"}
14:20:04.93 [INFO] notify invalidation: cleared 1 and dirtied 1381 nodes for: {".git", ".git/FETCH_HEAD"}
14:20:05.88 [INFO] notify invalidation: cleared 0 and dirtied 0 nodes for: {".git/FETCH_HEAD"}
14:20:05.88 [INFO] notify invalidation: cleared 0 and dirtied 0 nodes for: {".git/FETCH_HEAD"}
14:20:05.93 [INFO] notify invalidation: cleared 0 and dirtied 0 nodes for: {".git/objects", ".git/objects/maintenance.lock"}
14:20:05.93 [INFO] notify invalidation: cleared 0 and dirtied 0 nodes for: {".git/objects", ".git/objects/maintenance.lock"}
14:20:05.93 [INFO] notify invalidation: cleared 1 and dirtied 1381 nodes for: {".git/objects/maintenance.lock", ".git/objects"}
14:20:05.93 [INFO] notify invalidation: cleared 0 and dirtied 0 nodes for: {".git/objects", ".git/objects/maintenance.lock"}
🤔
b

bitter-ability-32190

09/23/2022, 12:23 PM
So pants is watching your .git directory. Have you twiddled with the settings for ignores?
s

strong-toothbrush-37759

09/23/2022, 12:23 PM
These are in the
.gitignore
@ root:
Copy code
# Pants workspace files
/.pants.d/
/dist
/.pids
/.pants.workdir.file_lock*
I’m using lazygit which seems to be messing with the git maintenance 🤔. But why is that important to pants? I understand that pants is watching files, but I didn’t think it would be watching the git tree when I’m telling it to run a specific collection of files in a test goal. For me running a “run”-Command triggering a file-watcher seems like unexpected behavior to me. What’s the idea behind this? In any case: Thank you very much @bitter-ability-32190 for clarifying! Stopping lazygit solves the issue for now. As most of my devs are running it though, this isn’t optimal.
w

wide-midnight-78598

09/23/2022, 12:39 PM
Whoa, Pants watches
.git
for changes?
🤯
Admittedly I think I'm also surprised that
lazygit
is modifying stuff in the git folder at that frequency
s

strong-toothbrush-37759

09/23/2022, 12:55 PM
I think that’s due to the fact that lazygit renders changes based on the git object tree.
A simple
git status
while pants command is running is triggering the “file changed” event handler btw. 😅
b

bitter-ability-32190

09/23/2022, 1:12 PM
Pants watches anything unless configured otherwise. The default ignores includes .git though
@strong-toothbrush-37759 what's your
pants_ignore
? https://www.pantsbuild.org/docs/reference-global
s

strong-toothbrush-37759

09/23/2022, 1:14 PM
Thanks again, I have indeed changed the
pants_ignore
variable.
b

bitter-ability-32190

09/23/2022, 1:14 PM
It should be excluding all dot files and dirs by defaukt
You can do
pants_ignore.add = ...
w

wide-midnight-78598

09/23/2022, 1:19 PM
It should be excluding all dot files and dirs by defaukt
Thanks for pointing out this default, I was just going through an existential crisis
h

happy-kitchen-89482

09/23/2022, 1:20 PM
Pants doesn’t watch .git by default, it should only be watching your own source files for changes.
s

strong-toothbrush-37759

09/23/2022, 1:21 PM
So just to be clear, this should avoid matching all Markdown files? So when I edit a markdown file with this setting, pants should not reevaludate?
Copy code
pants_ignore.add = [
  "*.md",
]
h

happy-kitchen-89482

09/23/2022, 1:21 PM
Thanks to `pants_ignore`’s defaults
Correct!
That will add to the defaults
Were you
pants_ignore = [...]
before? That is a common gotcha alas
s

strong-toothbrush-37759

09/23/2022, 1:23 PM
Yes I was using it without
.add
before. Unfortunately it does not do what it is told 😄 My ignores:
Copy code
pants_ignore.add = [
  "/apps/",
  "/src/bin",
  "/src/docker",
  "/frontend/",
  "/python/",
  ".idea/",
  "*.md",
]
I’m starting a test, changing a Markdown file, and the test restarts.
Copy code
15:21:26.37 [INFO] handling request: `--pants-bin-name=/Users/vader/dev/sntls/osiris/pants --pants-version=2.13.0 test src/core/::`
15:21:29.62 [INFO] notify invalidation: cleared 0 and dirtied 0 nodes for: {"pants-TODOS.md~", ""}
15:21:29.62 [INFO] notify invalidation: cleared 0 and dirtied 0 nodes for: {"pants-TODOS.md~", ""}
15:21:29.62 [INFO] notify invalidation: cleared 0 and dirtied 0 nodes for: {"", "pants-TODOS.md~"}
15:21:29.62 [INFO] notify invalidation: cleared 0 and dirtied 0 nodes for: {"", "pants-TODOS.md~"}
15:21:29.62 [INFO] notify invalidation: cleared 0 and dirtied 0 nodes for: {"pants-TODOS.md~"}
15:21:29.62 [INFO] notify invalidation: cleared 1 and dirtied 6069 nodes for: {"", "pants-TODOS.md~"}
15:21:29.62 [INFO] notify invalidation: cleared 0 and dirtied 0 nodes for: {"pants-TODOS.md~", ""}
15:21:29.62 [INFO] notify invalidation: cleared 0 and dirtied 0 nodes for: {"pants-TODOS.md~", ""}
15:21:29.62 [INFO] notify invalidation: cleared 0 and dirtied 0 nodes for: {"pants-TODOS.md~", ""}
15:21:29.62 [INFO] notify invalidation: cleared 0 and dirtied 0 nodes for: {"pants-TODOS.md~"}
15:21:31.21 [INFO] request completed: `--pants-bin-name=/Users/vader/dev/sntls/osiris/pants --pants-version=2.13.0 test src/core/::`
w

wide-midnight-78598

09/23/2022, 1:23 PM
I've seen
pants_ignore = [...]
type of configuration error in a few other places, it's a very common problem in some subsystems too
@strong-toothbrush-37759 Does that need to be a recursive glob?
***/*.md
?
Sorry
*./md*
s

strong-toothbrush-37759

09/23/2022, 1:24 PM
The markdown file is in the root-folder, according to the pants docs, it should align to .gitignore (which it does).
w

wide-midnight-78598

09/23/2022, 1:24 PM
I don't think the trailing tilde is picked up
s

strong-toothbrush-37759

09/23/2022, 1:25 PM
The trailing tilde is not in the filename.
w

wide-midnight-78598

09/23/2022, 1:25 PM
Looks like a temp file?
"pants-TODOS.md~"
s

strong-toothbrush-37759

09/23/2022, 1:26 PM
I’m saving it using Sublime Text, which I think does not generate temporary files for saving.
Oh shoot, it is a temporary file 🤦
w

wide-midnight-78598

09/23/2022, 1:28 PM
temp file or maybe a lock file 🙂
s

strong-toothbrush-37759

09/23/2022, 1:28 PM
Ok, using
pants_ignore.add
solves my issue, thanks everyone! 👏
👍 2
w

wide-midnight-78598

09/23/2022, 1:29 PM
Actually, this is an interesting case, because my global gitignore has:
Copy code
*~
.DS_Store
But those wouldn't be picked up it seems by a default
pants_ignore
or the
pants_ignore_use_gitignore
h

happy-kitchen-89482

09/23/2022, 2:09 PM
The gotcha of overriding defaults by accident is unfortunate, not sure how to best address it
b

bitter-ability-32190

09/23/2022, 2:09 PM
We can and probably should just nudge people in the right direction in the help string
You likely don't want to set this directly but use Pants' <https://www.pantsbuild.org/docs/options#addremove-semantics
|add/remove semantics> for list options. E.g.
pants_ignore.add = [...]
👍 1
w

wide-midnight-78598

09/23/2022, 2:42 PM
Would be nice when we can get help strings in IDEs in the toml
b

bitter-ability-32190

09/23/2022, 2:43 PM
I'll add that to my TODO of the Pants config LSP
w

wide-midnight-78598

09/23/2022, 2:44 PM
I think VSCode is working towards adding toml - similar to json
s

strong-toothbrush-37759

09/23/2022, 2:55 PM
TypeScript is using JSON files for this purpose. Most Editors implement a function where you can just add a “$schema” field and a link, you get all possible options. Example `tsconfig.json`:
Copy code
{
  "$schema": "<https://json.schemastore.org/tsconfig>",
  "compilerOptions": {
    "esModuleInterop": true,
    "jsx": "react-jsx"
  },
  "exclude": [
    "node_modules"
  ]
}
You get autocomplete for free in most of the editors. Does something similar exist for toml? 🤔
b

bitter-ability-32190

09/23/2022, 2:56 PM
That's what I linked above. A Rust implementation of a TOML toolkit with schema support and an LSP, and a VS Code extension using said toolkit's LSP.
s

strong-toothbrush-37759

09/23/2022, 2:57 PM
Nothing I can support as a PyCharm / Sublime / TextMate user 😄 😛
b

bitter-ability-32190

09/23/2022, 2:58 PM
See if there's an extension using that Rust toolkit's LSP. LSP is editor-agnostic
🙌 1
5 Views