question

Sean Webster avatar image
0 Likes"
Sean Webster asked Sean Webster commented

Does the experimenter work with python scripts?

I'm working on a model that uses a lot of external python to communicate with a database and make decisions about routing. I wanted to use the experimenter to do simultaneous testing of the model using different datasets which are held in different databases on the same server. I created an integer parameter [1,3] which changes which of the 3 databases the model uses.


This works fine when running the model normally - when I change the parameter everything works as expected with that database. However, when I use the experimenter with 3 scenarios, one for each of the options for the parameter, all of the user commands that call python functions are giving exceptions.


I know python integration is new so maybe it is not supported with the experimenter yet? If it is, was anyone able to do it successfully and is there anything you can think of which would cause the problem I'm having?

FlexSim 22.1.1
experimenterpython
· 4
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Phil BoBo avatar image
1 Like"
Phil BoBo answered Sean Webster commented

@Sean Webster

The issue is in how FlexSim finds the path to the Python DLL. External code paths are stored in VIEW:/environment/ExternalCode, which is where Global Preferences are stored.

The experimenter doesn't have access to that node because it doesn't include the VIEW tree, so it can't find the DLL path.

If you copy the VIEW:/environment/ExternalCode to MODEL:/Tools/ExternalCode, then it will work properly.

We'll fix it on our end so that it works without this workaround, but you can use this workaround to get it working right now in the current version.

· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Jordan Johnson avatar image
0 Likes"
Jordan Johnson answered

I think this is a bug. I made an extremely simple case, attempting to connect to Python in the Experimenter, and it didn't work. I don't think it's related to your databases.

@Joerg Vogel may have a point about simultaneous access, but it depends on the kind of database you are using. If it's a server-side database, then having multiple readers/writers won't be a problem.; most of the big ones (MySQL, Postgres, etc.) are designed for that use case. If it's SQLite, then you may run into a problem where writers block readers.

5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.