Jump to content

Sequential and Simultaneous data table loading via single IronPython script


Mario Reyes

Recommended Posts

Hi,

I need help achieving the task described in the thread title. Let me provide some background:

I am developing a very large dashboard on spotfire that loads a lot of data for visualization. Some of those tables need to be loaded sequentially because of dependencies between them, but others can just be load simultaneously.

For the sequentially loaded tables, I use the following script:

 

import clr

from System.Collections.Generic import List, Dictionary

from Spotfire.Dxp.Data import DataTable

from Spotfire.Dxp.Framework.ApplicationModel import NotificationService

 

# Empty list to hold DataTables

Tbls = List[DataTable]()

 

Tbls.Add(dt1) #dt1 a DataTable string parameter

Tbls.Add(dt2) #dt2 a DataTable string parameter

 

# Notification service

notify = Application.GetService[NotificationService]();

 

# Execute something after tables are loaded

def afterLoad(exception, Document=Document, notify=notify):

if not exception:

Document.Properties["lastReload"]

print "OK"

else:

notify.AddErrorNotification("Error refreshing table(s)","Error details",str(exception))

 

# Refresh table(s)

Document.Data.Tables.RefreshAsync(Tbls, afterLoad)For tables with no dependancies, I used the following simple script:

 

from System.Collections.Generic import List, Dictionary

from Spotfire.Dxp.Data import DataTable

from System.Collections import ArrayList

 

dt3.Refresh()

dt4.Refresh()

dt5.Refresh()I tried simply combining the scripts into a single one but the result was that all tables loaded sequentially.

With the naming used in these scripts, I would like the script to execute as follows:

 

Load dt1

Wait for dt1 to be fully loaded

Load dt2

Wait for dt2 to be fullyloaded

Load dt3, dt4 and dt5 all at the same time.

 

Best regards, and thanks in advance

MR

Link to comment
Share on other sites

  • 2 weeks later...
  • 8 months later...

Bellow is the script and error message I am getting.  Have tried several similar scripts and all lockup Spotfire analyst right after retrieving the second data table.  Please advise I am sure the script is close to working:

 

URL: https://community.spotfire.com/questions/sequential-and-simultaneous-data-table-loading-single-ironpython-script

 

 

 

 

 

import clr

 

from System.Collections.Generic import List, Dictionary

 

from Spotfire.Dxp.Data import DataTable

 

from Spotfire.Dxp.Framework.ApplicationModel import NotificationService

 

 

 

# Empty list to hold DataTables

 

Tbls = List[DataTable]()

 

 

 

 

 

Tbls.Add(dt1) #dt1 a DataTable string parameter

 

Tbls.Add(dt2) #dt2 a DataTable string parameter

 

 

 

# Notification service

 

notify = Application.GetService[NotificationService]();

 

 

 

# Execute something after tables are loaded

 

def afterLoad(exception, Document=Document, notify=notify):

 

 if not exception:

 

  Document.Properties["lastReload"]

 

  print "OK"

 

 else:

 

  notify.AddErrorNotification("Error refreshing table(s)","Error details",str(exception))

 

 

 

# Refresh table(s)

 

Document.Data.Tables.RefreshAsync(Tbls, afterLoad)

 

 

 

 

 

Error Message:

 

TIBCO Spotfire Analyst 7.11.0 LTS HF-002 R158444

 

Build version: 7.11.0.0.73

 

Build date: 2/13/2018

 

 

 

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Collections.Generic.KeyNotFoundException: The property named 'lastReload' could not be found.

 

   at Spotfire.Dxp.Data.DataPropertyRegistry.GetProperty(DataPropertyClass propertyClass, String propertyName)

 

   at _stub_$24##24(Closure , CallSite , Object , String )

 

   at Microsoft.Scripting.Actions.MatchCaller.Call2[T0,T1,TRet](Func`4 target, CallSite site, Object[] args)

 

   at Microsoft.Scripting.Actions.CallSite`1.UpdateAndExecute(Object[] args)

 

   at Microsoft.Scripting.Actions.UpdateDelegates.Update2[T,T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)

 

   at afterLoad$5##5(Closure , Object , Object , Object )

 

   at Microsoft.Scripting.Actions.MatchCaller.Call2[T0,T1,TRet](Func`4 target, CallSite site, Object[] args)

 

   at Microsoft.Scripting.Actions.CallSite`1.UpdateAndExecute(Object[] args)

 

   at Microsoft.Scripting.Actions.UpdateDelegates.Update2[T,T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)

 

   at Spotfire.Dxp.Data.DataTable.<AfterRefresh>d__a5.MoveNext()

 

   at Spotfire.Dxp.Data.Producers.ExternalColumnProducer.<AsyncCallback>d__34.MoveNext()

 

   at Spotfire.Dxp.Data.DataFunctions.DataFunctionImpl.<>c__DisplayClassf.<Spotfire.Dxp.Data.Producers.IExternalColumnProducerUpdater.Execute>b__e()

 

   at Spotfire.Dxp.Framework.ApplicationModel.InvocationAttempt.Execute()

 

   --- End of inner exception stack trace ---

 

   at Spotfire.Dxp.Framework.ApplicationModel.InvocationAttempt.WaitUntilPerformed()

 

   at Spotfire.Dxp.Forms.Application.FormsProgressService.PerformInvocation(ApplicationInvocation applicationInvocation, Boolean shallBeSynchronous)

 

   at Spotfire.Dxp.Forms.Application.FormsApplicationThread.Invoke(ApplicationInvocation method)

 

   at Spotfire.Dxp.Framework.Threading.WorkItem.ReturnItem()

 

   at Spotfire.Dxp.Data.DataFunctions.DataFunctionImpl.ResultHandler_(DataFunctionWorkItem workItem)

 

   at Spotfire.Dxp.Framework.Threading.WorkItem.ReturnItem()

 

   at Spotfire.Dxp.Framework.Threading.Worker`2.DoBatchWorkCore(IList`1 workItems)

 

   at Spotfire.Dxp.Framework.DocumentModel.Snapshot`1.<>c__DisplayClass7.<ReadCore>b__5()

 

   at Spotfire.Dxp.Framework.DocumentModel.ThreadTransactionInfo.EvaluateWithGenerationDependant(ILimitationTarget generationDependant, Executor executor)

 

   at Spotfire.Dxp.Framework.DocumentModel.Snapshot`1.ReadCore(Action`1 action)

 

   at Spotfire.Dxp.Framework.DocumentModel.Snapshot`1.Read(Action`1 action)

 

   at Spotfire.Dxp.Framework.Threading.WorkItem.ReadModel[TModel](Action`1 readAction)

 

   at Spotfire.Dxp.Framework.Threading.Worker`2.HandleWorkItemsCore(IList`1 workItems)

 

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...