Tensorflow Serving: Rest API returns "Malformed request" error - rest

Tensorflow Serving server (run with docker) responds to my GET (and POST) requests with this:
{ "error": "Malformed request: POST /v1/models/saved_model/" }
Precisely the same problem was already reported but never solved (supposedly, this is a StackOverflow kind of question, not a GitHub issue):
https://github.com/tensorflow/serving/issues/1085
https://github.com/tensorflow/serving/issues/1095
Any ideas? Thank you very much.

I verified that this does not work pre-v12 and does indeed work post-v12.
> docker run -it -p 127.0.0.1:9000:8500 -p 127.0.0.1:9009:8501 -v /models/55:/models/55 -e MODEL_NAME=55 --rm tensorflow/serving
> curl http://localhost:9009/v1/models/55
{ "error": "Malformed request: GET /v1/models/55" }
Now try with v12:
> docker run -it -p 127.0.0.1:9000:8500 -p 127.0.0.1:9009:8501 -v /models/55:/models/55 -e MODEL_NAME=55 --rm tensorflow/serving:1.12.0
> curl http://localhost:9009/v1/models/55
{
"model_version_status": [
{
"version": "1541703514",
"state": "AVAILABLE",
"status": {
"error_code": "OK",
"error_message": ""
}
}
]
}

There were two issues with my approach:
1) The status check request wasn't supported in my Tensorflow_model_server (see https://github.com/tensorflow/serving/issues/1085 for details)
2) More importantly, when using Windows you must escape quotation marks in JSON. So instead of:
curl -XPOST http://localhost:8501/v1/models/saved_model:predict -d "{"instances":[{"features":[1,1,1,1,1,1,1,1,1,1]}]}"
I should have used this:
curl -XPOST http://localhost:8501/v1/models/saved_model:predict -d "{\"instances\":[{\"features\":[1,1,1,1,1,1,1,1,1,1]}]}"

Depends on your model, but this is what my body looks like:
{"inputs": {"text": ["Hello"]}}
I used Postman to help me out so that it knew it was a JSON.
This is for predict API, so the url ends in ":predict"
Again, that depends on what API you're trying to use.

Model status API is only supported in master branch. There is no TF serving release that supports it yet (the API is slated for upcoming 1.12 release). You can use the nightly docker image (tensorflow/serving:nightly) to test on master branch builds.
This solution gived by netf in issue:1128 in tensorflow/serving.
I already try this solution, it's done and i can get the model status.Getting Model status img(this is the img for model status demo).
Hope I can help you.
If you not clear the master branch builds, you can contact me.
I can give your instruction.
Email:mizeshuang#gmail.com

Related

Localstack with MassTransit not getting messages

