Skip to content
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

Update Readme files #432

Merged
merged 4 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"default": true,
"MD013": false,
"MD034": false
}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- Remove HTTP Timeout, Add Context Timeout on Collections [#422](https://github.com/hypermodeinc/modus/pull/422)
- Add Modus AssemblyScript SDK [#423](https://github.com/hypermodeinc/modus/pull/423)
- Add models to Modus AssemblyScript SDK [#428](https://github.com/hypermodeinc/modus/pull/428)
- Update Readme files [#432](https://github.com/hypermodeinc/modus/pull/432)

## 2024-10-02 - Version 0.12.7

Expand Down
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Contributing to Modus

TODO
224 changes: 40 additions & 184 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,209 +1,65 @@
<a href="https://discord.hypermode.com" >
<img height=20 src="https://img.shields.io/discord/1267579648657850441" />
</a>
<!-- markdownlint-disable first-line-heading -->
[![chat](https://img.shields.io/discord/1267579648657850441)](https://discord.gg/NJQ4bJpffF)

# Modus

## TODO - rewrite this whole file in the context of Modus
Modus is an open-source, serverless framework for building intelligent functions and APIs, powered by WebAssembly.

This repository contains the source code for the _Hypermode Runtime_.
The Runtime loads and executes _plugins_ containing _Hypermode Functions_.
This repository contains the Modus source code, including the Modus runtime, SDKs, CLI, and introductory examples.

To get started with Hypermode Functions written in AssemblyScript, visit the
`functions-as` repository.
_Please note that prior to version 0.13.0, Modus was simply referred to as "Hypermode". Please bear with us if you find name conflicts while we are in transition!_

## Command Line Parameters
## Getting Started

When starting the Runtime, you can use the following command line parameters:
To get started using Modus, please refer to [the Modus docs](https://docs.hypermode.com/modus) site.

- `--port` - The HTTP port to listen on. Defaults to `8686`.
- `--modelHost` - The base DNS of the host endpoint to the model server.
- `--storagePath` - The path to a directory used for local storage.
- Linux / OSX default: `$HOME/.hypermode`
- Windows default: `%APPDATA%\Hypermode`
- `--useAwsSecrets` - Use AWS Secrets Manager for API keys and other secrets.
- `--useAwsStorage` - Use AWS S3 for storage instead of the local filesystem.
- `--s3bucket` - The S3 bucket to use, if using AWS storage.
- `--s3path` - The path within the S3 bucket to use, if using AWS storage.
- `--refresh` - The refresh interval to reload any changes. Defaults to `5s`.
- `--jsonlogs` - Use JSON format for logging.
## Open Source

_Note: You can use either `-` or `--` prefixes, and you use either a space or `=` to provide values._
Modus is developed by [Hypermode](https://hypermode.com/) as an open-source project, integral but independent from Hypermode.
We welcome external contributions! See the [CONTRIBUTING.md](./CONTRIBUTING.md) file if you would like to get involved!

## Environment Variables
## Programming Languages

The following environment variables are used by the Hypermode Runtime:
Since Modus is based on WebAssembly, you can write Modus apps in various programming languages.
Each language offers the full capabilities of the Modus framework.

- `ENVIRONMENT` - The name of the environment, such as `dev`, `stage`, or `prod`. Defaults to `dev` when not specified.
- `NAMESPACE` - Used in non-dev (ie. stage/prod) environments to retrieve the Kubernetes namespace for the Hypermode backend.
- `HYPERMODE_METADATA_DB` - Used in dev environment only, to set a connection string to a local Postgres database to use for Hypermode metadata.
Currently, the supported languages you may choose from are:

### Local Secrets
- [AssemblyScript](https://www.assemblyscript.org/) - A TypeScript-like language designed for WebAssembly.
- If you are primarily used to writing front-end web apps, you'll feel at home with AssemblyScript.

When running locally, in addition to the above, secrets are passed by environment variable using the following convention:
- [Go](https://go.dev/) - A general-purpose programming language originally designed by Google.
- If you are primarily used to writing back-end apps, you'll likely prefer to use Go.

```
HYPERMODE_<HOST_NAME>_<SECRET_NAME>
```
Additional programming languages may be supported in the future.

- Substitute `<HOST_NAME>` for the upper-cased name of the model, replacing hyphens (`-`) with underscores (`_`).
- Substitute `<SECRET_NAME>` for the upper-cased name of the secret variable used in the manifest.
## Hosting

For example, if the manifest contains the host entry:
We have designed Hypermode to be the best place to run your Modus app.
Hypermode hosting plans include features you might expect, such as professional support, telemetry, and high availability.
They also include specialty features such as model hosting that are purposefully designed to work in tandem with Modus apps.
Thus, for the best experience, please consider hosting your Modus apps on Hypermode.
See [hypermode.com](https://hypermode.com/) for details and pricing.

```json
"my-api": {
"endpoint":"https://api.example.com/",
"headers": {
"Authorization": "Bearer {{AUTH_TOKEN}}"
}
},
```
As Modus is a free, open-source framework, you’re welcome to run your Modus apps on your own hardware or on any
hosting platform that meets your needs. However, please understand that we cannot directly support issues related
to third-party hosting.

... then the corresponding environment variable name would be `HYPERMODE_MY_API_AUTH_TOKEN`.
The value of that environment variable would be used as the bearer token for any requests to that host.
## Support

### Using a `.env` file
Hypermode paid hosting plans include standard or premium support that covers both Hypermode and Modus, with response-time guarantees.
Click the _support_ link after signing in to Hypermode, or email [email protected] for paid support if you are a Hypermode customer.

While environment variables can be set through traditional mechanisms, they can also (optionally)
be set in a file called `.env`, placed in the plugins path. The file should be a simple list of
key/value pairs for each environment variable you want to set when the Runtime is loaded.
For free community-based support (without a response-time guarantee), or if you'd just like to share your experiences with
Modus or Hypermode, please chat with us on [Discord](https://discord.gg/NJQ4bJpffF).
We'd be happy to hear from you!

For example:
If you believe you have found a bug in Modus, please file a [Github issue](https://github.com/hypermodeinc/modus/issues)
so we can triage the problem and route it to our engineers as efficiently as possible.

```
HYPERMODE_FOO=abc123
HYPERMODE_BAR=xyz456
```
## License

## Building the Runtime
Modus and its components are Copyright 2024 Hypermode Inc., and licensed under the terms of the Apache License, Version 2.0.
See the [LICENSE](./LICENSE) file for a complete copy of the license.

Ensure that you have Go installed in your dev environment.
The required minimum major version is specified in the [go.mod](./go.mod) file.
It is recommended to use the latest patch version available, and keep current.

Then, you can do any of the following:

- You can run directly from source code:

```sh
go run .
```

- You can compile the source code and run the output:

```sh
go build
./hypruntime
```

- You can run and debug the source code in VS Code, using the VS Code debugger.

## Docker Setup

To build a Docker image for the Hypermode Runtime:

```sh
docker build -t hypermode/runtime .
```

When running the image via Docker Desktop, keep in mind:

- You may wish to give the container a specific name using `--name`.
- Port `8686` should be exposed.
- If using local storage, you'll need to map the container's `/root/.hypermode` folder to your own `~/.hypermode` folder.
- You may need to pass command line parameters and/or set environment variables.

For example:

```sh
docker run --name hypruntime \
-p 8686:8686 \
-v ~/.hypermode:/root/.hypermode hypermode/runtime
```

_Note, if you have previously created a container with the same name, then delete it first with `docker rm hypruntime`._

## AWS Setup

If configured to do so, the Hypermode Runtime may access AWS resources.
If you are debugging locally, set up an AWS profile.

```sh
export AWS_PROFILE=sandbox
```

Declare the `sandbox` profile in `~/.aws/config` as follows:

```ini
[profile sandbox]
sso_start_url = https://d-92674fec42.awsapps.com/start#
sso_region = us-west-2
sso_account_id = 436061841671
sso_role_name = AWSPowerUserAccess
region = us-west-2
```

Then run `aws sso login --profile sandbox` to login to the profile.

After SSO login you can start the Runtime, either from the VS Code debugger
using the `Hypermode Runtime (AWS)` launch profile, or from the command line as follows:

```sh
export AWS_SDK_LOAD_CONFIG=true
export AWS_PROFILE=sandbox
./hypruntime \
--useAwsSecrets \
--useAwsStorage \
--s3bucket=sandbox-runtime-storage \
--s3path=shared
```

You can omit the exports if the environment variables are already set.
You can also use any S3 bucket or path you like. If a path is not specified, the Runtime will look for files in the root of the bucket.

_The shared sandbox is intended for temporary use. In production, each customer's backend gets a separate path within a single bucket._

## Using Model Inference History Locally

To set up the model inference history table, run the following command, which will start a local postgres instance.

```sh
cd tools/local
docker-compose up
```

Next, you will need to apply the database schema using the [golang-migrate](https://github.com/golang-migrate/migrate) utility.

On MacOS, you can install this utility with the following:

```sh
brew install golang-migrate
```

Then, you can apply the migration as follows:

```sh
export POSTGRESQL_URL='postgresql://postgres:postgres@localhost:5433/my-runtime-db?sslmode=disable'
migrate -database ${POSTGRESQL_URL} -path db/migrations up
```

Now any model inference will be logged in the `inferences` table in the `my-runtime-db` database.

## Unit Testing

Unit tests are created using Go's [built-in unit test support](https://go.dev/doc/tutorial/add-a-test).

To run all tests in the project:

```sh
go test ./...
```

Or, you can just run tests in specific folders. For example:

```sh
go test ./functions
```

Tests can also be run from VS Code's Testing panel, and are run automatically for pull requests.
If you have any questions about Modus licensing, or need an alternate license or other arrangement, please contact us at [email protected].
8 changes: 8 additions & 0 deletions runtime/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Modus Runtime

This directory contains the source code for the Modus runtime,
which is responsible for loading and executing your Modus app.

Unless you are contributing to the Modus project, you will not need to download this code directly.
Instead, a compiled platform-specific binary of the Modus runtime will be downloaded and installed
in your development environment by the Modus CLI, or used when hosting a Modus app in production.
6 changes: 6 additions & 0 deletions sdk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Modus SDKs

This directory contains the source code for the SDKs of each language that you can write Modus apps in.

Typically, you will not need to download this code directly, as the SDK will automatically be installed when
you create a new Modus project. However, you may wish to explore the example projects in each SDK.
Loading