Solved

How to run same workspace multiple times with different parameters

  • 20 June 2016
  • 9 replies
  • 30 views

Badge

I would like to run the same workspace multiple times but with a different source geodabase each time. Basically, I want to run it once for each geodatabase in a given folder. I believe this could be scripted with Python, but am not entirely sure where to start.

Any suggestions or script samples is appreciated.

icon

Best answer by blueinc 20 June 2016, 20:24

View original

9 replies

Badge +2

Is there any reason for you to search in Python instead of using Workspace Runner in FME?

Userlevel 5

You can use the reader "Directory and File Pathnames" to look for folders ending with .gdb, then send those to the WorkspaceRunner with a workspace that treats each one individually:

Badge +5

You can use the reader "Directory and File Pathnames" to look for folders ending with .gdb, then send those to the WorkspaceRunner with a workspace that treats each one individually:

Yes, check out this example to see exactly how it is done.

Badge

Is there any reason for you to search in Python instead of using Workspace Runner in FME?

No reason other than I am a newby at this and thought Python was required.

So is the idea to use Workspace Runner to grab the filenames in the directory, and then for each filename, pass it into the workspace parameters and execute?

Userlevel 5

No reason other than I am a newby at this and thought Python was required.

So is the idea to use Workspace Runner to grab the filenames in the directory, and then for each filename, pass it into the workspace parameters and execute?

Yes, you use the Directory and File Pathnames reader to grab the filenames, then for each filename (i.e. each feature that exits the reader), you fire off another workspace with the WorkspaceRunner, passing the gdb filename as a published parameter.

Badge

Ok, thanks. Have the directory/file pathnames reader working. I have the generic workspace set up as well with the published parameter. What is confusing is that I am not sure how to loop through the filenames from the reader.

Badge +5

So you should have two FMWs at this point: one that does all your translations (let's call it Processor.fmw) and another fmw that uses the directory/file pathnames reader to feed the *.gdb names to the processor.fmw using a WorkspaceRunner Transformer. When you hook the Reader to the WSR and examine the parameters on the WSR, you will see the public parameter you set up on the processor.fmw. Using the dropdown arrow, you can set the parameter to one of the Reader's outputs like path_windows.

Badge

So you should have two FMWs at this point: one that does all your translations (let's call it Processor.fmw) and another fmw that uses the directory/file pathnames reader to feed the *.gdb names to the processor.fmw using a WorkspaceRunner Transformer. When you hook the Reader to the WSR and examine the parameters on the WSR, you will see the public parameter you set up on the processor.fmw. Using the dropdown arrow, you can set the parameter to one of the Reader's outputs like path_windows.

Worked perfectly. Thank you.

Badge +5

Worked perfectly. Thank you.

Awesome. Glad to help. (Though, in truth, all I did was diagram david_r's response :-))

Reply