I am having issues testing MassTransit with LocalStack, but with the real SNS/SQS in AWS everything works fine, so I suspect it's an issue with LocalStack unless MassTransit requires something else than configuring ServiceURL. See https://github.com/MassTransit/MassTransit/issues/1476
I run LocalStack as following, just with SNS and SQS
docker run -it -e SERVICES=sns,sqs -e TEST_AWS_ACCOUNT_ID="000000000000" -e DEFAULT_REGION="us-east-1" -e LOCALSTACK_HOSTNAME="localhost" -e -rm --privileged --name localstack_main -p 4566:4566 -p 4571:4571 -p 8080-8081:8080-8081 -v "/tmp/localstack:/tmp/localstack" -v "/var/run/docker.sock:/var/run/docker.sock" -e DOCKER_HOST="unix:///var/run/docker.sock" -e HOST_TMP_FOLDER="/tmp/localstack" "localstack/localstack"
Now with MassTransit I create the bus and start it. The only change I make for MassTransit to work with LocalStack is setting the ServiceURL in SNS and SQS. The rest should work in the same way (I think)
var region = "localhost:4566";
var accessKey = "test";
var secretKey = "test";
var busControl = Bus.Factory.CreateUsingAmazonSqs(c =>
{
var hostAddress = new Uri($"amazonsqs://{region}")
var hostConfigurator = new AmazonSqsHostConfigurator(hostAddress);
hostConfigurator.AccessKey(accessKey);
hostConfigurator.SecretKey(secretKey);
hostConfigurator.Config(new AmazonSimpleNotificationServiceConfig {ServiceURL = $"http://{region}"});
hostConfigurator.Config(new AmazonSQSConfig {ServiceURL = $"http://{region}"});
c.Host(hostConfigurator.Settings);
});
When running my project I can connect and publish events, no errors. I subscribe to events, no errors. I can see the topics, subscriptions and queue are properly created in LocalStack.
I can also see with Commandeer that there are "invisible" messages in the queue (not sure what that is) so it seems the problem is in the receiving part.
Is there anything additional requirement to configure in MassTransit to consume published events?
UPDATE 1: One interesting thing is that I can keep the subscriber listening for long time and during this time Commandeer shows there are invisible messages in the queue.
As soon as I stop the subscriber (and my application) I can see that Commandeer moves messages from "invisible" to "messages". Cannot peek messages though.
I've confirmed the problem is with localstack latest image as I've tried with an older one, as per Chris' suggestion, and it works well.
With localstack/localstack:0.11.2 it works well
docker run -it -e SERVICES=sns,sqs -e TEST_AWS_ACCOUNT_ID="000000000000" -e DEFAULT_REGION="us-east-1" -e LOCALSTACK_HOSTNAME="localhost" -e -rm --privileged --name localstack_main -p 4566:4566 -p 4571:4571 -p 8080-8081:8080-8081 -v "/tmp/localstack:/tmp/localstack" -v "/var/run/docker.sock:/var/run/docker.sock" -e DOCKER_HOST="unix:///var/run/docker.sock" -e HOST_TMP_FOLDER="/tmp/localstack" "localstack/localstack:0.11.2"
With latest (I think it was bdfbe53666a4dd13a09dd9e4b155e2fb750b8041daf7efc69783cb4208b6cacc but not a 100% sure) it doesn't work.
The following image versions don't work either:
localstack/localstack:0.12.8
localstack/localstack:0.11.6
UPDATE 1: I've created a simple repo with instructions to reproduce the issue https://gitlab.com/sunnyatticsoftware/sandbox/issue-localstack-masstransit
Notice the repo has a wrapper abstraction over MassTransit to use with a clean architecture. This doesn't affect the issue, but it was easier to copy-paste the needed parts rather than building up a sample from scratch.
UPDATE 2: Verified that the latest version localstack/localstack:0.12.9.1
works well for above scenario (see repo)
UPDATE 3 (2021-01-12): I attempted the version localstack/localstack:0.12.9.1 again and it does not work. Not sure if the previous time it really worked or the docker image was overwritten. In any case I'm back at using the version localstack/localstack:0.11.2 again, because the latest is also broken, unfortunately.
I can see the messages in the queue as hidden.
awslocal sqs get-queue-attributes --queue-url http://localhost:4566/000000000000/sample-queue --attribute-names All
{
"Attributes": {
"ApproximateNumberOfMessages": "0",
"ApproximateNumberOfMessagesDelayed": "0",
"ApproximateNumberOfMessagesNotVisible": "4",
"CreatedTimestamp": "1626087449.988218",
"DelaySeconds": "0",
"LastModifiedTimestamp": "1626087450.113652",
"MaximumMessageSize": "262144",
"MessageRetentionPeriod": "345600",
"QueueArn": "arn:aws:sqs:us-east-1:000000000000:sample-queue",
"Policy": "{\"Version\": \"2012-10-17\", \"Statement\": [{\"Sid\": \"0d948ac2a9ea4ed7b2c0609642107f0f\", \"Effect\": \"Allow\", \"Principal\": {\"AWS\": \"*\"}, \"Action\": \"sqs:SendMessage\", \"Resource\": \"arn:aws:sqs:us-east-1:000000000000:sample-queue\", \"Condition\": {\"ArnLike\": {\"aws:SourceArn\": \"arn:aws:sns:us-east-1:000000000000:*\"}}}]}",
"ReceiveMessageWaitTimeSeconds": "0",
"VisibilityTimeout": "30"
}
}

Kafka connector config error: filter.condition: Invalid json path defined

