Git Product home page Git Product logo

Comments (4)

mcaceresb avatar mcaceresb commented on May 30, 2024

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.

kylebarron avatar kylebarron commented on May 30, 2024

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.

mcaceresb avatar mcaceresb commented on May 30, 2024

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.

kylebarron avatar kylebarron commented on May 30, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.