Priyank Dwivedi Posted May 18, 2023 Share Posted May 18, 2023 How can the user be absolutely sure that the 'data tables' will refresh after running a data function via an IronPython script? I noticed that even though the data function works as intended (saves some data to the tables in the SQL server), the refresh process in Spotfire is a hit or miss. Sometimes the data shows up and sometimes it doesn't. Any advice on this?My simple IronPython script:from Spotfire.Dxp.Data.DataFunctions import DataFunctionExecutorService, DataFunctionInvocation, DataFunctionInvocationBuilderfrom System.Threading import Thread for fnc in Document.Data.DataFunctions: if fnc.Name == 'Overlays.Insert': #fnc.Execute() fnc.ExecuteSynchronously() print('Success') # Reload all data in a specific table Document.Data.Tables["Overlays"].ReloadAllData() #ReloadLinkedData() Document.Data.Tables["Forecast"].ReloadAllData() #ReloadLinkedData() Link to comment Share on other sites More sharing options...
Andrew Berridge Posted May 19, 2023 Share Posted May 19, 2023 Hi there!Does the function return the data to Spotfire, or are the ReloadAllData() responsible for doing this? It looks like the ReloadAllData() operations return the data.I suspect it's not a problem with Spotfire, but rather an async database issue. I would imagine that the commit may not yet have completed after INSERT and since you reload the data immediately, you may not get the committed rows, as they are not yet committed!You could try adding a delay to allow the database to catch up.You can also confirm if this is the issue by creating a separate script with just the ReloadAllData() operations. Then run each script sequentially manually. If you get the data you expect, then that will confirm the issue.Andrew (TIBCO Spotfire Data Science) Link to comment Share on other sites More sharing options...
Priyank Dwivedi Posted May 22, 2023 Author Share Posted May 22, 2023 Hi Andrew,Thanks for the note.Can you share an example of 'adding a delay'? That could work in my case. Link to comment Share on other sites More sharing options...
Andrew Berridge Posted May 23, 2023 Share Posted May 23, 2023 import timetime.sleep(1)From: https://ironpython.net/documentation/dotnet/dotnet.htmlHopefully that will work! It will sleep for 1 second. Note that you can use core Python functions in IronPython. time is part of the Python/IronPython core. For future reference, you can't import or install additional Python packages into the IronPython engine in Spotfire. Andrew Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now