kristinbranson / APT

Animal Part Tracker
GNU General Public License v3.0
71 stars 16 forks source link

Change location of temp directory #377

Closed harshk95 closed 1 year ago

harshk95 commented 2 years ago

Hey, I had a little query. I have a working APT model on one PC and wish to transfer it to another PC to use. When I do this, a large temporary folder is made in a default location upon loading the project which then runs out of space resulting in the following error. The default folder has very limited space and I could not figure out how to change this.

Error using Labeler/projGetEnsureTempDir (line 2420) Could not create temp directory \drive\user.apt\tp2a4ceb35_9991_4b3b_ad2f_9675cd0cf8e7: There is not enough space on the disk.

Error in Labeler/projGetRawLblFile (line 2588) projtempdir = obj.projGetEnsureTempDir(varargin{:});

Error in Labeler/projUnbundleLoad (line 2450) [rawLblFile,tname] = obj.projGetRawLblFile('cleartmp',true); % throws; sets .projTempDir

Error in Labeler/projLoad (line 2105) [success,tlbl,wasbundled] = obj.projUnbundleLoad(fname);

Error in LabelerGUI>menu_file_load_Callback (line 2945) currMovInfo = lObj.projLoad();

Error in gui_mainfcn (line 95) feval(varargin{:});

Error in LabelerGUI (line 48) gui_mainfcn(gui_State, varargin{:});

Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)LabelerGUI('menu_file_load_Callback',hObject,eventdata,guidata(hObject)) Error while evaluating Menu Callback.

Any pointers on how I could change the default temp directory would be helpful. Sorry, if there is something really silly that I am missing.

kristinbranson commented 2 years ago

Not an obvious question -- this is something we didn't think of. I haven't tried this out yet to confirm it works, but there is a way to set the temporary directory using the manifest file. In your APT directory, there is a file called Manifest.sample.txt (https://github.com/kristinbranson/APT/blob/develop/Manifest.sample.txt) If you copy this file over to a file called Manifest.txt in the same directory, you can modify /path/to/dl/cachedir to be the path to a directory you would like to use. By default, it is using a directory .apt created within your home directory. I don't have a Windows machine right now to test things on, but can check that this code is working properly tonight. Here's the relevant code in APT.m, if it is helpful:

 function cacheDir = getdlcacheroot()

      m = APT.readManifest;
      if isfield(m,'dltemproot')
        cacheDir = m.dltemproot;
      else
        if ispc
          userDir = winqueryreg('HKEY_CURRENT_USER',...
            ['Software\Microsoft\Windows\CurrentVersion\' ...
            'Explorer\Shell Folders'],'Personal');
        else
          userDir = char(java.lang.System.getProperty('user.home'));
        end
        cacheDir = fullfile(userDir,'.apt');
      end
    end
allenleetc commented 1 year ago

I tested on Win and Linux and creating Manifest.txt with the desired cache location works for me. Closing but please feel free to re-open with updates.