-
Notifications
You must be signed in to change notification settings - Fork 25
Add new endpoints to api-server #427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
thomcom
wants to merge
47
commits into
rapidsai:main
Choose a base branch
from
thomcom:feature/api-server-abstraction
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 28 commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
077a38e
Update for branch-22.08
thomcom 99d76ad
Modify edge mapper to use a table .join, with error handling, instead…
thomcom 7f69939
Remove set_missing_fields_as_nulls workaround.
thomcom adda810
First bits of template for abstract request handling.
thomcom e685652
Add routes/gpu
thomcom 5093b86
Add Series.repeat
thomcom a8f6eb8
Merge branch 'main' into feature/api-server-abstraction
thomcom c302c01
Fix yarn.lock
thomcom d4e721f
Clean up and pass a couple of tests.
thomcom cc3cbab
Adding flexibility to gpu handler.
thomcom 0eca0f4
Fiddling with dynamic dispatch
thomcom ba4c867
Drop the abstract server.
thomcom 1e1758f
Particles endpoints to send data to client.
thomcom 316a6a6
Fix a couple errors.
thomcom 5288d6c
Refactor particles handler to take two routes.
thomcom dee37c8
Add lon/lat filtering to request.
thomcom 8e19053
Tweaking for better filtering, memory safety.
thomcom 60c48de
Drop z, w, r, g, b from particles request.
thomcom e8f6b59
Add logging for timed out currentDataframe.dispose() that causes a 500
thomcom 7e51b88
Pass all tests and add some coverage, particles tests.
thomcom 7401333
Add new test files.
thomcom 4fdc5d7
Write unit tests for particles/get_shader_column in preparation of wr…
thomcom f28d277
Write npoints test and refactor endpoint.
thomcom f371cc7
Add quadtree loading route.
thomcom 54d3d31
Add set_polygons_quadtree and refactor gpu_cache.
thomcom 6b2a082
Set poly types.
thomcom 43aef81
Write quadtree/get_points
thomcom 63aee4d
Update modules/demo/api-server/package.json
thomcom bff76ab
Merge branch 'main' of github.com:rapidsai/node into feature/api-serv…
trxcllnt 6228a61
Update package.json
thomcom bc7f5bd
Drop repeat
thomcom 8d0f953
Merge branch 'feature/api-server-abstraction' of github.com:thomcom/n…
thomcom fe8679f
Really important comma needed to go.
thomcom 25ed45c
Merge branch 'feature/api-server-abstraction' of github.com:thomcom/n…
trxcllnt 1be7b71
Update modules/demo/api-server/routes/gpu/index.js
thomcom f687420
Update modules/demo/api-server/test/routes/graphology.test.js
thomcom 5a5efb5
Update modules/demo/api-server/test/routes/graphology.test.js
thomcom 2d3ccb2
For some reason the route path changed. Upstream changes?
thomcom 7ebef59
Trying to figure out issue with eslint improperly formatting in here.
thomcom ccb42f8
Reorder exports to make clang-format happy.
thomcom a537ad2
Writing docs for api-server
thomcom 695832b
Add docs, refactor gpu calls.
thomcom 4c3e0fb
Quadtree tweaks.
thomcom fa9447c
Add quadtree count endpoint, plus clean up schema.
thomcom b174028
Endpoint to return just the first n points.
thomcom 6b23188
Next and clear endpoints.
thomcom 230d6a3
Fix bug with error in next endpoint.
thomcom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| // Copyright (c) 2022, NVIDIA CORPORATION. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| const {Utf8String, Int32, Uint32, Float32, DataFrame, Series, Float64} = require('@rapidsai/cudf'); | ||
| const {RecordBatchStreamWriter, Field, Vector, List} = require('apache-arrow'); | ||
| const Path = require('path'); | ||
| const {promisify} = require('util'); | ||
| const Fs = require('fs'); | ||
| const Stat = promisify(Fs.stat); | ||
| const fastifyCors = require('@fastify/cors'); | ||
| const fastify = require('fastify')({logger: true}); | ||
|
|
||
| const arrowPlugin = require('fastify-arrow'); | ||
| const gpu_cache = require('../../util/gpu_cache.js'); | ||
| const root_schema = require('../../util/schema.js'); | ||
|
|
||
| module.exports = async function(fastify, opts) { | ||
| fastify.register(arrowPlugin); | ||
| fastify.register(fastifyCors, {origin: '*'}); | ||
| fastify.decorate('cacheObject', gpu_cache.cacheObject); | ||
| fastify.decorate('getData', gpu_cache.getData); | ||
| fastify.decorate('readCSV', gpu_cache.readCSV); | ||
| fastify.decorate('publicPath', gpu_cache.publicPath); | ||
|
|
||
| const get_schema = { | ||
| logLevel: 'debug', | ||
| schema: { | ||
| response: { | ||
| 200: { | ||
| type: 'object', | ||
| properties: | ||
| {success: {type: 'boolean'}, message: {type: 'string'}, params: {type: 'string'}} | ||
| } | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| fastify.get('/', {...get_schema, handler: () => root_schema['gpu']}); | ||
|
|
||
| fastify.route({ | ||
| method: 'POST', | ||
| url: '/DataFrame/readCSV', | ||
| schema: {}, | ||
| handler: async (request, reply) => { | ||
| let message = 'Error'; | ||
| let result = {'params': request.body, success: false, message: message}; | ||
| try { | ||
| const path = Path.join(fastify.publicPath(), request.body.filename); | ||
| const stats = await Stat(path); | ||
| const message = 'File is available'; | ||
| const currentDataFrame = await fastify.getData(request.body.filename); | ||
| if (currentDataFrame !== undefined) { | ||
| console.log('Found existing dataframe.'); | ||
| console.log(request.body); | ||
| console.log(currentDataFrame); | ||
| currentDataFrame.dispose(); | ||
| } | ||
| const cacheObject = await fastify.readCSV({ | ||
| header: 0, | ||
| sourceType: 'files', | ||
| sources: [path], | ||
| }); | ||
| const name = request.body.filename; // request.body.replace('/\//g', '_'); | ||
thomcom marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| await fastify.cacheObject(name, cacheObject); | ||
| result.success = true; | ||
| result.message = 'CSV file in GPU memory.'; | ||
| result.statusCode = 200; | ||
| await reply.code(200).send(result); | ||
| } catch (e) { | ||
| result.message = e.message; | ||
| if (e.message.search('no such file or directory') !== -1) { | ||
| await reply.code(404).send(result); | ||
| } else { | ||
| await reply.code(500).send(result); | ||
| } | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| fastify.route({ | ||
| method: 'GET', | ||
| url: '/get_column/:table/:column', | ||
| schema: {querystring: {table: {type: 'string'}, 'column': {type: 'string'}}}, | ||
| handler: async (request, reply) => { | ||
| let message = 'Error'; | ||
| let result = {'params': JSON.stringify(request.params), success: false, message: message}; | ||
| const table = await fastify.getData(request.params.table); | ||
| if (table == undefined) { | ||
| result.message = 'Table not found'; | ||
| await reply.code(404).send(result); | ||
| } else { | ||
| try { | ||
| const name = request.params.column; | ||
| const column = table.get(name); | ||
| const newDfObject = {}; | ||
| newDfObject[name] = column; | ||
| const result = new DataFrame(newDfObject); | ||
| const writer = RecordBatchStreamWriter.writeAll(result.toArrow()); | ||
| await reply.code(200).send(writer.toNodeStream()); | ||
| } catch (e) { | ||
| if (e.message.search('Unknown column name') != -1) { | ||
| result.message = e; | ||
| await reply.code(404).send(result); | ||
| } else { | ||
| await reply.code(500).send(result); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.