Dynamically access state while integrating (python) - scipy

I am integrating a system using scipy's odeint.
I would like to access the state during integration, and use it in the next step in the integration to modify the state accordingly.
More specifically, I want to take a dot product of the previous state and current state, and if it satisfies a certain condition I may want to alter the current state. This has effect on the next step of the integration, etc...
I am not sure how I can do this. That is, I want to dynamically access my state during the integration routine and modify it accordingly.
EDIT: In MATLAB there is an argument "outputFcn" which might be useful. I am essentially looking for an outputFcn type solution in Python.

Related

How to use the User Input node in SPSS modeler?

I am trying to make my SPSS flow a bit more dynamic. Although there is no way (that I am aware of) to take an input, is there a way to use User Input node to take some parameter values and use these parameters in another select node to perform tests on data.
What I am trying to achieve is run the same flow with some minor parameter changes. I have the flow running for some static values used in select nodes. It would be great if there was a way to change these static select nodes, even if it's not with a User Input node.
I believe what you are looking for is actually to make a parameter in SPSS modeler and then enable/check the Prompt? which will ask the user for input every time the stream is executed.
In SPSS Modeler 18.2 onwards I was able to see the prompt option as the first feature of parameter tab.

Best practices for Informatica Webservice workflow

I have created a Informatica webservice workflow which takes 1 parameter as input. A Webservice provider source definition is used for this and mapping is a one-way type.
Workflow works fine when parameter is being passed. But when the same workflow is triggered from Informatica Power center directly (in which case no parameters are passed), mapping that contains webservice provider source definition takes 3 minutes to complete (Gives Timeout based commit point in the log).
Is it a good practice to run the webservice workflow from power center directly? And is there a way to improve its performance when triggered from power center directly?
Note: I am trying to use 1 workflow for both - 1) Pass the parameter from web 2) Schedule the workflow in Informatica
Answers to your questions below.
Is it a good practice to run the webservice workflow from power center directly?
Of course it depends on requirement - whether you need to extract data automatically from WS or not. If you pass parameter using some session then i dont see much issue here and your session is completing within time.
So, you can create a new session/command task/shell script to create a param file and then use it in original session so it is passed on to WS.
In a complex scenario, you may have to pass multiple values, in such case, i would recommend to use a parent workflow to call original workflow multiple times and change param every time before call.
Is there a way to improve its performance when triggered from power center directly?
It is really depends on few factors.
The web service - Make sure you are using correct input and output columns. Most of the time WS are sensitive to outside call and you need to choose optimized column to extract data for better performance. You can work with WS admin to know correct column.
If informatica flow is complex then depending on bottle neck transformation/s (source, target, expression, lookup, aggregator, sorter), we can check and take actions.
For lookup, you can add new filter to exclude unwanted data, remove unwanted columns etc.
For aggregator, you can use sorter before to improve perf.
... like this

Rundeck display options dynamically

I am using Rundeck for basic API calls periodically or manually. As of now, I have a lot of options the user has to provide, but most of them remains empty.
In fact, some of them depends on a previous one (e.g do you want X ? Then provide Y). Is there a way to display some options only if another has a given value ?
I would like not to create two different jobs but to keep only one.
One possible way is with Cascading Remote Options
This provides a mechanism for declaring hierarchical or dependent sets of option values.

how to create a elastic watch which can identify the changes of data in a given index of elasticsearch

In the offical site of Elastic Watcher, they said
Watcher is a plugin for Elasticsearch that provides alerting and notification based on changes in your data
The relevant data or changes in data can be identified with a periodic Elasticsearch query
What I want is a function like Trigger of MySQL, that is when a record is updated, a action is triggered.
But I didn't find a example or document to address this use case, can anybody tell me how to do this?
You define an input of type search and using body, indices (mainly) you define which indices to look at (indices) and what is the actual query (body). If you need other settings, there are many more things to configure. After this, you define a condition and an action to complete the flow.
Make an attempt and create a watch. If you have difficulties, provide details of what you tried in a different SO post (you realize your current post is not appropriate for SO since you ask for complete code without you trying anything).

How to make an InArgument's value dependant upon the value of another InArgument at design time

I have a requirement to allow a user to specify the value of an InArgument / property from a list of valid values (e.g. a combobox). The list of valid values is determined by the value of another InArgument (the value of which will be set by an expression).
For instance, at design time:
User enters a file path into workflow variable FilePath
The DependedUpon InArgument is set to the value of FilePath
The file is queried and a list of valid values is displayed to the user to select the appropriate value (presumably via a custom PropertyValueEditor).
Is this possible?
Considering this is being done at design time, I'd strongly suggest you provide for all this logic within the designer, rather than in the Activity itself.
Design-time logic shouldn't be contained within your Activity. Your Activity should be able to run independent of any designer. Think about it this way...
You sit down and design your workflow using Activities and their designers. Once done, you install/xcopy the workflows to a server somewhere else. When the server loads that Activity prior to executing it, what happens when your design logic executes in CacheMetadata? Either it is skipped using some heuristic to determine that you are not running in design time, or you include extra logic to skip this code when it is unable to locate that file. Either way, why is a server executing this design time code? The answer is that it shouldn't be executing it; that code belongs with the designers.
This is why, if you look at the framework, you'll see that Activities and their designers exist in different assemblies. Your code should be the same way--design-centric code should be delivered in separate assemblies from your Activities, so that you may deliver both to designers, and only the Activity assemblies to your application servers.
When do you want to validate this, at design time or run time?
Design time is limited because the user can use an expression that depends on another variable and you can't read the value from there at design time. You can however look at the expression and possibly deduce an invalid combination that way. In this case you need to add code to the CacheMetadata function.
At run time you can get the actual values and validate them in the Execute function.