I want to create some metrics around step functions that we currently have. I was able to make that list using python but for some reason, we are limited to use java in our company.
I want to
List ALL statemachines which are defined in current region for given account. in python i was able to achieve this using
stepFunction = boto3.client('stepfunctions', region_name='eu-west-1')
stepFunction.list_state_machines()
Then from that, i want to list all Tasks for that given statemachine and get some metrics.
In Java, I am unable to find an API reference which will give me ALL statemachines. I was looking at http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/index.html?com/amazonaws/services/stepfunctions/model/ListStateMachinesRequest.html API but no help.
To get the activity tasks for every state machine in your library, you will need to use the describeStateMachine call. Follow this pattern (please excuse the pseudocode):
state_machines = list_state_machines()
for each (state machine arn : state_machines)
sm = describe_statemachine(state_machine_arn)
/*parse through the definition here and use regex pattern on the arns*/
activityarns = sm.getDefinition().find(/regex/)
metrics.add(sm.arn, activityarns)
endforeach
Hope this helps!
Related
I am new to Corda and am designing a Cordap. I want to display the states onto the terminal based on some arguments passed during initiating the flow.
My approach was I created a List of type StateAndRef storing all the states. Now I loop through the list and display the state based on if else condition.
But the issue I am facing is somethimes all the states the printed and sometimes only few of them are printed. Please help me to solve this problem. My main motive is I should be able to display on the screen those states which have name Car.
PS: I am using Java for designing the Cordapp.
You don't really need a flow to display states. You con using vaultQuery to do so:
run vaultQuery contractStateType: <fully-qualified name of the state type>
Refer documentation here for: https://docs.corda.net/docs/corda-os/4.4/shell.html#examples
In case you want to do complex querying, it's not supported in the CRaSH shell. However, you could do so in the RPC Client using the vault Query API. The VaultQuery API is very flexible and provide a number of mechanisms to access the vault.
Check the documentation here: https://docs.corda.net/docs/corda-os/4.4/api-vault-query.html#api-vault-query
As Ashutosh has already mentioned, complex querying doesn't seem to be supported yet. However a way to accomplish querying a subset of all states would be to create another class for those states.
For Ex - CARState for the subset you want to query on and the other states can be CAR2State, and then just use the
run vaultQuery contractStateType: com.template.CARState
Im not sure if this helps since I don't know for what reasons you want to use arguments passed in the flow. But the RPC client is the way to achieve complex queries, unfortunately that is not covered in my course on Udemy.
I have started learning Java a while back and looking at doing my first advanced (for me) project. I am wanting to create a program that uses the OpenWeatherMap API to show the weather for a particular city.
User inputs name of city
City stored as variable
Call API using city variable
Store results in two varibles (City & temp)
Display results using System.out.Println(City, Temp)
I have done some reading before starting and I am seeing people saying that storing api results in variables is bad practice? Just checking I am going down the right route before starting?
Below is an example of the API result
{"coord":{"lon":-0.13,"lat":51.51},"weather":[{"id":300,"main":"Drizzle","description":"light intensity drizzle","icon":"09d"}],"base":"stations","main":{"temp":280.32,"pressure":1012,"humidity":81,"temp_min":279.15,"temp_max":281.15},"visibility":10000,"wind":{"speed":4.1,"deg":80},"clouds":{"all":90},"dt":1485789600,"sys":{"type":1,"id":5091,"message":0.0103,"country":"GB","sunrise":1485762037,"sunset":1485794875},"id":2643743,"name":"London","cod":200}
Not sure why storing data in variables is bad practice. The alternative is to chain methods. e.g. instead of this:
String cityResult = callApi(city);
JSON jsonCityResult = JSON.parse(cityResult);
print(jsonCityResult.temp);
it would be:
print(JSON.parse(callApi(city)).temp);
which is difficult to read, difficult to maintain and difficult to work out what went wrong. Was it the api call or the JSON parse?
As long as the code is 'self documenting', i.e. cityResult instead of cr I think that is perfectable acceptable programming.
I`m using Android Google Places API to autocomplete streets and addresses. The problem is that it gives all streets from a whole country. Of course I added bounds to limit place for search, but it doesnt work correctly - it gives only priority, so in other words best results will be higher in list, nothing more
So code:
AutocompleteFilter typeFilter = new AutocompleteFilter.Builder()
.setTypeFilter(AutocompleteFilter.TYPE_FILTER_ADDRESS)
.setCountry("RU")
.build();
Intent intent =
new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY)
.zzih(searchString) //that is for passing search string from toolbar
.setFilter(typeFilter)
.setBoundsBias(city.getBounds())
.build(this);
In short the problem is:
When I type in search something like "Lenina Street" I see a lot of useless results out of bounds set in .setBoundsBias(city.getBounds()). Just imagine that something like "Lenina Street" exists in almost every locality!
How can I fix the problem and limit search results?
P.S.
I know I can use Google Places Web API or by GeoDataApi.getAutocompletePredictions() and filter results manually,
but that means I have to write UI manually too, what I dont want to
do.
Thats even worse than I thought. Even if I get results from Web API or through GeoDataApi I have only predictions which doesnt contain coordinates, only placeId. So if I want to filter predictions by coordinates I have to do request for each placeId. In other words if I got 20 places I will have to do 20 more requests to find out coordinates.
Also I can add city name in searchString, that makes results better (but not at all) but it makes writing of address unclear and city name takes place, so its not good solution too.
I'm afraid Places API for Android doesn't support strict bounds yet. There is a feature request in Google Issue tracker to implement this:
https://issuetracker.google.com/issues/38188994
Feel free to star this feature request to add your vote and subscribe to notifications from Google.
In the meantime the workaround might be using Places API web service that supports strict bounds and implement the UI manually.
UPDATE
The feature request was marked as Fixed by Google. Have a look at https://stackoverflow.com/a/50134855/5140781 that shows how to apply strict bounds in Places API for Android.
I started working with this network. And I wrote some code, but I am not sure whether I am doing it right or not. here is what I do:
First create the network HopefieldNetwork net = new HopefieldNetwork(50).
Than add all patterns, with net.addPattern(aPattern) where aPattern is of type BasicMLData and changes in a loop to add all patterns.
Now do net.runUntilStable(5000) for training with 5000 iterations max. Is this right?
Now we have the trained network. Get output like out = (BasicMLData) net.compute(input)
So is everything OK?
I found the solution.
You have to call setCurrentState then runUntilStable then getCurrentState to get output.
I have used OpenNLP to create an model. But now i am looking into StanfordNLP which uses Condition Random Field. I want to know how to train a data for NER using stanfordNLP.
For OpenNLp we use START and END tag but i do no how to train using StanfordNLP. please give me an example.
Look at http://nlp.stanford.edu/software/crf-faq.shtml#b
That should explain what you need to know to get started. There are then many options mainly only documented in the code.