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 Model docstring + Readme #14

Merged
merged 3 commits into from
Jan 31, 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
77 changes: 57 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,52 @@

# Actions SDK

The Actions SDK is a Python library designed to facilitate the development of applications on the Giza platform. It provides a set of decorators and classes to define tasks, actions, and models, and to handle data inputs.
The Actions SDK is a Python library designed to facilitate the development of ZKML applications on the Giza platform. It provides a set of decorators and classes to define tasks, actions, and models, and to handle data inputs.

## Where to start?
Check out our extensive [documentation](https://actions.gizatech.xyz/welcome/giza-actions-sdk) to understand concepts and follow how-to-guides.

## Installation

The Actions SDK can be installed using [Poetry](https://python-poetry.org/):
Start by creating a virtual environment in your project directory and activate it:
```bash
$ python -m venv .env

# Activate the virtual environment. On Linux and MacOs
$ source .env/bin/activate

# Activate Virtual environment on Windows:
$ .env/Scripts/activate
```
poetry install
Now you’re ready to install ⚡Actions with the following command:

```bash
$ pip install giza-actions
```

Be sure you're logged into the [Giza CLI](https://cli.gizatech.xyz/resources/users) and have created a workspace:
## Setup

From your terminal, create a Giza user through our CLI in order to access the Giza Platform:
```bash
$ giza users create
```
After creating your user, log into Giza:
```bash
$ giza users login
```
Optional: you can create an API Key for your user in order to not regenerate your access token every few hours.
```bash
$ giza users create-api-key
```
giza workspaces create
To create Actions Runs you will need a Giza Workspace, create it executing the following command in your terminal:
```bash
$ giza workspaces create
```

## Usage

### Defining Tasks
A task is a function that represents a distinct segment of work in a Giza Actions workflow. Tasks provide a way to encapsulate parts of your workflow logic in traceable, reusable units across actions.

Tasks are defined using the `@task` decorator. Here's an example:
```python
Expand All @@ -30,38 +57,48 @@ def preprocess():
print(f"Preprocessing...")
```

## Defining Actions
### Defining Actions
An action serves as a framework for coding ML inferencing workflow logic, enabling users to tailor the behaviour of their workflows.

Actions are defined using the `@action` decorator. Here's an example:
```python
from giza.action import action

@action
@action(name="My Action")
def inference():
print(f"Running inference...")
```

## Running Actions
### Deploy Actions

Actions can be deployed executing the Python script defining the Action. For example, if the Action is defined in `example.py`, you can run it using:
Deployments are server-side representations of actions. They keep essential metadata required for remote orchestration, including when, where, and how a workflow should run. Deployments transform workflows from functions that need to be manually activated to API-managed entities capable of being triggered remotely.

```
python example.py
```
We can easily create a deployment by creating the Action object and then calling the serve function in the entrypoint script:

Then, you can execute the Action using the Prefect UI:
```python
from giza_actions.action import Action, action
from giza_actions.task import task

```
prefect server start
```
@task
def print_hello():
print(f"Hello Action!")

## Examples
@action
def hello_world():
print_hello()

if __name__ == '__main__':
action_deploy = Action(entrypoint=hello_world, name="hello-world-action")
action_deploy.serve(name="hello-world-action-deployment")
```

Examples of how to use the Actions SDK can be found in the `examples` directory. Each example includes a README with detailed instructions on how to run the example.
Running this script will do two things:
- Create a deployment called "hello-world-action" for your action in the Giza Platform.
- Stay running to listen for action runs for this deployment; when a run is found, it will be asynchronously executed within a subprocess locally.

For instance, the `imagenet` example demonstrates how to use the Giza SDK to perform image classification using a pre-trained ResNet-50 model from the ONNX model zoo.
## Examples

To understand how to execute these examples, please refer to the README file in each example's directory.
Examples of how to use the Actions SDK can be found in the `examples` directory. Each example includes a README or a Notebook with detailed instructions on how to run the example.

## Contributing

Expand Down
Binary file added examples/verifiable_mnist/imgs/zero.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading