Question

FME Objects: Unique id of current FME Session ?


Userlevel 1
Badge +22

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

Userlevel 2
Badge +17

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.

Userlevel 4

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.

Userlevel 1
Badge +22

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
Userlevel 1
Badge +22

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
Userlevel 4

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

Userlevel 2
Badge +17

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.

Userlevel 1
Badge +22

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

Reply