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

@golem-sdk/task-executor

v2.1.0

Published

A golem-js based library allowing running computation tasks on Golem, designed for batch map-reduce like scenarios

Downloads

165

Readme

Task Executor

GitHub npm node-current npm type definitions

What's TaskExecutor?

TaskExecutor facilitates building of applications that utilize the computational power of the Golem Network in a transparent and efficient manner. It is a @golem-sdk/golem-js based library allowing running computation tasks, designed for batch map-reduce like scenarios.

With TaskExecutor, developers can focus on implementing their computational tasks without delving into the details of communicating with the Golem Network or managing modules such as payments or market.

System requirements

To use task-executor, it is necessary to have yagna installed, with a recommended minimum version of v0.15.0. Yagna is a service that communicates and performs operations on the Golem Network, upon your requests via the SDK. You can follow these instructions to set it up.

Simplified installation steps

In order to get started and on Golem Network and obtain test GLM tokens (tGLM) that will allow you to build on the test network, follow these steps:

Join the network as a requestor and obtain test tokens

# Join the network as a requestor
curl -sSf https://join.golem.network/as-requestor | bash -

# Start the golem node on your machine,
# you can use `daemonize` to run this in background
yagna service run

# IN SEPARATE TERMINAL (if not daemonized)
# Initialize your requestor
yagna payment init --sender --network holesky

# Request funds on the test network
yagna payment fund --network holesky

# Check the status of the funds
yagna payment status --network holesky

Obtain your app-key to use with TaskExecutor

If you don't have any app-keys available from yagna app-key list, go ahead and create one with the command below. You will need this key in order to communicate with yagna from your application via golem-js.You can set it as YAGNA_APPKEY environment variable.

yagna app-key create my-golem-app

Installation

@golem-sdk/task-executor is available as a NPM package.

npm install @golem-sdk/task-executor

Building

To build a library available to the Node.js environment:

npm run build

This will generate production code in the dist/ directory ready to be used in your Node.js or browser applications.

Usage

Hello World example

import { TaskExecutor } from "@golem-sdk/task-executor";
import { pinoPrettyLogger } from "@golem-sdk/pino-logger";

(async function main() {
  const executor = await TaskExecutor.create({
    logger: pinoPrettyLogger({ level: "info" }),
    demand: {
      workload: {
        imageTag: "golem/alpine:latest",
      },
    },
    market: {
      rentHours: 0.5,
      pricing: {
        model: "linear",
        maxStartPrice: 0.5,
        maxCpuPerHourPrice: 1.0,
        maxEnvPerHourPrice: 0.5,
      },
    },
  });
  try {
    await executor.run(async (exe) => console.log((await exe.run("echo 'Hello World'")).stdout));
  } catch (error) {
    console.error("Computation failed:", error);
  } finally {
    await executor.shutdown();
  }
})();

More examples

The examples directory in the repository contains various usage patterns for the TaskExecutor. You can browse through them and learn about the recommended practices. All examples are automatically tested during our release process.

In case you find an issue with the examples, feel free to submit an issue report to the repository.

You can find even more examples and tutorials in the JavaScript API section of the Golem Network Docs.

Supported environments

The library is designed to work with LTS versions of Node (starting from 18) and with browsers.

Documentation

Debugging

The library uses the debug package to provide debug logs. To enable them, set the DEBUG environment variable to task-executor:* to see the related log lines. For more information, please refer to the debug package documentation.

Testing

Read the dedicated testing documentation to learn more about how to run tests of the library.

Contributing

It is recommended to run unit tests and static code analysis before committing changes.

npm run lint
# and
npm run format

See also