npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@cocalc/compute

v0.1.6

Published

CoCalc remote compute provider -- connects to project and provides remote compute

Downloads

24

Readme

@cocalc/compute

Goal

The minimal goal of this package is to connect from a nodejs process to a cocalc project, open a Jupyter notebook sync session, and provide the output. I.e., instead of the project itself running a kernel and providing output, the kernel will be provided by whatever client is running this @cocalc/compute package!

Concern: I want this package to remain lightweight if at all possible, so it's fast to install and uses little space. Also, we eventually plan to run a variant of it in a web browser, which is another reason to keep it small. On the other hand, to offer a really useful Jupyter kernel environment, this will probably be part of a big Docker container or something.

This is used by cocalc-compute-docker.

Build

pnpm install
pnpm build

Examples of where to run this

  • A powerful computer (possibly with a GPU?) and a Jupyter kernel installed
  • A web browser providing Python code evaluation via WebAssembly.
    • You point a web browser on some random powerful compute you have at cocalc
    • You (and collabs) can then use this power from cocalc on your laptop.
  • A web browser with WebGPU providing PyTorch (say).

The filesystem

The filesystem from the project will get mounted via WebSocketFS. This will initially only be for FUSE, but later could also use WASI in the browser.

Status

This is currently an unfinished work in progress. We will focus mostly on the powerful Linux host for @cocalc/compute first, since it's also what we need to make cocalc vastly more useful to people.

We are also focusing initially on a single Jupyter notebook. However, this could also be useful for terminals and many other things.

Try It Out

Define the following three environment variables:

export API_KEY="sk-gEWEutsR9tK9q2Dd000002"
export PROJECT_ID="34ce85cd-b4ad-4786-a8f0-67fa9c729b4f"
export IPYNB_PATH="Untitled.ipynb"
  • API_KEY -- You make this in project settings. It is specific to the project you want to connect to on https://cocalc.com:
  • PROJECT_ID -- The project id is in the URL or project settings
  • IPYNB_PATH -- The IPYNB_PATH is the path of a Jupyter notebook. You should have that notebook open in your browser.

After setting the above variables, you can FUSE WebSocketFS mount the home directory of the project and switch to using your compute for that kernel as follows:

cd /cocalc/src/packages/compute
node ./bin/kernel.js

Tweaks

Do this if you want to see VERY verbose logs:

export DEBUG=*
export DEBUG_CONSOLE=yes

If you're using a different server, these could be relevant:

export BASE_PATH="/"
export API_BASE_PATH="/"
export API_SERVER="https://cocalc.com"

E.g., for local dev these might be

export BASE_PATH='/ab3c2e56-32c4-4fa5-a3ee-6fd980d10fbf/port/5000'
export API_SERVER='http://localhost:5000'
export API_BASE_PATH='/ab3c2e56-32c4-4fa5-a3ee-6fd980d10fbf/port/5000'

Mounting just the project home directory

Mount the project's HOME directory at /tmp/project by running this code in nodejs after setting all of the above environment variables.

await require("@cocalc/compute").mountProject({
  project_id: process.env.PROJECT_ID,
  path: "/tmp/project",
});
0;

Jupyter

You should open the notebook Untitled.ipynb on cocalc.com. Then set all the above env variables in another terminal and run the following code in node.js. Running of that Jupyter notebook will then switch to your local machine.

await require("@cocalc/compute").jupyter({
  project_id: process.env.PROJECT_ID,
  path: "Untitled.ipynb",
  cwd: "/tmp/project",
});
0;

Terminal

You should open the notebook Untitled.ipynb on cocalc.com. Then set all the above env variables in another terminal and run the following code in node.js. Running of that first (if you split frame) command line terminal will then switch to your local machine.

await require("@cocalc/compute").terminal({
  project_id: process.env.PROJECT_ID,
  path: "term.term",
  cwd: "/tmp/project",
});
0;