-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into jairus/hyp-2207-create-hypermode-cli
- Loading branch information
Showing
380 changed files
with
6,159 additions
and
1,235 deletions.
There are no files selected for viewing
This file contains 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,32 @@ | ||
--- | ||
name: Bug report | ||
about: Create a report to help us improve | ||
title: '' | ||
labels: bug | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Describe the bug** | ||
A clear and concise description of what the bug is. | ||
|
||
**To Reproduce** | ||
Steps to reproduce the behavior: | ||
1. Go to '...' | ||
2. Click on '....' | ||
3. Scroll down to '....' | ||
4. See error | ||
|
||
**Expected behavior** | ||
A clear and concise description of what you expected to happen. | ||
|
||
**Screenshots** | ||
If applicable, add screenshots to help explain your problem. | ||
|
||
**Environment** | ||
- OS: [e.g. macOS, Windows, Ubuntu] | ||
- Language [e.g. AssemblyScript, Go] | ||
- Version [e.g. v0.xx] | ||
|
||
**Additional context** | ||
Add any other context about the problem here. |
This file contains 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,20 @@ | ||
--- | ||
name: Feature request | ||
about: Suggest an idea for this project | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Is your feature request related to a problem? Please describe.** | ||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] | ||
|
||
**Describe the solution you'd like** | ||
A clear and concise description of what you want to happen. | ||
|
||
**Describe alternatives you've considered** | ||
A clear and concise description of any alternative solutions or features you've considered. | ||
|
||
**Additional context** | ||
Add any other context or screenshots about the feature request here. |
This file contains 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,10 @@ | ||
# Description | ||
Please explain the changes you made here. | ||
|
||
# Checklist | ||
- [ ] Code compiles correctly and linting passes locally | ||
- [ ] Tests for new functionality and regression tests for bug fixes added | ||
- [ ] Documentation added or updated | ||
- [ ] Entry added to the `CHANGELOG.md` file describing and linking to this PR | ||
|
||
Thank you for your contribution to the Modus project! |
This file contains 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,5 @@ | ||
{ | ||
"default": true, | ||
"MD013": false, | ||
"MD034": false | ||
} |
This file contains 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 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 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,3 @@ | ||
# Contributing to Modus | ||
|
||
TODO |
This file contains 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 |
---|---|---|
@@ -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]. |
This file contains 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 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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
/* | ||
* Copyright 2024 Hypermode, Inc. | ||
* Copyright 2024 Hypermode Inc. | ||
* Licensed under the terms of the Apache License, Version 2.0 | ||
* See the LICENSE file that accompanied this code for further details. | ||
* | ||
* SPDX-FileCopyrightText: 2024 Hypermode, Inc. <[email protected]> | ||
* SPDX-FileCopyrightText: 2024 Hypermode Inc. <[email protected]> | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
|
This file contains 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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
/* | ||
* Copyright 2024 Hypermode, Inc. | ||
* Copyright 2024 Hypermode Inc. | ||
* Licensed under the terms of the Apache License, Version 2.0 | ||
* See the LICENSE file that accompanied this code for further details. | ||
* | ||
* SPDX-FileCopyrightText: 2024 Hypermode, Inc. <[email protected]> | ||
* SPDX-FileCopyrightText: 2024 Hypermode Inc. <[email protected]> | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
|
Oops, something went wrong.