I'm trying to use Confluent's Filter SMT with Debezium example unwrap-smt.
I added the following configs to source connector (Debezium MySQL) config:
"transforms": "route,csFilter",
...
...
"transforms.csFilter.type": "io.confluent.connect.transforms.Filter$Value",
"transforms.csFilter.filter.condition": "$.payload.after.source == 2",
"transforms.csFilter.filter.type": "exclude",
"transforms.csFilter.missing.or.null.behavior": "fail"
Since this Filter SMT is provided by Confluent, I downloaded the jar file and copied (connect-transforms, connect-utils, json-path) jar files to path-to-kafka/connect/debezium-connector-mysql directory.
When I tried to register Debezium MySQL source connector,
curl -i -X POST -H "Accept:application/json" -H "Content-Type:application/json"
localhost:8083/connectors/ -d #source_connector_config.json
I got this error:
{"error_code":400,
"message":"Connector configuration is invalid and contains the following 1 error(s):\n
Invalid value $.payload.after.source == 2 for configuration filter.condition: Invalid json path defined.
Please refer to https://github.com/json-path/JsonPath README for correct use of json path.\n
You can also find the above list of errors at the endpoint `/{connectorType}/config/validate`"}
I checked the JSON path expression with the examples provided in this guide. It seemed okay.
Can you please point me to the right directioin? What am I missing?
Thanks.
Please try to use this condition: $.payload.after[?(#.source == 2)]

kubeflow UI shows "the site can't be reached" after deploy with CLI

I try to deploy kubeflow with the tutorial https://www.kubeflow.org/docs/gke/deploy/deploy-cli/ , after I run "kfctl apply -V -f ${CONFIG_FILE}" and finally I see "Applied the configuration Successfully!", then I wait an hour and try to visit "https://.endpoints..cloud.goog/" as tutorial described.
However, when I visit my url, it shows "the site can't be reached".
And I try to "curl -k https://chukubeflow.endpoints.tchu-test.cloud.goog -v" , it shows:
* Rebuilt URL to: https://chukubeflow.endpoints.tchu-test.cloud.goog/
* Could not resolve host: chukubeflow.endpoints.tchu-test.cloud.goog
* Closing connection 0
It seems DNS resolve failed. Any suggestion for this problem?
It seems no problem when I use a new oAuth and a new App ("tchu2kubeflow" instead of "tchukubeflow"). So I guess some fails happened before and remembered in the workflow

trying to start a standalone wiremockcsv application

Has any one tried wiremock csv standalone application?
I did a mvn clean install for wiremockcsv and the build is successfull. I can see wiremockcsv-1.1.1-standalone.jar in my target folder. Then launched using the below command in my terminal
java -jar "##MyProjectPath##/WireMockCsv/target/wiremockcsv-1.1.1-standalone.jar" --port 8181 --root-dir ".\src\test\resources\factures\mock" --verbose
The application is launched successfully. But when I hit the below request in postman I get not found response. Can someone help me what I am missing here.
http://localhost:8181/rechercherClients
Response:
Error 404
HTTP ERROR: 404
Problem accessing /__files/rechercherClients. Reason:
<pre> Not Found</pre>
</p>
<hr />
<i>
<small>Powered by Jetty://</small>
</i>
and in my terminal i can see this
Matched response definition:
(no response definition configured)
When i hit http://localhost:8181/__admin
I get below response
{
"mappings": [],
"meta": {
"total": 0
}
}
Am i missing something?
With the demo project, the mappings are already done, it's ready to launch with examples of all features.
In your case, the command line is not correct, if the current directory is not the project's base, it will not work, ##MyProjectPath## should be path of your project
Try this:
java -jar "##MyProjectPath##\WireMockCsv\target\wiremockcsv-1.1.1-standalone.jar" --port 8181 --root-dir "**##MyProjectPath##**\src\test\resources\factures\mock" --verbose
Or better and easier, directly with the provided Eclipse Launch Config ;-)

swift client delete object failed

Environment
swift client in CentOS7(10.0.0.2)
bash
[root#bogon ~]# pip2 show python-swiftclient
Name: python-swiftclient
Version: 2.7.0
Summary: OpenStack Object Storage API Client Library
Home-page: http://www.openstack.org/
Author: OpenStack
Author-email: openstack-dev#lists.openstack.org
License: UNKNOWN
Location: /usr/lib/python2.7/site-packages
Requires: futures, six, requests
swift server in CentOS7(10.0.0.4)
bash
[root#bogon ~]# swift --version
python-swiftclient 3.2.1.dev9
Question
swift client login server ,and delete one .jpg file in the container "temporary".
Details
[root#bogon ~]# swift -A http://10.0.0.4:8080/auth/v1.0 -U admin:admin -K admin_pass list
contract
data
mask_contract
temporary
[root#bogon ~]# swift -A http://10.0.0.4:8080/auth/v1.0 -U admin:admin -K 806huayuan list temporary | tail
9f2f8626-a2ad-11e7-ad0b-1866daecc1a0.jpg
a25ebf08-a2b0-11e7-ad0b-1866daecc1a0.jpg
a6cfc990-a2ad-11e7-ad0b-1866daecc1a0.jpg
a8732914-a216-11e7-ad0b-1866daecc1a0.jpg
a87cda6a-77f8-11e7-befe-1866daecc1a0.jpg
ad186efc-a216-11e7-ad0b-1866daecc1a0.jpg
b255e2e6-a216-11e7-ad0b-1866daecc1a0.jpg
d1d010f2-0129-11e8-8cef-1866daecc1a0.jpg
f779a1ea-a2ad-11e7-ad0b-1866daecc1a0.jpg
ff4fbf7e-aa70-11e7-bbe0-1866daecc1a0.jpg
[root#bogon ~]# swift -A http://10.0.0.4:8080/auth/v1.0 -U admin:admin -K 806huayuan delete temporary ff4fbf7e-aa70-11e7-bbe0-1866daecc1a0.jpg
Error Deleting: temporary/f779a1ea-a2ad-11e7-ad0b-1866daecc1a0.jpg: Object DELETE failed: http://10.0.0.4:8080/v1/AUTH_admin/temporary/f779a1ea-a2ad-11e7-ad0b-1866daecc1a0.jpg 409 Conflict [first 60 chars of response] There was a conflict when trying t
Got it!
The reason is that the timestamp assigned to the delete is earlier than the timestamp of the objects.
http://lists.openstack.org/pipermail/openstack-dev/2014-April/033438.html