question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve the the blib2to3 grammar caching mechanism

See original GitHub issue

I get an error upon launching Jupyter Lab with the jupyterlab_code_formatter extension enabled:

[I 10:37:25.686 LabApp] Node v10.8.0

[I 10:37:26.075 LabApp] Build is up to date
Generating grammar tables from C:\Users\%USERNAME%\Anaconda3\lib\site-packages\blib2to3\Grammar.txt
Writing grammar tables to C:\Users\%USERNAME%\AppData\Local\black\black\Cache\18.9b0\Grammar3.7.1.final.0.pickle
Writing failed: [Errno 2] No such file or directory: 'C:\\Users\\%USERNAME%\\AppData\\Local\\black\\black\\Cache\\18.9b0\\Grammar3.7.1.final.0.pickle'
Generating grammar tables from C:\Users\%USERNAME%\Anaconda3\lib\site-packages\blib2to3\PatternGrammar.txt
Writing grammar tables to C:\Users\%USERNAME%\AppData\Local\black\black\Cache\18.9b0\PatternGrammar3.7.1.final.0.pickle
Writing failed: [Errno 2] No such file or directory: 'C:\\Users\\%USERNAME%\\AppData\\Local\\black\\black\\Cache\\18.9b0\\PatternGrammar3.7.1.final.0.pickle'

After manually creating the folder C:\\Users\\%USERNAME%\\AppData\\Local\\black\\black\\Cache\\18.9b0 and relaunching Jupyter lab the error disappears (even though the folder seems to stay empty).

The error appears to originate from this line. It might be related to #192. I think this line fails because the cache directory does not exist, but I don’t understand why it doesn’t exist.

Other users confirmed this happens on linux and with version 19.10b as well in this issue.

I tried to find the cause of this issue in the extension, but it doesn’t seem to do anything out of the ordinary with the cache folder, so I was hoping someone here can tell me why the cache folder would not exist?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:11
  • Comments:13

github_iconTop GitHub Comments

4reactions
VasuBhogcommented, Nov 19, 2020

I am still seeing this error with papermill 2.2.2 black 20.8b1 Mac OS: 10.15.7

Is there any update or workaround for this error? Upon papermill execution: Generating grammar tables from /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/blib2to3/Grammar.txt Writing grammar tables to /Users/xxx/Library/Caches/black/20.8b1/Grammar3.6.8.final.0.pickle Writing failed: [Errno 2] No such file or directory: '/Users/xxx/Library/Caches/black/20.8b1/tmpp31361aj' Generating grammar tables from /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/blib2to3/PatternGrammar.txt Writing grammar tables to /Users/xxx/Library/Caches/black/20.8b1/PatternGrammar3.6.8.final.0.pickle Writing failed: [Errno 2] No such file or directory: '/Users/xxx/Library/Caches/black/20.8b1/tmpcq8qn401'

3reactions
darachmcommented, Sep 22, 2021

I get this error trying to run papermill (which apparently imports black, hello) inside of a Singularity container.

  • https://github.com/psf/black/issues/1143#issuecomment-730814683 does not work, likely because the container is built as root and then run as a user
  • similarly, mkdir won’t work because the container is supposed to be able to be run by different users - hence different user-specific caches
  • similarly, this is being used inside of Nextflow for some pipeline management, so no I do not want it to be interacting or dependent on states in home cache directories across different machines, so I’m not binding those into the container

Before I go and remove black/papermill from my workflow, is there a way to move the CACHE_DIR to a predictable location? Can I set this with an environmental variable? Can the cache go into /tmp or something? Or can I disable it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

No problem with Black per se - it's my default linter
No problem with Black per se - it's my default linter - but latest inclusion with IPython 8.0 seems to break in a...
Read more >
Controlling grammar caches - Nuance Speech Suite
The voice browser can control grammar caches via the following means: ... higher value keeps more grammars instantly accessible, and improves loading times....
Read more >
Caching Overview | Caching to improve performance - Drupal
In order to maximize performance of Drupal, we need to understand Drupal's execution and caching model.
Read more >
User-Guide - Logging — ploomber 0.21.8dev documentation
... INFO:blib2to3.pgen2.driver:Generating grammar tables from ... [Errno 2] No such file or directory: '/home/codespace/.cache/black/22.3.0/tmp1j9p6bb9' ...
Read more >
Oracle TimesTen Application-Tier Database Cache
product option ideal for caching performance-critical subsets of an Oracle. Database in the application tier for improved response time. Applications.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found