Comments (4)
My 2c
import tempfile
import shutil
import os
# In __init__
self.graphdir = tempfile.mkdtemp()
# In get_graph
gr = os.path.join(self.graphdir, name + '.svg')
cmd = 'graph export `"{0}"\' , name({1}) as(svg) replace'
self.do(cmd.format(gr, name))
with open(gr) as f:
img = f.read()
# In do_shutdown
shutil.rmtree(self.graphdir)
So even if the kernel fails for some reason, you won't litter the user's folders with temp folders. It would go into the system temp directory.
from stata_kernel.
Yes I agree, but I was thinking of the dua model, and I'm not sure it would be ok to arbitrarily save images in tmp (likewise with the cross-console history file, not sure that can go in ~ by default. Maybe I could put this setting in the configuration.
from stata_kernel.
The "tmp" folder created via tempfile
is only readable and writeable by the user that makes it, AFAIK. I did ask about this when I started work because the DUA model says all the things must be in the user's DUA folder. However, SAS and Stata create temporary files in the system's temporary directory all the time. I was told that was OK.
Nevertheless, an option to specify the images cache directory would certainly be nice.
from stata_kernel.
I'm not sure it's necessary to delete the cache directory anymore, as long as it's always in the same place and now possible to be user defined.
from stata_kernel.
Related Issues (20)
- Graphs do not show with stata 17 HOT 5
- Graphs not displaying on JupyterLab with Stata 17 HOT 1
- Ubuntu run pytest get "stata_path option in configuration file is missing or invalid"
- Kernel does not recover after stata process is killed
- Atom and stata_kernel togther with Hydrogen -- not executing HOT 4
- Is stata kernel able to install in Mac OS? HOT 1
- Issues with stata_kernel in Atom (Hydrogen) HOT 3
- Graph display bug after setting user _graph_keywords? HOT 34
- Update kernel's python dependencies HOT 1
- Kernel does not execute then `*` is used within multi-line `syntax` statement
- Use importlib.resources instead of pkg_resources
- Repo modernization HOT 1
- How to make jupyter automatically close the stata session HOT 1
- %help magic does not work for Stata commands HOT 2
- The word "format" appears below stata plot output
- Graphs no longer display in Jupyter notebook HOT 9
- Kernel freezes whenever I try to run some code HOT 2
- can't run arch model. HOT 2
- How can i make the results more beautiful. HOT 2
- can we insert a graph on the local path using markdown?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stata_kernel.