bluedata mlops prediction - 'NoneType' object does not support item assignment - bluedata

I'm calling the BlueData MLOPS prediction API to get a score for my model, but I'm getting the following response:
============================response begin==========================================
Status code : {}200
Status text : {}OK
Headers : {}{Server=[gunicorn/19.9.0], Date=[Sat, 23 Nov 2019 12:16:43 GMT], Content-Type=[text/html; charset=utf-8], Content-Length=[50]}
Response body: {}'NoneType' object does not support item assignment
=======================response end=================================================
What could be causing this?

On closer inspection of my request, I noticed that I had the content type set to text/plain:
===========================request begin================================================
URI : {}http://xxxx:10026/diabetes%20model/1/predict
Method : {}POST
Headers : {}{Accept=[application/json], X-Auth-Token=[6EMbYcQsBD], Content-Type=[text/plain;charset=ISO-8859-1], Content-Length=[174], Accept-Charset=[big5, ...]}
Request body: {}{"use_scoring": true, "scoring_args": {"NumPreg":1.0,"Glucose": 85.0,"BloodPressure": 66.0,"SkinThick": 29.0,"Insulin": 0.0,"BMI": 26.6,"DiabetesPedFunc": 0.351,"Age": 35.0}}
==========================request end===================================================
Changing that to application/json resolved the issue for me.

Related

Microsoft graph api null or empty filter not working

I want to filter my tasks which are currently active(not completed). I am using microsoft graph api. I get all my tasks and I found that if I mark task complete it is adding date to completedDateTime property. If task is not completed then it's completedDateTime is null. so I try to get task which has completedDateTime eq null but it is not working. so is there any why to check my active task which are not completed?
I have user v1.0 and beta both none of them are working. After lot of struggle get https://github.com/microsoftgraph/microsoft-graph-docs/issues/239 link which says that null check is possible with beta I tried it and it is working. but null check is not working with my query.
Query where null check working:
GET https://graph.microsoft.com/beta/users?$count=true&$select=id,displayName,surname&$filter=surname eq null
Content-type: application/json
ConsistencyLevel : eventual
Authorization: Bearer {{access_token}}
My query where null check not working:
GET https://graph.microsoft.com/beta/me/planner/tasks?$count=true&$select=planId,title,completedDateTime&$filter=completedDateTime eq null
Content-type: application/json
ConsistencyLevel : eventual
Authorization: Bearer {{access_token}}
I have also tried with percentComplete parameter. If it is 100 means task is completed but it also not working.
GET https://graph.microsoft.com/beta/me/planner/tasks?$count=true&$select=planId,title,percentComplete,completedDateTime&$filter= percentComplete ne 100
Content-type: application/json
ConsistencyLevel : eventual
Authorization: Bearer {{access_token}}
According this filtering is not supported and unfortunately it is not described in the documentation which properties support filtering.
I have tested filtering and it is not possible to filter tasks by any property. It always returns all records.
Similar issue:
GitHub
Microsoft Q&A

Microsoft Update DriveItem API throwing locked exception if the file is open in desktop

1.This is the behavior I am observing when I use Update DriveItem graph API to update my file name.https://learn.microsoft.com/en-us/graph/api/driveitem-update?view=graph-rest-1.0&tabs=http.
2.If the file is open in my office desktop document it throws locked exception. If i close the file renaming works fine.
3.I tested same in sharepoint their UI ,I am able to rename the file.But through graph API it throws locked exception if file is open.
Is this error expected ?. How can I get around this
https://learn.microsoft.com/en-us/graph/api/driveitem-update?view=graph-rest-1.0&tabs=http.
PATCH https://graph.microsoft.com/v1.0/drives/b!qnfox2pppU-AeWEPhWpRhNiB9gIq_ANJq5NFCiklU2Y5F3fDc7fsaQvB/items/014UHAXWYO5LX2RTA6YZE37E4XTG45PTTW
SdkVersion : graph-java/v1.6.0
Authorization : Bearer
{"name":"V-blah (1) (113_0_4_26).docx"}
423 : Locked
Strict-Transport-Security : max-age=31536000
Cache-Control : private
x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"West US","Slice":"SliceC","Ring":"5","ScaleUnit":"000","RoleInstance":"AGSFE_IN_57"}}
client-request-id : 33f16bde-55d1-XXXX
request-id : XXXXXXX
Content-Length : 251
Date : Sat, 02 May 2020 04:05:23 GMT
Content-Type : application/json
{
"error": {
"code": "resourceLocked",
"message": "The resource you are attempting to access is locked",
"innerError": {
"request-id": "d1bfa1f2-cXXXXX",
"date": "2020-05-02T04:05:23"
}
}
}
Ensure that the document library does not have "check-in required" enabled.
Assuming check-in is not required, I received the same HTTP 423 "resourceLocked" response for both scenarios: file opened in the browser (SharePoint Online UI) and file opened in desktop client. I believe this is working by design that you can't update a file's name when it is currently opened by another user or yourself in another instance.
Please see this reference about files locked for editing.
Try adding the HeaderOption that bypasses the shared lock, to the request.
new Microsoft.Graph.HeaderOption("Prefer", "bypass-shared-lock")
If you are using the graphServiceClient, add it to a List and pass it directly in your Request.

