I’m experiencing an indefinite `Filesystem changed...
# general
s
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
Does your
python_test
target include anything other than
.py
files?
s
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
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
Like a test that is writing to a watched directory?
w
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
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
Is
p
an alias? Or a wrapper?
s
Ah, yeah sorry it’s an alias:
alias p "./pants"
😄
w
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
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
🤯
Which version of pants?
s
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
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
I’m gonna reboot and try with a fresh env
w
When in doubt, reboot 🙂 Good luck! And maybe someone more knowledgeable can help when they come online
s
No luck unfortunately with the reboot 😄
b
.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
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
So pants is watching your .git directory. Have you twiddled with the settings for ignores?
s
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
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
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
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
Thanks again, I have indeed changed the
pants_ignore
variable.
b
It should be excluding all dot files and dirs by defaukt
You can do
pants_ignore.add = ...
w
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
Pants doesn’t watch .git by default, it should only be watching your own source files for changes.
s
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
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
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
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
The markdown file is in the root-folder, according to the pants docs, it should align to .gitignore (which it does).
w
I don't think the trailing tilde is picked up
s
The trailing tilde is not in the filename.
w
Looks like a temp file?
"pants-TODOS.md~"
s
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
temp file or maybe a lock file 🙂
s
Ok, using
pants_ignore.add
solves my issue, thanks everyone! 👏
👍 2
w
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
The gotcha of overriding defaults by accident is unfortunate, not sure how to best address it
b
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
Would be nice when we can get help strings in IDEs in the toml
b
I'll add that to my TODO of the Pants config LSP
w
I think VSCode is working towards adding toml - similar to json
s
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
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
Nothing I can support as a PyCharm / Sublime / TextMate user 😄 😛
b
See if there's an extension using that Rust toolkit's LSP. LSP is editor-agnostic
🙌 1