Can someone help me with name of api which enables realtime prediction of a model. Please note that i am not requesting for RealtimeEndpointRequest object. i have gone through the entire documentation of AWS Machine Learning SDK but haven't found any thing.
Edit 1 :
This is the code that i have used -
CreateRealTimePrediction createRealTimePrediction ;
CreateRealtimeEndpointRequest createRealtimeEndPointReq;
CreateRealtimeEndpointResult createRealtimeEndPointRes;
PredictRequest predReq;
String mlModelId="ml-Lkqmcs8cM2W";
createRealtimeEndPointReq.setMLModelId(mlModelId);
PredictResult predRes = null;
Map<String,String> record=null;
// assume i have set a record in the Map.
createRealtimeEndPointRes = amlClient.createRealtimeEndpoint(createRealtimeEndPointReq);
String predictEndpoint=createRealtimeEndPointRes.getRealtimeEndpointInfo().getEndpointUrl();
predReq= new PredictRequest();
predReq.setMLModelId(mlModelId);
for (int i=0;i<recordKeys.length;i++){
record.put(recordKeys[i],recordValues[i]);
}
predReq.setRecord(record);
predReq.setPredictEndpoint(predictEndpoint);
predRes=amlClient.predict(predReq);
return predRes;
}
Now what is happening is - if i enable the real time prediction by using aws management console manually and then run this segment of code, then the results are generated as expected but when i the realtime prediction is disabled, then i get this error -
Exception in thread "main" com.amazonaws.services.machinelearning.model.PredictorNotMountedException: Either ML Model with id ml-Lkqmcs8
cM2W is not enabled for real-time predictions or the MLModelId is invalid. (Service: AmazonMachineLearning; Status Code: 400; Error Code
: PredictorNotMountedException; Request ID: 2dc70e58-07d0-11e5-a0c7-bb93f17d1b2e)
at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1160)
at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:748)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:467)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:302)
at com.amazonaws.services.machinelearning.AmazonMachineLearningClient.invoke(AmazonMachineLearningClient.java:1995)
at com.amazonaws.services.machinelearning.AmazonMachineLearningClient.predict(AmazonMachineLearningClient.java:637)
at com.nrift.aml.prediction.realtime.CreateRealTimePrediction.createRealTimePrediction(CreateRealTimePrediction.java:61)
at RealTimePrediction.main(RealTimePrediction.java:53)
which effectively means that this segment of code is not enabling the real time prediction though i have used
CreateRealtimeEndpoint
api in it.
P.s- the code segment i have posted is a not complete, the complete code is working correctly so you can make assumptions about the correctness of code.
The API you are looking for is CreateRealtimeEndpoint. Creating a real-time endpoint is the mechanism for enabling the model to be used for real-time predictions. When you no longer need to use this model, you can destroy the endpoint with the DeleteRealtimeEndpoint API. The model always stays intact, so you can create/delete endpoints when needed.
Related
Has anyone here worked with the DatedFlight class to retrieve flight status as of Amadeus Java class from version 5.4.1? What issues have you experienced? Is there a list of known issues I can refer to for this Flight Status feature that is recently released?
I have used the DatedFlight class to retrieve scheduled flight information from Amadeus for flight SQ479. However, I do not get consistent results. Sometimes I get ResponseException. Sometimes I get no results. However, when I go to the Amadeus Dev portal and make a call RESTful call from the portal it works. Please see the code example below.
.builder("YOUR_AMADEUS_API_KEY","YOUR_AMADEUS_API_SECRET")
.build();
// Returns the status of a given flight
DatedFlight[] flightStatus = amadeus.schedule.flights.get(Params
.with("flightNumber", "319")
.and("carrierCode", "AZ")
.and("scheduledDepartureDate", "2021-03-13"));
if (flightStatus[0].getResponse().getStatusCode() != 200) {
System.out.println("Wrong status code: " + flightStatus[0].getResponse().getStatusCode());
System.exit(-1);
}
System.out.println(flightStatus[0]);```
It seems like this particular scheduling function is only available in Test API. When requesting in production the data part of JSON is empty. But when requested in test it is fully populated.
Clearly I did not read the manual....
I'm building a Spring Boot application that's deployed on Google App Engine. To find out the cause of some weird latency issues, I figured I'd enable Google Cloud Trace to view detailed latency reports.
Adding basic tracing was simple enough since this is supported natively by GAE. However, I am having a hard time adding details to any individual trace.
For example; the following code:
public MediaContent getMediaContent(long contentId) {
Optional<MediaContent> found;
try (Scope ss = tracer.spanBuilder("databaseSubSpan").setSampler(Samplers.alwaysSample()).startScopedSpan()) {
tracer.getCurrentSpan().addAnnotation("Retrieving MediaContent " + contentId + " from repository");
found = mediaContentRepository.findById(contentId);
}
if (found.isEmpty()) {
tracer.getCurrentSpan().setStatus(Status.NOT_FOUND);
throw new NoSuchContentException(contentId);
}
return found.get();
}
I figured that in the Cloud Trace UI, this would display a separate little latency line so I could see which part of the total request time is spent on database communication. However, no such information is visible to me:
I have made sure that this exact method is invoked by adding a few log entries around it. All the log entries (even the one inside the try block) show up in my logs.
I set the sampling rate to 100% by adding the following to my application.yml: spring.sleuth.sampler.probability: 1.0
Basically, what I expected to see on the Cloud Trace UI is a second bar underneath the primary request. As such:
Is this even possible in Cloud Trace? I expect that it would be since the chart is so tall which seems to me like it has space left for extra bars. If it is, what am I doing wrong?
Thanks.
It needs to be investigated by the Google product team.
Then I would suggest forwarding this through a Public Issue Tracker for further support. or you can open a ticket with Google Cloud support (For free users this link) so that we may investigate this issue further.
I do not want to block threads in my application and so I am wondering are calls to the the Google Datastore async? For example the docs show something like this to retrieve an entity:
// Key employeeKey = ...;
LookupRequest request = LookupRequest.newBuilder().addKey(employeeKey).build();
LookupResponse response = datastore.lookup(request);
if (response.getMissingCount() == 1) {
throw new RuntimeException("entity not found");
}
Entity employee = response.getFound(0).getEntity();
This does not look like an async call to me, so it is possible to make aysnc calls to the database in Java? I noticed App engine has some libraries for async calls in its Java API, but I am not using appengine, I will be calling the datastore from my own instances. As well, if there is an async library can I test it on my local server (for example app engine's async library I could not find a way to set it up to use my local server for example I this library can't get my environment variables).
In your shoes, I'd give a try to Spotify's open-source Asynchronous Google Datastore Client -- I have not personally tried it, but it appears to meet all of your requirements, including being able to test on your local server. Please give it a try and let us all know how well it meets your needs, so we can all benefit and learn -- thanks!
I am developing an app that gets Facebook unread inbox message .
The following v2.0 FQL query works fine:
SELECT sender, body FROM unified_message
WHERE thread_id IN
(SELECT thread_id FROM unified_thread WHERE folder = 'inbox' AND unread=1)
AND unread=1
ORDER BY timestamp DESC
As a result, we have a list of all unread messages.
But, Facebook says:
Version 2.0 of the Facebook Platform API is the last version where FQL
will be available. Versions after 2.0 will not support FQL. Please
migrate your applications to use Graph API instead of FQL. Please see
our changelog for current version information.
So, I am looking for a way to do that with Graph API only. I tried the following:
Bundle params = new Bundle();
params.putString("unread", ">0");
new Request(session,"/me/inbox/",params,HttpMethod.GET,new Request.Callback() {
public void onCompleted(Response response) {
...
}
}
).executeAsync();
without success. I get all the threads whereas I only need the unread threads. How to do that then?
I am sorry for the advice I gave when I blindly quoted the following Facebook notice:
However, you should not use FQL anymore:
Version 2.0 of the Facebook Platform API is the last version where FQL will be available. Versions after 2.0 will not support FQL. Please
migrate your applications to use Graph API instead of FQL. Please see
our changelog for current version information.
This statement is true, but to follow it isn't very smart.
Indeed, I checked further and found out:
v2.0 is available until August 7th 2016,
the Graph API is not yet suitable for your current usage.
I didn't expect the Graph API to be so weak. The Graph API makes it impossible to build a request by filtering any field. For example, we can't do simple things such as:
me/threads?unread_count>0,
me/threads?fields=unread_count.more(0).
Right now with Graph, you would have to iterate through all the threads and check which one have unread > 0. You would lose time and bandwidth. Moreover, the message table doesn't even have an unread field which would make it impossible for you to find any specific unread message(s).
So, the best is to keep using FQL. You are safe for now. By 2016, Facebook will probably have improved the way we query with Graph API.
Wait and see...
I'm trying to start a Amazon EC2 cloud machine with [startInstance][2] method using aws-sdk in Java. My code is as follows.
public String startInstance(String instanceId) throws Exception {
List<String> instanceIds = new ArrayList<String>();
instanceIds.add(instanceId);
StartInstancesRequest startRequest = new StartInstancesRequest(
instanceIds);
startRequest.setRequestCredentials(getCredentials());
StartInstancesResult startResult = ec2.startInstances(startRequest);
List<InstanceStateChange> stateChangeList = startResult
.getStartingInstances();
log.trace("Starting instance '{}':", instanceId);
// Wait for the instance to be started
return waitForTransitionCompletion(stateChangeList, "running",
instanceId);
}
When I run the above code, i'm getting the following AWS error:
Status Code: 400, AWS Request ID: e1bd4795-a609-44d1-9e80-43611e80006b, AWS Erro
r Code: InvalidInstanceID.NotFound, AWS Error Message: The instance ID 'i-2b97ac
2f' does not exist
at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpCli
ent.java:538)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.ja
va:283)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:168
)
at com.amazonaws.services.ec2.AmazonEC2Client.invoke(AmazonEC2Client.jav
a:5208)
at com.amazonaws.services.ec2.AmazonEC2Client.startInstances(AmazonEC2Cl
ient.java:2426)
AWS Error Message: The instance ID 'i-2b97ac2f' does not exist
You'll have to take the AWS response for granted here, i.e. the instance does not exist ;)
But seriously: Presumably you have already verified that you are actually running an instance with this ID in your account? Then this is most likely caused by targeting the wrong API endpoint, insofar an instance ID is only valid within a specific region (if not specified, the region defaults to 'us-east-1', see below).
In this case you need to specify the actual instance region via the setEndpoint() method of the AmazonEC2Client object within the apparently global ec2 variable before calling startInstances().
There are some examples regarding Using Regions with the AWS SDKs and all currently available AWS regional endpoint URLs are listed in Regions and Endpoints, specifically the Amazon Elastic Compute Cloud (EC2) defaults to 'us-east-1':
If you just specify the general endpoint (ec2.amazonaws.com), Amazon
EC2 directs your request to the us-east-1 endpoint.
We run a service (Qubole) that frequently spawns and then tags (and in some cases terminates) AWS instances immediately.
We have found that Amazon will, every once in a while, claim an instanceid as invalid - even though it has just created it. Retrying a few times with some sleep time thrown in usually solves the problem. Even a total retry interval of 15s proved insufficient in rare cases.
This experience comes from the useast region. We do not make api calls to different regions - so that is not an explanation. More likely - this is the infamous eventual consistency at work - where AWS is unable to provide read-after-write consistency for these api calls.
I am using the AWS ruby api and I noticed the same issue when creating an AMI image and its status is pending when I look in the AWS console but after a while the image is available for use.
Here is my script
image = ec2.images.create(:name => image_name, :instance_id => ami_id, :description => desc)
sleep 5 while image.state != :available
I sleep for about 5 sec for image to be in available but I get the error saying that the "AWS Error Message: InvalidInstanceID.NotFound". During my testing this is fine but most of the time this seems to be failing during continuous integration builds.
InvalidInstanceID.NotFound means the specified instance does not exist.
Ensure that you have indicated the region in which the instance is located, if it's not in the default region.
This error may occur because the ID of a recently created instance has not propagated through the system. For more information, see Eventual Consistency.