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

Can you expose the option of specifying a cache folder #15

Closed
JBKahn opened this issue Feb 13, 2018 · 7 comments
Closed

Can you expose the option of specifying a cache folder #15

JBKahn opened this issue Feb 13, 2018 · 7 comments

Comments

@JBKahn
Copy link

JBKahn commented Feb 13, 2018

Using a temp directory based on the filepath is much slower than allowing me to specify a path, especially if I use it on the CLI as well and then I can share a cache folder with other apps.

@conanfanli
Copy link

I can confirm that the plugin is not taking advantage of cache-dir.

@elarivie
Copy link
Owner

Hello @JBKahn and @conanfanli,

The current linter-mypy implementation handles cache-dir like that:

A unique cache-dir is currently being created in the OS temp folder for each file being linted (opened in a text editor) (it uses the md5 of the file path as a unique signature).
This way, any future lint call for a given file will use its cache data from previous call.

This strategy is maybe not fully optimal but:

  • it works fine when multiple project folder are open by atom
  • it correctly handle when a single file is opened by atom.
  • there is no risk of mixing up cache with unrelated stuff.

@JBKahn

Effectively with this strategy, the cache-dir folder is not shareable with other external tools.

I am curious to know what is your use case precisely.

How do you share cache dir?
- Do you use the defaults .mypy_cache being created by Mypy in every folder of your source?
- Do you use the same cache directory for all your projects on your computer (even if they are unrelated)?
- Do you use a single cache directory somewhere within your project tree?

Note: I am not a fan of tools polluting source code with temp/cache data so
that's why I implemented this strategy which benefits from cache data while
not creating cache data in the source of the project.


@conanfanli

What exactly do you confirm? how did you come to that conclusion (one minute after the bug was created)?
- Did you check the mypy arguments being sent?
- Did you check the cache-dir content?
- Which OS, which Atom/Mypy/Python/linter-mypy version do you use?
- ...?

What exactly makes you conclude that "it is not taking advantage of cache-dir."? Which missing behavior would make it takes advantage of cache-dir?

@JBKahn
Copy link
Author

JBKahn commented Feb 14, 2018

@elarivie

The problem with this strategy is that large projects with large numbers of files and imports don't share cache across the project. So each time I open a new file, it takes minutes to finish running. In an ideal world, and the way I try to use it is to have a mypy_cache at the root of the folder for each project. Even if you didn't make it configurable, the default (making the md5 part optional) would cache this in a way that the rest of the files could make use of.

@elarivie
Copy link
Owner

@JBKahn
I added the possibility to specify the cache folder to use.
It now supports the following four options:

1- No cache data (by setting the path to "/dev/null")
2- Cache data in a unique temp folder for each file (by setting the path to empty string) 🡐 By Default
3- Using a specific folder (may use $PROJECT_PATH and $PROJECT_NAME to define the path)

  • Note: If when linting the folder does not exists, it silently fallbacks to # 2

4- Mypy default behavior, by using/creating a folder named .mypy_cache in the same folder as the file being linted (by setting the path to a dot ".")

@JBKahn, Could you test to see if using the code present in the commit 3519521 works well for your setup.

If everything is good, I'll soon push a new release.

@JBKahn
Copy link
Author

JBKahn commented Feb 17, 2018

Works great for me

@elarivie
Copy link
Owner

@JBKahn, @conanfanli

This is now available in linter-mypy v2.6.0

@JBKahn
Copy link
Author

JBKahn commented Feb 18, 2018

Thanks @elarivie

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants