Skip to content

Commit

Permalink
Plugins added (#45)
Browse files Browse the repository at this point in the history
* plugins

---------

Co-authored-by: Phil Downey <[email protected]>
Co-authored-by: Brian Duenas <[email protected]>
  • Loading branch information
3 people authored May 31, 2024
1 parent dfad8fa commit 7eed012
Show file tree
Hide file tree
Showing 11 changed files with 122 additions and 63 deletions.
58 changes: 27 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,29 +118,29 @@ If you get an error when running `init_magic`, you may first need to setup the d

## Table of Contents <!-- omit from toc -->

<a href="#openad-beta">OpenAD Beta</a>

<a href="#installation">Installation</a>
<li><a href="#getting-started---cli">Getting Started - CLI</a></li>
<li><a href="#getting-started---jupyter">Getting Started - Jupyter</a></li>
<li><a href="#Setting up Jupyter">#setting-up-jupyter</a><br></li>
<li><a href="#launching-openad-in-jupyter">Launching OpenAD in Jupyter</a><br></li>
<a href="#interacting-with-the-toolkits">Interacting with the Toolkits</a>
<li><a href="#registration">Registration</a></li>
<li><a href="#adding-a-toolkit">Adding a Toolkit</a></li>
<li><a href="#sample-commands">Sample Commands</a></li>
<li><a href="#running-bash-commands-cli">Running Bash Commands (CLI)</a></li>
<a href="#ai-assistant">AI AssistantL</a>
<a href="#for-developers">For Developer</a>
<li><a href="#installation-for-development">Installation for Development</a></li>
<li><a href="#testing-a-branch">Testing a branch</a></li>
<a href="#installing-on-windows">Installing on Windows</a>
<li><a href="#before-you-start">Before you start</a></li>
<li><a href="#installing-wsl">Installing WSL</a></li>
<a href="#linux-notes">Linux Notes</a>


---
<!-- toc -->

- [OpenAD Beta](#openad-beta)
- [Installation](#installation)
- [Getting Started - CLI](#getting-started---cli)
- [Getting Started - Jupyter](#getting-started---jupyter)
- [Setting up Jupyter](#setting-up-jupyter)
- [Launching OpenAD in Jupyter](#launching-openad-in-jupyter)
- [Interacting with the Toolkits](#interacting-with-the-toolkits)
- [Registration](#registration)
- [Adding a Toolkit](#adding-a-toolkit)
- [Sample Commands](#sample-commands)
- [Running Bash Commands (CLI)](#running-bash-commands-cli)
- [AI Assistant](#ai-assistant)
- [For Developers](#for-developers)
- [Installation for Development](#installation-for-development)
- [Testing a branch](#testing-a-branch)
- [Installing on Windows](#installing-on-windows)
- [Before you start](#before-you-start)
- [Installing WSL](#installing-wsl)
- [Linux Notes](#linux-notes)

<!-- tocstop -->

<br>

Expand All @@ -160,7 +160,7 @@ Ensure you're running Python 3.10 or 3.11. There's multiple ways of updating Pyt

1. **Step 1: Set up your virtual environment** (optional)<br>

python -m venv ~/ad-venv
python3.11 -m venv ~/ad-venv
source ~/ad-venv/bin/activate

> **Note:** To exit the virtual environment, you can run `deactivate`
Expand All @@ -169,16 +169,12 @@ Ensure you're running Python 3.10 or 3.11. There's multiple ways of updating Pyt

pip install openad

if you are going to use the model services you will need to have an AWS CLI enabled on your machine and follow the below steps to install and check skypilot is enabled on your machine:

A. Install Sky with `pip install "skypilot-nightly[aws]"`

B. setup your aws command line
if you are going to use the model services you will need to have an AWS CLI enabled on your machine and follow the below steps to check skypilot is enabled to deploy on aws on your machine:

C. run `sky check`
A. run `sky check`

Services will take about 10 minutes to deploy it can be monitored through the controllers logs.
If you launch Model Services will take about 10 minutes to deploy it can be monitored through the controllers logs.
e.g. `sky serve logs sky-service-0af4 --controller`

<br>
Expand Down
4 changes: 2 additions & 2 deletions docs/output/csv/commands.csv
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ model service config '<service_name>'|<service_name>;Model
model catalog list;Model
uncatalog model service '<service_name>'|<service_name>;Model
catalog model service from (remote) '<path or github>' as '<service_name>'|<service_name>;Model
model service up '<service_name>'|<service_name>;Model
model service local up '<service_name>'|<service_name>;Model
model service up '<service_name>'|<service_name> [no_gpu]};Model
model service local up '<service_name>'|<service_name> ;Model
model service down '<service_name>'|<service_name>;Model
search for similar molecules to '<smiles>' [ save as '<filename.csv>' ];Search Molecules
search for molecules in patents from list ['<patent1>', '<patent2>', ...] | dataframe <dataframe_name> | file '<filename.csv>' [ save as '<filename.csv>' ];Search Molecules
Expand Down
33 changes: 21 additions & 12 deletions docs/output/markdown/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -482,25 +482,34 @@ uncatalog a model service <br>
`uncatalog model service 'gen'` <br><br>

`catalog model service from (remote) '<path or github>' as '<service_name>'|<service_name>`{: .cmd }
catalog a model service from a path or github or remotely from an existing OpenAD service. <br>
Example: <br>
catalog a model service from a path or github or remotely from an existing OpenAD service. <br>

`catalog model service from '[email protected]:acceleratedscience/generation_inference_service.git' as 'gen'` <br><br>
Example: <br>

`model service up '<service_name>'|<service_name>`{: .cmd }
launch a model service <br>
Examples: <br>
`model service up gen` <br>
`model service up 'gen'` <br><br>
-`catalog model service from '[email protected]:acceleratedscience/generation_inference_service.git' as 'gen'` <br>

or to catalog a remote service shared with you: <br>
-`catalog model service from remote 'http://54.235.3.243:30001' as gen` <br><br>

`model service up '<service_name>'|<service_name> [no_gpu]}`{: .cmd }
launches a cataloged model service. <br>
If you do not want to launch a service with GPU you should specify `no_gpu` at the end of the command. <br>
Examples: <br>

-`model service up gen` <br>

-`model service up 'gen'` <br>

-`model service up gen no_gpu` <br><br>

`model service local up '<service_name>'|<service_name>`{: .cmd }
launch a model service locally <br>
launch a model service locally. <br>

Example: <br>
` model service local up gen` <br><br>
Example: <br>
` model service local up gen` <br><br>

`model service down '<service_name>'|<service_name>`{: .cmd }
bring down a model service <br>
Bring down a model service <br>
Examples: <br>

`model service down gen` <br>
Expand Down
29 changes: 22 additions & 7 deletions docs/output/markdown/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ Get started with Jupyter:
init_examples
jupyter lab ~/openad_notebooks/Table_of_Contents.ipynb

If you get an error when running `init_magic`, you may first need to setup the default iPython profile for magic commands.

ipython profile create

<br>

---
Expand Down Expand Up @@ -60,8 +64,6 @@ Get started with Jupyter:
- [Installing WSL](#installing-wsl)
- [Linux Notes](#linux-notes)

---

<br>

# Installation
Expand All @@ -80,7 +82,7 @@ Ensure you're running Python 3.10 or 3.11. There's multiple ways of updating Pyt

1. **Step 1: Set up your virtual environment** (optional)<br>

python -m venv ~/ad-venv
python3.11 -m venv ~/ad-venv
source ~/ad-venv/bin/activate

> **Note:** To exit the virtual environment, you can run `deactivate`
Expand All @@ -89,6 +91,13 @@ Ensure you're running Python 3.10 or 3.11. There's multiple ways of updating Pyt

pip install openad

if you are going to use the model services you will need to have an AWS CLI enabled on your machine and follow the below steps to check skypilot is enabled to deploy on aws on your machine:

A. run `sky check`

If you launch Model Services will take about 10 minutes to deploy it can be monitored through the controllers logs.
e.g. `sky serve logs sky-service-0af4 --controller`

<br>

# Getting Started - CLI
Expand Down Expand Up @@ -187,7 +196,7 @@ The following commands only need to be run once after installation:

# Interacting with the Toolkits

OpenAD integrates with `DS4SD`, `RXN`, and has placeholder support for `ST4SD`.
OpenAD integrates with `DS4SD`, `RXN`, and has placeholder support for `ST4SD`.

<div class="notice" style="margin-top: 16px;" markdown="block">

Expand Down Expand Up @@ -277,8 +286,14 @@ To run a command in bash mode, prepend it with `openad` and make sure to escape

To enable our AI assistant, you'll need an account with OpenAI. There is a one month free trial.

This is available for IBM BAM service and Openai.

> **Note:** watsonx coming soon
For IBM BAM simply used your supplied API key if you have BAM access

For OpenAI

1. Go to [platform.openai.com](https://platform.openai.com) and create an account

2. Click on the profile icon in the top right and choose "View API keys"
Expand All @@ -287,8 +302,6 @@ To enable our AI assistant, you'll need an account with OpenAI. There is a one m

4. Run `tell me` to be prompted for your OpenAI API credentials

<a href="https://raw.githubusercontent.com/acceleratedscience/open-ad-toolkit/main/assets/openai-api-key.png" target="_blank"><img src="https://raw.githubusercontent.com/acceleratedscience/open-ad-toolkit/main/assets/openai-api-key.png" /></a>

<br>

# For Developers
Expand Down Expand Up @@ -378,7 +391,7 @@ Install WSL and create a user called 'openad' or one of your choosing.

wsl --install Ubuntu-22.04

**Optional:** To setup an Ubuntu Python environment from scratch, continue to [Linux Notes](#linux-notes)
**Optional:** To setup an Ubuntu Python environment from scratch, continue to <a href="#linux-notes">Linux Notes</a>

<br>

Expand All @@ -393,6 +406,8 @@ If you wish to setup an Ubuntu Python environment from scratch, run:
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 100
sudo pip install pip --upgrade

You will need to restart your Linux session before running `pip install openad` so that the python libraries are in your path.

If you get an error when running `init_magic`, you may first need to setup the default iPython profile for magic commands.

ipython profile create
31 changes: 31 additions & 0 deletions openad/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,26 @@
from openad.app.global_var_lib import GLOBAL_SETTINGS
from openad.app.global_var_lib import MEMORY

# Load available_Plugins modules
import pkg_resources
import inspect
import importlib


PLUGIN_CLASS_LIST = []
installed_packages = pkg_resources.working_set
installed_packages_list = [
i.key for i in installed_packages if i.key.startswith("openad-plugin-") or i.key.startswith("openad_plugin_")
]

for module_name in installed_packages_list:
try:
module_name = module_name.replace("-", "_")
module = importlib.import_module(f"{module_name}.plugins")
PLUGIN_CLASS_LIST.append(getattr(module, "openad_plugins"))
except:
output_error("ignoring addin, incorrect class definition")


sys.ps1 = "\x01\033[31m\x02>>> \x01\033[0m\x02"

Expand Down Expand Up @@ -100,6 +120,17 @@ class RUNCMD(Cmd):
llm_model = "gpt-3.5-turbo"
llm_models = SUPPORTED_TELL_ME_MODELS_SETTINGS

# Load OpenAD Plugins into cmd_pointer
plugins = PLUGIN_CLASS_LIST.copy()
plugin_objects = {}
plugins_statements = []
plugins_help = []
for plugin in plugins:
p = plugin()
plugin_objects.update(p.PLUGIN_OBJECTS)
plugins_statements.extend(p.statements)
plugins_help.extend(p.help)

# # Instantiate memory class # Trash
# memory = Memory()

Expand Down
12 changes: 4 additions & 8 deletions openad/app/main_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,14 +314,6 @@ def lang_parse(cmd_pointer, parser):
]:
return openad_model_requestor(cmd_pointer, parser)

# # Show molecules commands
# elif parser.getName() == "show_molecules":
# return show_molsgrid(cmd_pointer, parser)
# elif parser.getName() == "show_molecules_df":
# return show_molsgrid(cmd_pointer, parser)
# elif parser.getName() == "show_molecule":
# return show_mol__TRASH(cmd_pointer, parser)

# Toolkit execution
elif str(parser.getName()).startswith("toolkit_exec_"):
try:
Expand All @@ -336,6 +328,10 @@ def lang_parse(cmd_pointer, parser):
elif parser.getName() == "flask_example":
return flask_example(cmd_pointer, parser)

# openad Plugin Search for commands
elif parser.getName() in cmd_pointer.plugin_objects.keys():
return cmd_pointer.plugin_objects[parser.getName()].exec_command(cmd_pointer, parser)

return


Expand Down
2 changes: 1 addition & 1 deletion openad/app/metadata.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"banner": "OPENAD",
"title": "Welcome to the Open Accelerated Discovery CLI",
"version": "0.3.0",
"version": "0.3.1",
"commands": {
"intro": "If this is your first time, let us help you getting started.",
"? toolkits": "Learn about the toolkits.",
Expand Down
10 changes: 10 additions & 0 deletions openad/core/grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -901,12 +901,22 @@ def create_statements(cmd_pointer):
except Exception as e:
print(e)
pass
# add plugins

for stmt in cmd_pointer.plugins_statements:
cmd_pointer.current_statements.append(stmt)

cmd_pointer.current_help.help_plugins.extend(cmd_pointer.plugins_help)
cmd_pointer.current_help.reset_help()

for i in cmd_pointer.current_statements:
cmd_pointer.current_statement_defs |= i

if cmd_pointer.toolkit_current is not None:
for i in cmd_pointer.toolkit_current.methods_grammar:
cmd_pointer.current_statement_defs |= i
cmd_pointer.current_statements.append(i)

# statements_zom = ZeroOrMore(statements_def)


Expand Down
2 changes: 2 additions & 0 deletions openad/core/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ class OpenadHelp:
help_orig = []
help_current = []
help_model_services = []
help_plugins = []

def add_help(self, help_dict):
for i in help_dict:
Expand All @@ -232,3 +233,4 @@ def add_help(self, help_dict):
def reset_help(self):
self.help_current = self.help_orig.copy()
self.help_current.extend(self.help_model_services)
self.help_current.extend(self.help_plugins)
Binary file added openad/notebooks/media/genai.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "openad"
version = "0.3.0"
version = "0.3.1"
description = "Open Accelerated Discovery Client "
authors = ["Phil Downey <[email protected]>"]
readme = "README.md"
Expand Down Expand Up @@ -107,7 +107,7 @@ enable_error_code = [
]

[tool.pytest.ini_options]
addopts = "--cov=openad/openad_model_plugin"
#addopts = "--cov=openad/openad_model_plugin"
testpaths = ["tests"]
filterwarnings = ["ignore::DeprecationWarning"]

Expand Down

0 comments on commit 7eed012

Please sign in to comment.