Using the CLI

Detailed guide for using the Ogre CLI.

·4 min read
Cover Image for Using the CLI

The CLI enables the user to customize how ogre builds and deploys the coding environment. It enables the user to: Modify specific deployment parameters that are not accessible from the extension Deploy local projects, i.e., source code stored in a local folder, directly in the Ogre.run cloud. This is very handy for professionals who want to expose their project without the need to create a repository on GitHub or GitLab.

Installation

  1. Generate a token for your organization in the Ogre.run page.
  2. Install the Ogre CLI with python pip:
    pip install https://install.ogre.run/ogre_run-0.8.0-py3-none-any.whl This command will prompt you to provide a user name and a password (provided by email).
  3. To check if everything was successfully installed, type ogre --help

Create a config file

You can modify the default Ogre parameters by creating a config file. To generate one based off a template, go inside the folder containing the Python code you want to run, and type

ogre --config

The config file consists of several parameters that control the behavior of Ogre.run and how it builds the environment.

path: .
web: False
jupyter: True
jupyter_password: ogre123
jupyter_port: "8001"
mount: True
api_url: https://dev-cloud.ogre.run
api_token: <OGRE_TOKEN>
docker:
  company: ogarantia
  version: 0.1.0
  baseimage: ogarantia/ogre:base-ubuntu22.04-<PLATFORM>
  device: cpu
  container_repo: ghcr.io
  project_volume_path: /opt
  cmd: bash
  ttyd: ttyd
  ttyd_version: 1.6.3
  ttyd_url: https://github.com/tsl0922/ttyd/releases/download/
  ttyd_port: 6007
  ogre_dir: ogre_dir
  requirements_format: freeze
  expose_ports: 8888
  no_cache: True

where you should substitute <OGRE_TOKEN> by the token created in the ogre.run website, and <PLATFORM> by either amd64 (e.g. Intel CPUs) or arm64 (e.g. Mac).


Using the config file you can:

  1. Choose a different port to deploy the environment (try jupyter_port: 8081 for example); However, if the desired port is already taken, Ogre.run will automatically choose a free port.
  2. Define which container ports you want to expose to the host (this comes in handy if your application runs on a specific port). If you need to expose more than one port, separate then by commas, e.g., expose_ports: 8081, 8090. If you don't want/need to expose container ports, set it equal to zero, i.e., expose_ports: 0;
  3. Choose a different baseimage on top of which your project image will be built. Try for example pytorch/pytorch:latest to build your environment based on the latest pytorch version. Now you are ready to deploy your environment using the CLI.

Metacompile a code base from the command line

Go inside the folder containing the python code you want to metacompile.

IMPORTANT: Ogre is currently limited to code bases that contain at least a README file with instructions to run the code. We are working to remove that limitation and enable Ogre to work without the need for a README file.

Type the command
ogre –-yaml_config ogre.yml
This command will send a request to the Ogre Cloud, which will then run the metacompilation of your code base and send back a file with instructions on how to build the optimal environment to run the code in your local system.


Once the environment is done being built, you can access it by visiting the address returned by the command ogre --info for example, for the following output


>>>Info about ogre containers running in the local system.
ogre-ogarantia-<YOUR_PROJECT_NAME>-jupyter 0.0.0.0:8001->8001/tcp

you should access the address 0.0.0.0:8001 on a web browser.

If you prefer to expose your code base to everybody, you have the option to use the Ogre cloud. Use the following sequence of commands to package, publish, and start the service online.

  1. Package code. ogre --package
  2. Publish code to the cloud (this step just uploads it; no service is started). ogre --publish
  3. Start the Ogre service. Your environment will be built remotely (in the Ogre Cloud) according to the parameters in your ogre.yml file. ogre --service_up
  4. Once finished building, you will be able to access the jupyterlab environment from the browser, the same way as when using the extension. Finally, to stop the service just do ogre --service_down

Congratulations! You have successfully learned how to use Ogre.run CLI. If you have any further questions or need assistance, feel free to reach out to our support team.


Read more about

Cover Image for Deploying your first environment
·2 min read·Tutorials

Detailed guide for deploying your first environment using Ogre.