Apolo
HomeConsoleGitHub
  • Apolo concepts
  • CLI Reference
  • Examples/Use Cases
  • Flow CLI
  • Actions Reference
  • Apolo Extras CLI
  • Python SDK
  • Getting started
    • Introduction
    • First Steps
      • Getting Started
      • Training Your First Model
      • Running Your Code
    • Apolo Base Docker image
    • FAQ
    • Troubleshooting
    • References
  • Apolo Console
    • Getting started
      • Sign Up, Login
      • Organizations
      • Clusters
      • Projects
    • Apps
      • Pre-installed apps
        • Files
        • Buckets
        • Disks
        • Images
        • Secrets
        • Jobs
          • Remote Debugging with PyCharm Professional
          • Remote Debugging with VS Code
        • Flows
      • Available apps
        • Terminal
        • LLM Inference
          • vLLM Inference details
          • Multi-GPU Benchmarks Report
        • PostgreSQL
        • Text Embeddings Inference
        • Jupyter Notebook
        • Jupyter Lab
        • VS Code
        • PyCharm Community Edition
        • ML Flow
        • Apolo Deploy
        • Dify
        • Weaviate
        • Fooocus
        • Stable Diffusion
  • Apolo CLI
    • Installing CLI
    • Apps
      • Files
      • Jobs
      • Images
  • Administration
    • Cluster Management
      • Creating a Cluster
      • Managing Users and Quotas
      • Managing organizations
      • Creating Node Pools
      • Managing Presets
Powered by GitBook
On this page
  • Prerequisites
  • Configuration
  • Running code

Was this helpful?

  1. Getting started
  2. First Steps

Running Your Code

PreviousTraining Your First ModelNextApolo Base Docker image

Last updated 2 months ago

Was this helpful?

Oftentimes you don't start a project from scratch. Instead of that you use someone's or your own old code as a baseline and develop your solution on top of it. This guide demonstrates how to take an existing code base, convert it into a Apolo flow, and start developing on the platform.

Prerequisites

  1. Make sure that you have the Apolo CLI and logged in.

  2. Install the apolo-flow package:

pip install -U apolo-flow

Configuration

As an example we'll use the GitHub that contains PyTorch implementations for Aspect-Based Sentiment Analysis models (see for more details).

First, let's clone the repo and navigate to the created folder:

git clone git@github.com:songyouwei/ABSA-PyTorch.git
cd ABSA-PyTorch

Now, we need to create two more files in this folder:

  • Dockerfile contains a very basic Docker image configuration. We need this file to build a custom Docker image which is based on pytorch/pytorch public images and contains this repo requirements (which are gracefully listed by the repo maintainer in requirements.txt):

Dockerfile
FROM pytorch/pytorch:1.4-cuda10.1-cudnn7-runtime
COPY . /cfg
RUN pip install --progress-bar=off -U --no-cache-dir -r /cfg/requirements.txt
  • .neuro/live.yml contains minimal configuration allowing us to run this repo's scripts right on the platform through handy short commands:

.neuro/live.yml
kind: live
title: Sentiment Analysis Training
id: absa

volumes:
  project:
    remote: storage:${{ flow.id }}
    mount: /project
    local: .

images:
  pytorch:
    ref: image:${{ flow.id }}:v1.0
    dockerfile: ${{ flow.workspace }}/Dockerfile
    context: ${{ flow.workspace }}

jobs:
  train:
    image: ${{ images.pytorch.ref }}
    preset: gpu-small
    name: absa-pytorch-train
    volumes:
      - ${{ volumes.project.ref_rw }}
    bash: |
        cd ${{ volumes.project.mount }}
        python train.py --model_name bert_spc --dataset restaurant

Here is a brief explanation of this config:

  • volumes section contains declarations of connections between your computer file system and the platform storage; here we state that we want the entire project folder to be uploaded to storage at storage:absa folder and be mounted inside jobs /project;

  • images section contains declarations of Docker images created in this project; here we declare our image which is decribed in Dockerfile above;

  • jobs section is the one where action happens; here we declare a train job which runs our training script with a couple of parameters.

Running code

Now it's time to run several commands that set up the project environment and run training.

  • First, create volumes and upload project to platform storage:

apolo-flow mkvolumes
apolo-flow upload ALL
  • Then, build an image:

apolo-flow build pytorch
  • Finally, run training:

apolo-flow run train

Please run apolo-flow --help to get more information about available commands.

repo
Attentional Encoder Network for Targeted Sentiment Classification
installed