algorithmiaio / algorithmia-nodejs Goto Github PK
View Code? Open in Web Editor NEWAlgorithmia node.js client library
Algorithmia node.js client library
I am trying to make a mobile app with ionic3( based on angular4). it could also be a progressive web app (PWA). When call algo node api, I get following CORS error,
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8100' is therefore not allowed access. The response had HTTP status code 404.
While doing the algorithm DeepFilter
var client = algorithmia(process.env.ALGORITHMIA_API_KEY);
var input={ images: [ 'https://en.wikipedia.org/wiki/Nikola_Tesla#/media/File:N.Tesla.JPG' ],
savePaths: [ 'data://.my/DeepFilterTest/stylized_image.jpg' ],
filterName: 'space_pizza' }
client.dir('data://.my/DeepFilterTest/').create((res)=>console.log(res))
I get
ReferenceError: headers is not defined
at Dir.create (/myProject/node_modules/algorithmia/lib/data.js:135:100)
at repl:1:32
at sigintHandlersWrap (vm.js:32:31)
at sigintHandlersWrap (vm.js:96:12)
at ContextifyScript.Script.runInContext (vm.js:31:12)
at REPLServer.defaultEval (repl.js:308:29)
at bound (domain.js:280:14)
at REPLServer.runBound [as eval] (domain.js:293:12)
at REPLServer.<anonymous> (repl.js:489:10)
at emitOne (events.js:101:20)
Steps to reproduce:
Algorithmia.client(...).algo("demo/hello").pipe("foo");
No matter what algorithm I try to call from a nodejs app, I get the following TypeError.
error:
/XXXX/XXXXX/node_modules/algorithmia/lib/algorithmia.js:75
if (ct.startsWith('application/json')) {
^
TypeError: undefined is not a function
at IncomingMessage.<anonymous> (/XXXX/XXXXX/node_modules/algorithmia/lib/algorithmia.js:75:16)
at IncomingMessage.emit (events.js:129:20)
at _stream_readable.js:908:16
at process._tickCallback (node.js:355:11)
call:
var algorithmia = require("algorithmia");
var client = algorithmia('API KEY');
client.algo("algo://demo/Hello/0.1.1")
.pipe("HAL 9000")
.then(function(response) {
console.log(response.get());
});
Have tried rotating API keys, spinning up a fresh node app, and trying a bunch of different algorithms, but no dice.
Results with a .then
are generally thought to be promises. The issue here is that the result isn't a real promise and doesn't conform the promises A+ spec.
This becomes a problem for example if you want to handle an exception you might assume that you can attach a .catch()
to the result.
I'm addressing some client timeout issue in another client and comparing with how existing clients work. I believe nodejs defaults to a 120s client timeout and I didn't spot any code overriding that in this client.
Filing this to followup with testing on a >2min algorithm (and fixing if it times out)
File
has putString
, putJson
, getString
and getJson
methods, but no way to work with binary files. (The algorithm pipe
method does support binary input/output)
IMO, we should add put
that works with strings and byte Buffers like most other clients. I think putString
and putJson
should be deprecated in a future release. putString
becomes redundant of put
, and putJson
is more confusing than helpful (if it takes JSON input, it's redundant of putString
, if it takes an object, it's the opposite of the pipeJson
method). In all cases, put(JSON.stringify(myobject))
is simple and obvious.
We could have separate getString
and getBytes
, but I'm inclined to push for future deprecation of those behind a get
and probably getFile
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.