Skip to content
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
20 changes: 20 additions & 0 deletions src/hyrax/hyrax.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from pathlib import Path
from typing import Union

from hyrax.verbs.verb_registry import Verb


class Hyrax:
"""
Expand Down Expand Up @@ -229,6 +231,24 @@ def list_dataset_classes(self):

return sorted(DATASET_REGISTRY.keys())

def list_verbs(self):
"""Return the alphabetically sorted list of available verbs.

The list shows all classes in the verbs directory which extend the Verb class.
Each element is simply the string given by the `information`
method for that verb.

Returns
-------
list[str]
Alphabetically sorted list of each verb along with
required arguments, optional arguments, and short description.
See `information()` method in verb_registry.py for more details.
"""
verbs = [obj.information() for obj in Verb.__subclasses__()]
verbs.sort()
return verbs

# Python notebook interface to class verbs
# we need both __dir__ and __getattr__ so that the
# functions from the various verb classes appear to be
Expand Down
4 changes: 2 additions & 2 deletions src/hyrax/verbs/database_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

@hyrax_verb
class DatabaseConnection(Verb):
"""Verb to insert inference results into a vector database index for fast
similarity search."""
"""Verb to create a connection to a vector database with inference results."""
Comment thread
drewoldag marked this conversation as resolved.

cli_name = "database_connection"
add_parser_kwargs = {}
description = "Create a connection to the vector database for interactive queries."

@staticmethod
def setup_parser(parser: ArgumentParser):
Expand Down
1 change: 1 addition & 0 deletions src/hyrax/verbs/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Engine(Verb):

cli_name = "engine"
add_parser_kwargs = {}
description = "Run inference with an ONNX model."

@staticmethod
def setup_parser(parser):
Expand Down
1 change: 1 addition & 0 deletions src/hyrax/verbs/infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Infer(Verb):

cli_name = "infer"
add_parser_kwargs = {}
description = "Run inference on a model using a dataset."
Comment thread
drewoldag marked this conversation as resolved.

# Dataset groups that the Infer verb knows about.
REQUIRED_DATA_GROUPS = ("infer",)
Expand Down
1 change: 1 addition & 0 deletions src/hyrax/verbs/lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Lookup(Verb):

cli_name = "lookup"
add_parser_kwargs = {}
description = "Look up an inference result using the ID of a data member."

@staticmethod
def setup_parser(parser: ArgumentParser):
Expand Down
1 change: 1 addition & 0 deletions src/hyrax/verbs/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Model(Verb):

cli_name = "model"
add_parser_kwargs = {}
description = "Return a reference to the model class (not a new instance)."

@staticmethod
def setup_parser(parser):
Expand Down
1 change: 1 addition & 0 deletions src/hyrax/verbs/save_to_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class SaveToDatabase(Verb):

cli_name = "save_to_database"
add_parser_kwargs = {}
description = "Insert inference results into vector database."

@staticmethod
def setup_parser(parser: ArgumentParser):
Expand Down
48 changes: 0 additions & 48 deletions src/hyrax/verbs/search.py

This file was deleted.

1 change: 1 addition & 0 deletions src/hyrax/verbs/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Test(Verb):

cli_name = "test"
add_parser_kwargs = {}
description = "Evaluate a trained model on test data."

# Dataset groups that the Test verb knows about.
REQUIRED_DATA_GROUPS = ("test",)
Expand Down
1 change: 1 addition & 0 deletions src/hyrax/verbs/to_onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class ToOnnx(Verb):

cli_name = "to_onnx"
add_parser_kwargs = {}
description = "Export model to ONNX format."

@staticmethod
def setup_parser(parser):
Expand Down
1 change: 1 addition & 0 deletions src/hyrax/verbs/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Train(Verb):

cli_name = "train"
add_parser_kwargs = {}
description = "Train a model using provided data."

# Dataset groups that the Train verb knows about.
# REQUIRED_DATA_GROUPS must be present in the dataset dict returned by setup_dataset.
Expand Down
1 change: 1 addition & 0 deletions src/hyrax/verbs/umap.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Umap(Verb):

cli_name = "umap"
add_parser_kwargs = {}
description = "Transforms the entire dataset into a lower-dimensional space by fitting a UMAP model."

@staticmethod
def setup_parser(parser: ArgumentParser):
Expand Down
23 changes: 23 additions & 0 deletions src/hyrax/verbs/verb_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class Verb(ABC): # noqa: B024
# Verbs that leave both empty skip data_request validation entirely.
REQUIRED_DATA_GROUPS: tuple[str, ...] = ()
OPTIONAL_DATA_GROUPS: tuple[str, ...] = ()
cli_name = "VERB"
description = ""

def __init__(self, config):
"""
Expand All @@ -29,6 +31,27 @@ def __init__(self, config):
self.config = config
self.validate_data_request()

@classmethod
def information(cls):
"""Returns a string describing this verb. Includes the following:
- Name of the verb
- Required Data Groups
- Optional Data Groups
- One line description of what this verb does

If a data group is empty then it will be printed as an empty tuple.

Returns
-------
str
<name>: Data Groups: Req. (<req1>, <req2>, ...), Opt. (<opt1>, <opt2>, ...). <Description>
"""
info = cls.cli_name + ": "
required = "Req. " + str(cls.REQUIRED_DATA_GROUPS)
optional = "Opt. " + str(cls.OPTIONAL_DATA_GROUPS)
info = info + "Data groups: " + required + ", " + optional + ". " + cls.description
return info

def validate_data_request(self) -> None:
"""Validate the data_request configuration for this verb's known groups.

Expand Down
1 change: 1 addition & 0 deletions src/hyrax/verbs/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Visualize(Verb):

cli_name = "visualize"
add_parser_kwargs = {}
description = "Generate a visualization of a latent space created by a UMAP reduction."

# Dataset groups that the Visualize verb knows about.
# REQUIRED_DATA_GROUPS must be present in the data request configuration.
Expand Down
Loading