Error when creating tags with Gibbon (Ruby MailChimp client)

I have an issue when trying to create tags/segments with Gibbon, the MailChimp wrapper for Ruby.
I've been using Gibbon successfully for a large production site for 2 years, but need to move away from Merge Fields to tagging subscribers.
I can successfully add tags to a subscriber via Gibbon, but there are over 85,000 users that need to be transitioned and I really don't want to have to make 85,000 individual requests. There are 200+ possible tags, so I wanted to find all the users for each possible tag and then post the email addresses to the segment endpoint... so 200 requests, rather than 85,000.
The issue is that If a tag already exists (i.e. a test tag I created) in the list, then I get 400 error, Tag already exists and if the tag doesn't exist, I get 404 Resource Not Found. This is the same if I supply email addresses within static_segment or not.
I would expect the following to create a tag within MailChimp:
request = Gibbon::Request.lists(<list_id>)
request.tags.create(body: { name: "testing3", static_segment: [] })
However, I recieve the following error (which is the same if I use tags or segmentsin the request):
I, [2019-06-06T10:33:59.711436 #88340] INFO -- request: POST https://us15.api.mailchimp.com/3.0/lists/<list_id>/tags
D, [2019-06-06T10:33:59.711556 #88340] DEBUG -- request: User-Agent: "Faraday v0.15.4"
Authorization: "Basic <key>"
Content-Type: "application/json"
D, [2019-06-06T10:33:59.711605 #88340] DEBUG -- request: {"type":"http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/","title":"Resource Not Found","status":404,"detail":"Invalid path","instance":"<instance_id>"}
I, [2019-06-06T10:33:59.711779 #88340] INFO -- response: Status 404
D, [2019-06-06T10:33:59.711839 #88340] DEBUG -- response: server: "openresty"
content-type: "application/problem+json; charset=utf-8"
x-request-id: "<instance_id>"
link: "<https://us15.api.mailchimp.com/schema/3.0/ProblemDetailDocument.json>; rel=\"describedBy\""
vary: "Accept-Encoding"
date: "Thu, 06 Jun 2019 09:33:59 GMT"
content-length: "204"
connection: "close"
set-cookie: "_AVESTA_ENVIRONMENT=prod; path=/, _mcid=1.b9640bf1122e4a9b277bb19e3d72caf6; expires=Fri, 05-Jun-2020 09:33:59 GMT; Max-Age=31536000; path=/; domain=.mailchimp.com"
D, [2019-06-06T10:33:59.711878 #88340] DEBUG -- response: {"type":"http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/","title":"Resource Not Found","status":404,"detail":"Invalid path","instance":"<instance_id>"}
Gibbon::MailChimpError: the server responded with status 404 #title="Resource Not Found", #detail="Invalid path", #body={:type=>"http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/", :title=>"Resource Not Found", :status=>404, :detail=>"Invalid path", :instance=>"<instance_id>"}, #raw_body="{\"type\":\"http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/\",\"title\":\"Resource Not Found\",\"status\":404,\"detail\":\"Invalid path\",\"instance\":\"<instance_id>\"}", #status_code=404
from /Users/Paul/.rvm/gems/<gemset>/gems/gibbon-3.2.0/lib/gibbon/api_request.rb:134:in `handle_error'
Caused by Faraday::ResourceNotFound: the server responded with status 404
from /Users/Paul/.rvm/gems/<gemset>/gems/faraday-0.15.4/lib/faraday/response/raise_error.rb:8:in `on_complete'
I'm using the latest version of Gibbon 3.2.0.
When I byebug'ed inside of the Gibbon::APIRequest.post to see the path that was being generated I see the following:
(byebug) base_api_url
"https://us15.api.mailchimp.com/3.0/"
# For request.segments
(byebug) api_url
"https://us15.api.mailchimp.com/3.0/lists/<list_id>/segments"
# For request.tags
(byebug) api_url
"https://us15.api.mailchimp.com/3.0/lists/<list_id>/tags"
Any help would be much appreciated, as I'm really not sure what I'm doing wrong.
Thank you in advance.
Paul. :)
So for anyone else that might struggle with this, the Gibbon docs don't talk about Segments at all, but do reference tags, which I think is where some of my confusion make from.
request.tags should have been request.segments.
The other issue is that the request cannot be reused, so because I was performing the action inside a loop, by assigning request1 = Gibbon::Request.lists(<list_id>) and trying to use that for the second iteration, Gibbon forwarded the request to the wrong path and returned a 404 error.
Each request needs to be its own instance of Gibbon Request Gibbon::Request. So the following would work:
request = Gibbon::Request
#loop start
request.lists(<list_id>).segments.create(body: { name: "testing", static_segment: [] })
# loop end
Hope that helps someone else.
Gibbon::Request.lists(LIST_ID).segments.create(body: { name: "NAME", static_segment: [] })

Send multiple files using HTTParty

Here is the code which is working using Net::HTTP::Post
request = Net::HTTP::Post.new(url)
...
form_data = [
['attachments[]', File.open('file1.txt')],
['attachments[]', File.open('file2.txt')]
]
request.set_form form_data, 'multipart/form-data'
http.request(request)
Now, I am trying to use httparty like below but it is not working.
body = { attachments: [ File.open('file1.txt'), File.open('file2.txt') ] }
HTTParty.post(url, body: body)
The response I am getting from web service call is below:
#<HTTParty::Response:0x557d7b549f90 parsed_response={"error"=>true, "error_code"=>"invalid_attachment", "error_message"=>"Attachmen
t(s) not found or invalid."}, #response=#<Net::HTTPBadRequest 400 Bad Request readbody=true>, #headers={"server"=>["nginx"], "date"=>[
"Mon, 20 May 2019 07:41:50 GMT"], "content-type"=>["application/json"], "content-length"=>["102"], "connection"=>["close"], "vary"=>["
Authorization"], "set-cookie"=>["c18664e1c22ce71c0c91742fbeaaa863=uv425hihrbdatsql1udrlbs9as; path=/"], "expires"=>["Thu, 19 Nov 1981
08:52:00 GMT", "-1"], "cache-control"=>["no-store, no-cache, must-revalidate", "private, must-revalidate"], "pragma"=>["no-cache", "no
-cache"], "x-ratelimit-limit"=>["60"], "x-ratelimit-remaining"=>["59"], "strict-transport-security"=>["max-age=63072000; includeSubdom
ains;"]}>
It looks like it is not able to read the contents of files. Does HTTParty support this or I need to use some other gem?
Something like this should work, I just tested it, worked for me no problem.
HTTParty.post(url,
body: { attachments: [
File.read('foo.txt'),
File.read('bar.txt')] })
With HTTParty you can pass IO/Files as parameters the same way (multipart is automatically set to true if there's a file in parameters).
But keep in mind that files should be closed after upload, otherwise you may run out of file descriptors before GC collects them:
files = ['file1.txt', 'file2.txt'].map{|fname| File.open(fname) }
begin
HTTParty.post(url, body: { attachments: files })
ensure
files.each(&:close)
end
That should work for you if net/http variant does (and is actually the same as your code).
Other thing to look at is content type detection by filename - because file upload consists of filename, content type and data itself.
Error 400 with "invalid_attachment" you're getting suggests that more probably it's related to content type or other validation on server side (so make sure you're testing with the same files and nothing else changes other than http lib), also check httparty to be a recent version
I've written a test program which sends the same multipart request using both Net::HTTP and HTTParty. Then it compares and prints the request strings so that we can compare them. The only substantive difference between the two requests is that HTTParty attempts to guess and set the Content-Type header (e.g. text/plain for a file named file1.txt), whereas Net::HTTP always uses application/octet-stream.
HTTParty definitely does read the files and send them in the request. So, I suggest you investigate if the server is returning an error due to the Content-Type (maybe the content type in your particular request is not supported).
For your reference, here is the test program and specific results.

404 Bad Request Error while retrieving specific details using Swagger, But working in Postman

I have incorporated Swagger in my application. I am trying to get a individual details through id by hitting the endpoint in swagger. But I am getting the following error
Controller
#RequestMapping(value = "/{clientId}/")
public ResponseEntity<ClientDto> getClientById(#ApiParam(name = "Client Id", required = true) #PathVariable("clientId") UUID clientId){}
Error
Error Code 400
connection: close
content-length: 0
date: Tue, 22 May 2018 12:56:40 GMT
It's working correctly in Postman but I don't know why I am facing this error in swagger. Can somebody help me out from this?
I found out the reason for the issue.
The URL that I am trying to hit is
#RequestMapping(value = "/{clientId}/")
public ResponseEntity<ClientDto> getClientById(#ApiParam(name = "Client Id", required = true) #PathVariable("clientId") UUID clientId){}
I thought the name parameter in the #ApiParam is just used for display purpose in the swagger-UI but now I realized that it should match with value parameter in the #RequestMapping
I have changed the code from
#ApiParam(name="Client Id") to #ApiParam(name="clientId")

Resources