Skip to main content
Question

FME Objects: Unique id of current FME Session ?


lifalin2016
Contributor
Forum|alt.badge.img+29

Hi,

I want to build a small (Python based) transformer, that utilizes a small SQLite db for syncronization purposes. This functionality I think I have covered.

However, I want it to use resources inherently local to the current session, so multiple workspaces can utilize this same transformer without colliding. I thought that the current session might have a function to return a unique ID (e.g. as a GUID), that I could use to prefix tables in SQLite, but I can't find it in the documentation.

It's probably a no brainer, but I'm still figuring out how to handle FME Objects properly.

Ps! Is the "current" session started automatically by FME running the workspace, or must I initiate it myself in my "init" routine ?

Cheers

 

Lars

7 replies

takashi
Influencer
  • June 17, 2016

Hi @lifalin2016, I don't know whether the session id can be retrieved through the Python FME Object API, but if UUID satisfies your requirement, that can be generated using Python 'uuid' module or FME UUIDGenerator transformer.


david_r
Celebrity
  • June 17, 2016

In addition you might want to consider using the process ID (PID): https://msdn.microsoft.com/en-us/library/windows/hardware/ff545415%28v=vs.85%29.aspx?f=255&MSPPError;=-2147217396

This concept is also valid under Unix/Linux and OS/X.


lifalin2016
Contributor
Forum|alt.badge.img+29
  • Author
  • Contributor
  • June 17, 2016

Hi Takashi,

Yes, if it was just a unique id I was looking for, this would work.

But I'm looking for the same unique id across multiple transformers in the same workspace. Each transformer should be able to retrieve this id by itself. That's why I hoped that something like a session id was the answer and available.

If such an id is not available thru the API, do you know if there are any other id's available in the API, with properties like what I'm looking for ?

Cheers

 

Lars

lifalin2016
Contributor
Forum|alt.badge.img+29
  • Author
  • Contributor
  • June 17, 2016

Hi David_R,

That depends on whether FME spawns individual transformers into seperate thread, i.e. processes?

I suspects that FME does just that, which will leave the process id to be unuseful for me (see answer to Takashi about what I'm looking for).

Cheers

 

Lars

david_r
Celebrity
  • June 17, 2016
lifalin2016 wrote:

Hi David_R,

That depends on whether FME spawns individual transformers into seperate thread, i.e. processes?

I suspects that FME does just that, which will leave the process id to be unuseful for me (see answer to Takashi about what I'm looking for).

Cheers

 

Lars

It all depends how FME does it. Although I suspect that FME does not run the transformers in separate threads.

You should try and analyze this using the ProcessExplorer while FME is running, it will show you all the parent and child processes, with their PID: https://technet.microsoft.com/en-us/sysinternals/processexplorer.aspx?f=255&MSPPError;=-2147217396


takashi
Influencer
  • June 17, 2016
lifalin2016 wrote:

Hi Takashi,

Yes, if it was just a unique id I was looking for, this would work.

But I'm looking for the same unique id across multiple transformers in the same workspace. Each transformer should be able to retrieve this id by itself. That's why I hoped that something like a session id was the answer and available.

If such an id is not available thru the API, do you know if there are any other id's available in the API, with properties like what I'm looking for ?

Cheers

 

Lars

How about this approach?

  • Main canvas: define a scripted Python parameter which returns a UUID.
  • Transformer: define a published user parameter which accepts a UUID.

Then you can pass an identical UUID generated by the scripted parameter to all the transformers through the published parameter.


lifalin2016
Contributor
Forum|alt.badge.img+29
  • Author
  • Contributor
  • June 22, 2016

Hi David, all,

The process id is indeed the same for all transformers it seems :-)

I made a simple transformer, that only logged the process id (=os.getpid()), and added two transformers to my workspace. Both transformers logged the same process id when I ran the workspace.

Thanks for helping me out here guys.

Cheers

 

Lars

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