I was wondering could any of the python experts help me. I'm trying to write a python shut down script that calls FME Server and passes some parameter values into a workspace to run on Server.
I can successfully do the same on Desktop- run a workspace collect information in the shutdown script about featuresRead, featureswritten, timings and so on and kick off a new workspace using these values which records and reports on this.
So I was testing could I complete the same task on Server -- I am able to run the workspace on server as part of the shut down script but right now I am just populating all the parameter values with "Test".
What is the correct syntax to replace "test" with the variables I have created regarding information about the translation-- eg fme.totalFeaturesRead etc. I have managed to do this through desktop but I just can't get the correct information to log when I test on Server, any advice would be appreciated as I am trying to learn python myself (slowly)
Thanks
Best answer by ciarab
Meant to post as this was the solution I ended up with- might not be the easiest way to go about logging shutdown information it but if anyone is ever looking to call FMEServer and pass in some parameters from python shutdown this is the code I used. It works and I learnt something along the way
Why not simply use the FMEServerJobSubmitter transformer?
If you need it to run after all the writers have terminated, consider replacing the writers with FeatureWriters send all the summaries to an Aggregator (to reduce to one single feature), then the FMEServerJobSubmitter.
If you really do need to use Python, consider using the REST API rather than the jobsubmitter, it's easier (I think). I also recommend using the excellent requests module.
Why not simply use the FMEServerJobSubmitter transformer?
If you need it to run after all the writers have terminated, consider replacing the writers with FeatureWriters send all the summaries to an Aggregator (to reduce to one single feature), then the FMEServerJobSubmitter.
If you really do need to use Python, consider using the REST API rather than the jobsubmitter, it's easier (I think). I also recommend using the excellent requests module.
If it's the feature counts, you'll get them from the FeatureWriters.
Its just I'm trying to learn python and I have been tasked with doing this using python so I'm giving it a go despite my limited python skills..I'm learning anyway so I guess its not a bad task.
I just thought because I managed to do the same on desktop (fairly) easily I must be missing something simple on Server.
This was the info I was pulling out in Desktop
status = fme.status
errorMsg = fme.failureMessage
logFile = fme.logFileName
Read= fme.totalFeaturesRead
Written= fme.totalFeaturesWritten
licence= fme.licensing
Time=fme.cpuSysTime
memory=fme.memoryUsage
maxmemory=fme.peakMemoryUsage
FeaturesLogged=fme.numFeaturesLogged
Location=FME_MacroValues['FME_MF_DIR']
Workspace=FME_MacroValues['FME_MF_NAME']
Build=FME_MacroValues['FME_BUILD_NUM']
I'll take a look at your suggestion and see if I can get any further
Actually, I've been toying with an idea of making an open-source Python library for interacting with FME Server. The idea was to have an interface where you could write code like
Its just I'm trying to learn python and I have been tasked with doing this using python so I'm giving it a go despite my limited python skills..I'm learning anyway so I guess its not a bad task.
I just thought because I managed to do the same on desktop (fairly) easily I must be missing something simple on Server.
This was the info I was pulling out in Desktop
status = fme.status
errorMsg = fme.failureMessage
logFile = fme.logFileName
Read= fme.totalFeaturesRead
Written= fme.totalFeaturesWritten
licence= fme.licensing
Time=fme.cpuSysTime
memory=fme.memoryUsage
maxmemory=fme.peakMemoryUsage
FeaturesLogged=fme.numFeaturesLogged
Location=FME_MacroValues['FME_MF_DIR']
Workspace=FME_MacroValues['FME_MF_NAME']
Build=FME_MacroValues['FME_BUILD_NUM']
I'll take a look at your suggestion and see if I can get any further
Just to turn the thing the thing upside-down: I'm guessing that you're calling a workspace to log the results from the first workspace?
If so, why not log it directly from the first workspace, would that be possible?
Just to turn the thing the thing upside-down: I'm guessing that you're calling a workspace to log the results from the first workspace?
If so, why not log it directly from the first workspace, would that be possible?
Ha it would, but that would involve getting others involved as I have no admin rights I can't install ANYTHING without permission. So I don't have access to the correct packages to write to a database or excel or whatever. Might take a little while to get that sorted.
I thought it would be easier/quicker to just do it like this but doesnt look like the case
Why not simply use the FMEServerJobSubmitter transformer?
If you need it to run after all the writers have terminated, consider replacing the writers with FeatureWriters send all the summaries to an Aggregator (to reduce to one single feature), then the FMEServerJobSubmitter.
If you really do need to use Python, consider using the REST API rather than the jobsubmitter, it's easier (I think). I also recommend using the excellent requests module.
Meant to post as this was the solution I ended up with- might not be the easiest way to go about logging shutdown information it but if anyone is ever looking to call FMEServer and pass in some parameters from python shutdown this is the code I used. It works and I learnt something along the way
We use 3 different kinds of cookies. You can choose which cookies you want to accept. We need basic cookies to make this site work, therefore these are the minimum you can select. Learn more about our cookies.