Skip to main content
Question

Parent Directory and subfolders


Forum|alt.badge.img

Hi,

I have a set of workspaces inside many directories and a workspace which call all the workspaces one by one using a workspaceRunner.

Here is the picture of my hierarchical structure

In this structure you have a directory called " Livraison - Transformation globale AIXM 51". Inside this one, you have the "master" workspace which call all the workspaces one by one in the various directories you can see on the picture.

Here is the picture of the "master" workspace

The issue i have : when i changed the master directory called "Livraison AIXM 51 V2.0" in another directory, i lost the path of the workspacerunner parameter (show the picture). I would like to use "FME_MF_DIR" and i want to go in the parent directory and go inside the subfolder to reach the various workbenchs, but the absolute paths are used in my case.

Is there a way to use python scripts to :

- Bring in an attribute the value of the "Livraison AIXM 51 V2.0" path

- The main workbench is in "Livraison - Transformation globale AIXM 51". So, FME_MF_DIR contains by default the absolute path of this directory.

- Bring in an attribute the parent directory of FME_MF_DIR

- In each workspacerunner bring the attribute of the subfolders in which the different workbenchs are called

Thanks in advance

7 replies

takashi
Influencer
  • July 17, 2018

Hi @philippe33, you can get the parent directory path with the FilenamePartExtractor with this setting.

0684Q00000ArKFmQAN.png

Or, if you prefer to use scripted Python parameter,  try this one.

import os
return os.path.split(os.path.abspath('.'))[0]

takashi
Influencer
  • July 17, 2018
takashi wrote:

Hi @philippe33, you can get the parent directory path with the FilenamePartExtractor with this setting.

0684Q00000ArKFmQAN.png

Or, if you prefer to use scripted Python parameter,  try this one.

import os
return os.path.split(os.path.abspath('.'))[0]
This script is also possible.

 

import os
return os.path.abspath('..')

 


Forum|alt.badge.img
  • Author
  • July 18, 2018
takashi wrote:

Hi @philippe33, you can get the parent directory path with the FilenamePartExtractor with this setting.

0684Q00000ArKFmQAN.png

Or, if you prefer to use scripted Python parameter,  try this one.

import os
return os.path.split(os.path.abspath('.'))[0]
Thank you takashi,

 

 

How can i put this result in the workspacerunner transformer in such a way i could retrieve the path of the workspaces i call one by one without having to write them (in the case the absolute path may change) ?

 

 

 


takashi
Influencer
  • July 18, 2018
takashi wrote:

Hi @philippe33, you can get the parent directory path with the FilenamePartExtractor with this setting.

0684Q00000ArKFmQAN.png

Or, if you prefer to use scripted Python parameter,  try this one.

import os
return os.path.split(os.path.abspath('.'))[0]
I thought that you could construct workspace file path within the parameter field using the feature attribute or the scripted parameter, but it wouldn't retrieve published parameters from the child workspace...

 

Another thought. Probably you can directly set the relative path indicating the child workspace to the FME Workspace parameter field, as in:

 

..\04 - Transformation Runway 51\010_Test_Gestion_UUID_Runway_gml_id.fmw

 


Forum|alt.badge.img
  • Author
  • July 18, 2018
takashi wrote:
I thought that you could construct workspace file path within the parameter field using the feature attribute or the scripted parameter, but it wouldn't retrieve published parameters from the child workspace...

 

Another thought. Probably you can directly set the relative path indicating the child workspace to the FME Workspace parameter field, as in:

 

..\04 - Transformation Runway 51\010_Test_Gestion_UUID_Runway_gml_id.fmw

 

No, it doesn't want to let me do that in this parameter. I try to put an attribute with the creation of a published parameter with the option (script Python). it doesn't succeed. It seems only to accept an absolute path written inside but if i change the path i have to pass inside this workbench and set again the correct path.

 

 


takashi
Influencer
  • July 18, 2018
takashi wrote:
I thought that you could construct workspace file path within the parameter field using the feature attribute or the scripted parameter, but it wouldn't retrieve published parameters from the child workspace...

 

Another thought. Probably you can directly set the relative path indicating the child workspace to the FME Workspace parameter field, as in:

 

..\04 - Transformation Runway 51\010_Test_Gestion_UUID_Runway_gml_id.fmw

 

Didn't the parameter field accept any relative path (..\<folder name>\<workspace name>.fmw)?

 

 


Forum|alt.badge.img
  • Author
  • July 18, 2018

Hi,

I find a workaround to solve my problem, but i don't think it's the good one.

Please see this solution here :

https://knowledge.safe.com/questions/5254/set-workspacerunner-parameters-programmatically.html

How i do the job :

1 - In my main workspace i created a published parameter like this:

img3.png

 

The parameter "toto" take the value of the absolute path of the workbench i called in my first workspacerunner

2 - I follow the webpage i gave above

3 - that gives me this following:

img4.png

 

When i change the place of the directory "Livraison AIXM 51 V2.0" which is the main directory with all the subdirectories inside, the workbenchs are called with the respect of the new path without having to change the initial workbench.

But i don't think it's the easiest way, but i follow the sample i saw (link above)


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