Skip to main content
Question

Transformer to purge temporary files

  • February 13, 2015
  • 4 replies
  • 194 views

Forum|alt.badge.img+1
Hi,

 

 

I am using a WorkspaceRunner to run another workspace a number of times.  Because the workspace I'm calling uses up a lot of memory, I was wondering if there is a transformer that I can add to the called workspace, so that at the end of each run, the temporary files are purged automatically?

 

 

Thanks,

4 replies

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • February 13, 2015
Hi,

 

 

I don't think there is such a transformer.

 

FME itself has a functionality to delete automatically temp files after completion of a translation. And I don't think that the size of temp files affects so much to performance of the translation, unless overflowing disk size.

 

So I don't worry about that.

 

 

This article may be helpful.

 

Why did the temporary files not get deleted from my translation? (http://fmepedia.safe.com/articles/FAQ/Why-did-the-temporary-files-not-get-deleted-from-my-translation)

 

 

Takashi

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • February 13, 2015
there is a manual purg button on the menu of Workbench.

 

Tools->purge. But there is no automated option afaik.

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • February 14, 2015
This is a shutdown script example to try removing all the temporary files and folders in the FME_TEMP folder.

 

I cannot guarantee that it always works safely.

 

-----

 

# Shutdown Python Script Example

 

import os

 

 

# Try removing a file/directory specified by the path.

 

# If the path indicates a directory, it removes recursively

 

# all subdirectories and files under the directory.

 

def rmfile(path):

 

    if os.path.isfile(path):

 

        try:

 

            os.remove(path)

 

        except:

 

            pass

 

    else:

 

        map(rmfile, ['%s/%s' % (path, f) for f in os.listdir(path)])

 

        try:

 

            os.rmdir(path)

 

        except:

 

            pass

 

 

# Get FME_TEMP directory path from environment variable.

 

# If it exists, try removing all temporary files and folders.

 

tmp = os.environ.get('FME_TEMP')

 

if tmp != None:

 

    map(rmfile, ['%s/%s' % (tmp, f) for f  in os.listdir(tmp)])

 

-----

 

 

Tcl too can do that concisely.

 

-----

 

# Shutdown Tcl Script Example

 

proc rmfile {path} {

 

    if {[file isdirectory $path]} {

 

        foreach f [glob -directory $path -type {f d} *] {rmfile $f}

 

    }

 

    catch {file delete $path}

 

}

 

 

if {![catch {set tmp $env(FME_TEMP)}]} {

 

    foreach f [glob -directory $tmp -type {f d} *] {rmfile $f}

 

}

 

-----

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • February 14, 2015
The shutdown script certainly removes every unlocked file in the Temp folder, including temporary source files for Views of Data Inspector. So the Views showing translation results may become invalid immediately after running the script.

 

That's a side-effect. If you cannot accept it, the script should not be used.

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings