Giter Club home page Giter Club logo

paperspace-node's Introduction


Note Heads up! This project has been deprecated. Please use our new Paperspace CLI! !


Paperspace CORE API (v0.1.17)

image

The Paperspace CORE API is the official devkit for automating your Paperspace account. It is currently available through the use of standard HTTP requests as well as a JavaScript client for Node.js. We plan to offer other languages and integrations in the future. This repository includes:

Getting started

Installation

Install the paperspace-node package from npm

For this option you will need Node.js v8.12.0 or later. Check your Node.js version by running node -v. Node.js comes bundled with npm, the Node.js package management tool, which you'll use to install this package. Install the package using the -g option as follows:

$ npm install -g paperspace-node

We recommend installing the paperspace-node package globally so that the paperspace command will be available on your command line everywhere on your system. If you want to make it available only within an individual Node.js project, you can install it for use only in the current directory by omitting the -g flag.

Setup a Paperspace Account

Before you can use this tool, you'll need a Paperspace account. You'll use this account to obtain a Paperspace API key.

After creating your Paperspace account check your email to confirm your account before logging in.

Obtaining an API key

Once you have created a Paperspace Account you will need to obtain a API key.

Your API key allows you to access the Paperspace CORE API via conventional HTTP requests or from within apps that you develop.

There is currently only one way to create an API key: from within the section of your Paperspace console.

Obtain an API key via your Paperspace Console

You can create an API key from within your Paperspace console under the API section. Login to your Paperspace console, visit your team settings page, locate the API section, and follow the instructions to create a new API key.

image

You'll use the API keys generated here to authenticate your requests.

Usage

You can interact with CORE API in two ways: by using an HTTP client of your choice and the Paperspace API HTTP endpoints or programmatically from within a Javascript Node.js application.

Authentication

For authenticated requests, the Paperspace-Node module will look for an api key:

An environment variable: PAPERSPACE_API_KEY. Example:

$ export PAPERSPACE_API_KEY=1ba4f98e7c0...
$ paperspace machines show --machineId "ps123abc"

See the previous section on Obtaining an API key for more information.

Programmatic access via Paperspace-Node

You can use the Paperspace APIs programmatically by creating a Javascript Nodejs application and importing the Paperspace-Node module.

We'll be illustrating all examples using ES5 syntax and the CommonJS module format. For other systems like Asynchronous Module Definition, consider using a bundler such as Browserify.

First install the paperspace-node package in your project directory using:

$ npm install paperspace-node

Within your node.js app you can import the package with:

var paperspace_node = require('paperspace-node');

Then create an instance of the client, optionally passing in your API key:

var paperspace = paperspace_node({
  apiKey: '1ba4f98e7c0...' // <- paste your api key here
});

-or-

var paperspace = paperspace_node();

You can get the paperspace-node version programmatically via the VERSION attribute:

var version = paperspace_node.VERSION;

Calling the API programmatically

All of the methods are namespaced by category ("machines.create" or "invoices.show") and have the same function signature. For example:

paperspace.machines.create({
  // parameters
}, function (err, res) {
  // callback
});

That is, the first argument is parameters object, and the second is a error-first callback function.

For information on all the methods available, see the API documentation.

Paperspace API HTTP endpoints

If you'd prefer to build your own client instead of using the Paperspace-Node library, you can use the Paperspace API HTTP endpoints directly, as described in the API documentation.

Address for the Paperspace API HTTP endpoints

If making HTTP requests directly to the Paperspace API endpoints use the following address for each request: https://api.paperspace.io

Authenticating to the Paperspace API

In order to use the HTTP API directly you must specify the x-api-key header with the value of your API key.

Other clients

If you've created an API client in a language other than JavaScript, please let us know at [email protected] and we will link to it here.

Sample Apps

See the directory samples for a few simple samples of using the node API, and the CLI in a bash script. Note: the jq tool is used in the bash sample for parsing JSON data.

Contributing

We welcome contributions to this project. Please adhere to the established coding conventions within the project and submit changes using pull requests.

Additional information for developers is here: developers.md

Bugs / Support / Troubleshooting

For bugs with the API client, command-line utility, or the HTTP API, please file tickets using GitHub Issues on this repo. We'll do our best to respond as quickly as we can. Keep in mind that Paperspace is a small team and you may need to allow up to a week for a response.

Other issues, such as those related to your Paperspace account, your team or team members, billing, or technical issues with your Paperspace machines should be directed to [email protected].

Security

Think you've discovered a security flaw or exploit? Please contact us directly at [email protected] and we will respond as quickly as we can.

Disclaimer

Use the Paperspace API with care. This tool is provided as-is (please see our LICENSE). Know that many actions provided via our public API can result in billing charges for Paperspace services. Please be aware of Paperspace's billing policies before performing any of these actions; you'll see charges reflected in your invoice at the end of the month. Some actions, such as deactivating machines, are irreversible, resulting in permanent loss of data. Paperspace cannot recover lost data such as mistakenly deleted account information, and may only be able to give limited assistance if an action is performed mistakenly. API access will be disabled for accounts not in good standing. Keeping your account credentials secret is your responsibility. You may only use Paperspace's API to store, retrieve, query, serve, and execute content that is owned, licensed or lawfully obtained by you.

License

This project is open source, under the ISC license. See LICENSE.txt.

Copyright

Copyright 2021 Paperspace Co. - All Rights Reserved

paperspace-node's People

Contributors

briankmatheson avatar colin-welch avatar dandruszak avatar dependabot[bot] avatar dkobran avatar dte avatar exdx avatar jaredscheib avatar mlunoe avatar paperspace-philip avatar robby-robby avatar sanfilip avatar tallyw00d avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

paperspace-node's Issues

NODE_ENV mismatch

Hello there!

I'm developing an app with electron and I have my own custom environment variables.
Running any request to the paperspace api with my own NODE_ENV creates an error in line 14 of client.js:

var nodeEnv = processEnv.NODE_ENV;
var config = configInfo[nodeEnv || 'production'];

Throwing this:

TypeError: Cannot read property 'host' of undefined

because I don't have a custom .host variable in my environment variable.

I got to pass the error by specifying production always:

var config = configInfo['production'];

I'm not sure if this is the intended behavior. If not, I can submit a PR to fix this

Expose ports and create public IP

Following a brief discussion with @dte, having a method in the API to expose ports will be useful. I'm creating a public server and need to expose specific ports when the machine is started. I'm using sudo ufw allow 33100, but it would be nice to have them programmatically setup up when booting the machine.

Also, having a way to enable or set up the public address will be nice too!

Paperspace Startup Script Not Working

`var paperspace_node = require("paperspace-node");

var paperspace = paperspace_node({
apiKey: API_KEY, // <- paste your api key here
});

paperspace.scripts.create
(
{
scriptName: "Server Startup Script",
scriptFile: "/home/paperspace/game-server/linux-build/startup.sh",
scriptDescription: "Runs startup.sh",
machineId: MACHINE_ID
},
function (err, res) {
// handle error or result
console.log(res);
console.log(err);
}
);`

This is my node script that makes a paperspace script when launched. The script is confirmed to be created because when I do "paperspace scripts list", it exists. My problem is when I restart the machine. The startup script that has been created won't launch. I don't really know why it won't work. I followed the documents step by step.

Latest version has vulnerable dependency

as per npm audit using [email protected]

yargs-parser  <=5.0.0
Severity: moderate
yargs-parser Vulnerable to Prototype Pollution - https://github.com/advisories/GHSA-p9pc-299p-vxgp
No fix available
node_modules/paperspace-node/node_modules/yargs-parser
  yargs  4.0.0-alpha1 - 7.0.0-alpha.3 || 7.1.1
  Depends on vulnerable versions of yargs-parser
  node_modules/paperspace-node/node_modules/yargs
    paperspace-node  *
    Depends on vulnerable versions of yargs
    node_modules/paperspace-node

Is paperspace-node supposed to work in-browser?

Based on the Paperspace API docs

JavaScript API client (for Node.js and web browsers)

I expected that using the paperspace-node module (via ps_promise in my case) would work in a create-react-app-bootstrapped application.

However, I've hit a few problem, and they look suspiciously like assumptions of running on a node.js stack:

  • [lib/projectConfig.js] uses fs.existsSync which doesn't appear to be available.
  • [lib/method.js] uses readlineSync only when global.paperspace_cli is set, but always imports it.
  • [lib/jobs/create.js] uses archiver which eventually hits fs.ReadStream being missing.

isaacs/node-graceful-fs#121 (comment) suggests that last one might be a bug in graceful-fs, but perhaps it's a problem somewhere else.

Before I sink much more time into trying to fix these things properly, is this even a valid-use case? Is the 'web browsers' mention on the page an oversight, or is there something I need to fix about my environment to make this work?

paperspace command not found on npm install

Hi - I'm leading a course on machine learning and have successfully installed paperspace on my own machine, but I need to test student access on the school's laptops, and cannot get the cli working. Due to security restraints, I can only do an npm install paperspace-node (no global, no pip, and the binary just downloads as a text document that I cannot execute).

But after successful npm init, npm install, if I attempt to run paperspace ... anything, I get command not found paperspace. Would this be a security constraint? Or a difference between a global install and a local that means I need to do something different to invoke the CLI?

screen shot 2018-10-28 at 1 08 30 pm

screen shot 2018-10-28 at 1 16 05 pm

screen shot 2018-10-28 at 1 17 20 pm

Error while trying to create script

Hi,

I'm trying to create script on my machine. According to https://paperspace.github.io/paperspace-node/scripts.html#.create I've created sample code

paperspace.scripts.create({
    scriptName: 'Run docker at start',
    scriptFile: 'startup.sh', 
    scriptDescription: 'A startup script', // optional
    isEnabled: true, // optional
    runOnce: false, // optional
    machineId: machineId, // optional
}, function(err, res) {
    console.log(res);
});

and what I'm getting is

{ error:
   { name: 'Error',
     status: 404,
     message: 'script not uploded - temporary' } }

Could you explain this, please?
Of course other requests are working ( e.g. I can start and stop machines using paperspace-node)

contribution: Homebrew paperspace CLI formula

To install and upgrade (or uninstall) the Paperspace CLI binary on macOS, I have made a Homebrew (mac package manager) tap and formula "paperspace-cli":
https://github.com/itsayellow/homebrew-paperspace

I would be happy to share with a wider community, so if you want to put this in your documentation, it would be much appreciated.

I tried to get the Homebrew organization to add the paperspace-cli formula to homebrew-core, but it was judged "not notable enough": Homebrew/homebrew-core#38536

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.