Skip to content

Commit

Permalink
added new categories (#1478)
Browse files Browse the repository at this point in the history
* added new categories

* added try-except

* bugfix list to dictionary

* added output consistency field and blackened code

* Update columns_information.py
  • Loading branch information
miquelduranfrigola authored Dec 30, 2024
1 parent d33dcbe commit 68e3798
Show file tree
Hide file tree
Showing 133 changed files with 1,644 additions and 1,051 deletions.
2 changes: 1 addition & 1 deletion .github/scripts/airtableops.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def __init__(self, model_id, config_json=None):
self.model_id = model_id

def read_information(self):
print ("Cannot read directly from README file. Using AirTable instead")
print("Cannot read directly from README file. Using AirTable instead")
am = AirtableMetadata(model_id=self.model_id)
bi = am.read_information()
print(bi.as_dict())
Expand Down
14 changes: 10 additions & 4 deletions .github/scripts/summarize_publication_with_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import json
from typing import List
from pydantic import BaseModel

# from dotenv import load_dotenv

# load_dotenv()
Expand Down Expand Up @@ -187,6 +188,7 @@
Reformat, if necessary, the following publication report:
"""


class Summary(BaseModel):
title: str
authors: str
Expand Down Expand Up @@ -278,9 +280,10 @@ def download(self):
return self.download_from_file_path()
return None


class PublicationSummarizer:
def __init__(self, publication_pdf, output_file, format="json"):
self.tmp_dir = tempfile.mkdtemp(prefix="ersilia-") # TODO Unused
self.tmp_dir = tempfile.mkdtemp(prefix="ersilia-") # TODO Unused
self.model_name = MODEL_NAME
self.publication_pdf = publication_pdf
self.output_file = output_file
Expand Down Expand Up @@ -336,9 +339,11 @@ def postprocess_response(self, text_response, output_file):
text_response = response.choices[0].message.content
with open(output_file, "w") as f:
f.write(text_response)

else:
raise ValueError("Invalid format. Please choose either 'json' or 'markdown'.")
raise ValueError(
"Invalid format. Please choose either 'json' or 'markdown'."
)

def run(self):
text = self.extract_text_from_pdf(self.publication_pdf)
Expand All @@ -358,6 +363,7 @@ def serialize_json_to_md(json_file, md_file):
else:
f.write(str(value) + "\n")


if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Process arguments.")
parser.add_argument(
Expand Down Expand Up @@ -394,7 +400,7 @@ def serialize_json_to_md(json_file, md_file):
type=str,
default="json",
required=False,
help="File format in which to save the summary, defaults to JSON"
help="File format in which to save the summary, defaults to JSON",
)
args = parser.parse_args()
model_id = args.model_id
Expand Down
104 changes: 59 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,77 +20,89 @@

## Project Description

The [Ersilia Model Hub](https://ersilia.io) is a unified platform of pre-trained AI/ML models dedicated to 🦠 infectious and neglected disease research. Our mission is to offer an open-source, 🛠 low-code solution that provides seamless access to AI/ML models for 💊 drug discovery. Models housed in our hub come from two sources:
The [Ersilia Model Hub](https://ersilia.io) is a unified platform of pre-trained AI/ML models for 🦠 infectious and neglected disease research. Our mission is to offer an open-source, 🛠 low-code solution that provides seamless access to AI/ML models for 💊 drug discovery. Models housed in our hub come from two sources:

1. 📚 Published models from literature (with due third-party acknowledgement)
2. 🛠 Custom models developed by the **Ersilia team** or our valued contributors.
- Published models from literature (with due third-party acknowledgement)
- Custom models developed by the Ersilia team or our valued contributors

* Read more about the project in the [Ersilia Book](https://ersilia.gitbook.io/ersilia-book/)
* Browse available models in the [Ersilia Model Hub](https://ersilia.io/model-hub/)
You can read more about the project in the [Ersilia Book](https://ersilia.gitbook.io/ersilia-book/) and browse available models in the [Ersilia Model Hub](https://ersilia.io/model-hub/).

## Quick Start Guide

Please check the package requirements in the [Installation Guide](https://ersilia.gitbook.io/ersilia-book/quick-start/installation). The next steps are a quickstart guide to installing Ersilia.
Please check the package requirements in the [Installation Guide](https://ersilia.gitbook.io/ersilia-book/quick-start/installation). The following steps are a quick start guide to using Ersilia.

1. Create a conda environment and activate it
First, create a conda environment and activate it:

```bash
conda create -n ersilia python=3.10
conda activate ersilia
```
```bash
conda create -n ersilia python=3.10
conda activate ersilia
```

1. Clone this repository and install with pip
Then, clone this repository and install with `pip`:

```bash
git clone https://github.com/ersilia-os/ersilia.git
cd ersilia
pip install -e .
```
```bash
git clone https://github.com/ersilia-os/ersilia.git
cd ersilia
pip install -e .
```

1. Once the Ersilia Model Hub is installed, you can use the CLI to run predictions. First, select a model from the [Ersilia Model Hub](https://ersilia.io/model-hub/) and **fetch** it:
Alternatively, you can directly install from PyPi:
```bash
pip install ersilia
```

```bash
ersilia fetch retrosynthetic-accessibility
```
Once the Ersilia package is installed, you can use the CLI to run predictions. First, select a model from the [Ersilia Model Hub](https://ersilia.io/model-hub/) and fetch it:

1. Generate a few (5) example molecules, to be used as input. The **example** command will generate the adequate input for the model in use
```bash
ersilia fetch eos4e40
```

```bash
ersilia example retrosynthetic-accessibility -n 5 -f my_molecules.csv
```
Note that you can use the model identifier (eos4e40) or its human-readable slug (antibiotic-activity).

1. Then, **serve** your model:
Now you can serve the model:

```bash
ersilia serve retrosynthetic-accessibility
```
```bash
ersilia serve eos4e40
```

1. And **run** the model:
To view some information of the model, type the following:

```bash
ersilia run -i my_molecules.csv -o my_predictions.csv
```
```bash
ersilia info
```

1. Finally, **close** the service when you are done.
The simplest way to run a model is by passing a CSV file as input. If you don't have one, you can generate it easily. In this case, we take 5 molecules as an example:

```bash
ersilia close
```
```bash
ersilia example -n 5 -f my_input.csv
```

1. If you no longer want to use the model, you can **delete** it.
Now you can run the model:

```bash
ersilia delete retrosynthetic-accessibility
```
```bash
ersilia run -i my_input.csv -o my_output.csv
```

To stop the service, you can simply close the model:

```bash
ersilia close
```

Finally, if you don't want to use the model anymore, delete it as follows:

```bash
ersilia delete eos4e40
```

Please see the [Ersilia Book](https://ersilia.gitbook.io/ersilia-book/) for more examples and detailed explanations.

## Contribute

The Ersilia Model Hub is a Free, Open Source Software and we highly value new contributors. There are several ways in which you can contribute to the project:

* A good place to start is checking open [issues](https://github.com/ersilia-os/ersilia/issues).
* If you have identified a bug in the code, please open a new issue using the bug template.
* A good place to start is checking open [issues](https://github.com/ersilia-os/ersilia/issues)
* If you have identified a bug in the code, please open a new issue using the bug template
* Share any feedback with the community using [GitHub Discussions](https://github.com/ersilia-os/ersilia/discussions) for the project
* Check our [Contributing Guide](https://github.com/ersilia-os/ersilia/blob/master/CONTRIBUTING.md) for more details

Expand All @@ -100,7 +112,7 @@ The Ersilia Open Source Initiative adheres to the [Contributor Covenant](https:/

If you want to incorporate a new model in the platform, open a new issue using the [model request template](https://github.com/ersilia-os/ersilia/issues/new?assignees=&labels=new-model&template=model_request.yml&title=%F0%9F%A6%A0+Model+Request%3A+%3Cname%3E) or contact us using the following [form](https://www.ersilia.io/request-model).

After submitting your model request via an issue (suggested), a maintainer will review your request. If they `/approve` your request, a new model respository will be created for you to fork and use! There is a [demo repository](https://github.com/ersilia-os/eos-demo) explaining the steps one-by-one.
After submitting your model request via an issue (suggested), an Ersilia maintainer will review your request. If they approve your request, a new model respository will be created for you to fork and use! There is a [demo repository](https://github.com/ersilia-os/eos-demo) explaining the steps one-by-one.

## License and Citation

Expand All @@ -113,6 +125,7 @@ Please note that Ersilia distinguises between software contributors and software
- Carolina Caballero

### Cited by

The Ersilia Model Hub is used in a number of scientific projects. Read more about how we are implementing it in:
- [Turon, Hlozek et al, Nat Commun, 2023](https://www.nature.com/articles/s41467-023-41512-2)
- [Van Heerden et al, ACS Omega, 2023](https://pubs.acs.org/doi/10.1021/acsomega.3c05664)
Expand All @@ -125,4 +138,5 @@ The [Ersilia Open Source Initiative](https://ersilia.io) is a Non Profit Organiz
[Help us](https://www.ersilia.io/donate) achieve our mission!

### Funding
The Ersilia Model Hub is the flagship product of Ersilia. It has been funded thanks to a combination of funding sources. Full disclosure can be found in our [website](https://ersilia.io/supporters). Highlighted supporters include Splunk Pledge, the Mozilla Builders Accelerator and the AI2050 Program by Schmidt Futures.

The Ersilia Model Hub is the flagship product of Ersilia. It has been funded thanks to a combination of funding sources. Full disclosure can be found in our [website](https://ersilia.io/supporters). Highlighted supporters include the Mozilla Builders Accelerator, Fast Forward, Splunk Pledge and the AI2050 Program by Schmidt Sciences.
9 changes: 3 additions & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"sphinx.ext.mathjax",
"sphinx.ext.viewcode",
"sphinx.ext.napoleon",
'sphinx.ext.autosummary'
"sphinx.ext.autosummary",
]

autosummary_generate = True
Expand All @@ -26,15 +26,12 @@
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

html_theme = "furo"
html_theme_options = {
"collapse_navigation": True,
"navigation_depth": 4
}
html_theme_options = {"collapse_navigation": True, "navigation_depth": 4}

html_static_path = []
htmlhelp_basename = "ersilia_doc"

pygments_style = 'sphinx'
pygments_style = "sphinx"

latex_documents = [
(master_doc, "ersilia.tex", "Ersilia Documentation", author, "manual"),
Expand Down
2 changes: 1 addition & 1 deletion ersilia/cli/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ def setup(self):

def test(self):
m = importlib.import_module("ersilia.cli.commands.test")
m.test_cmd()
m.test_cmd()
1 change: 1 addition & 0 deletions ersilia/cli/commands/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def catalog_cmd():
Display model card for a specific model ID and show catalog in json format:
$ ersilia catalog --card <model_id> --as-json
"""

# Example usage: ersilia catalog
@ersilia_cli.command(help="List a catalog of models")
@click.option(
Expand Down
2 changes: 2 additions & 0 deletions ersilia/cli/commands/close.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from ...core.session import Session
from ...utils.session import deregister_model_session


def close_cmd():
"""
Closes the current session.
Expand All @@ -24,6 +25,7 @@ def close_cmd():
Close the current session:
$ ersilia close
"""

# Example usage: ersilia close {MODEL}
@ersilia_cli.command(short_help="Close model", help="Close model")
def close():
Expand Down
5 changes: 2 additions & 3 deletions ersilia/cli/commands/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def delete_cmd():
Delete all models:
$ ersilia delete --all
"""

def _delete(md, model_id):
md.delete(model_id)

Expand All @@ -46,9 +47,7 @@ def _delete_model_by_id(model_id):
)
else:
echo(
f":person_tipping_hand: {reason}".format(
model_id
),
f":person_tipping_hand: {reason}".format(model_id),
fg="yellow",
)

Expand Down
5 changes: 3 additions & 2 deletions ersilia/cli/commands/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def example(model, n_samples, file_name, simple, predefined):
model_id = session.current_model_id()
if not model_id:
echo(
"No model found. Please specify a model or serve a model in the current shell.", fg="red"
"No model found. Please specify a model or serve a model in the current shell.",
fg="red",
)
return
eg = ExampleGenerator(model_id=model_id)
Expand All @@ -41,4 +42,4 @@ def example(model, n_samples, file_name, simple, predefined):
)
)
else:
eg.example(n_samples, file_name, simple, try_predefined=predefined)
eg.example(n_samples, file_name, simple, try_predefined=predefined)
8 changes: 6 additions & 2 deletions ersilia/cli/commands/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def fetch_cmd():
Fetch a model from a local directory:
$ ersilia fetch <model_id> --from_dir <path>
"""

def _fetch(mf, model_id):
res = asyncio.run(mf.fetch(model_id))
return res
Expand Down Expand Up @@ -78,7 +79,7 @@ def _fetch(mf, model_id):
"--hosted_url",
default=None,
type=click.STRING,
help="URL of the hosted model service"
help="URL of the hosted model service",
)
@click.option(
"--with_bentoml",
Expand Down Expand Up @@ -136,6 +137,9 @@ def fetch(
fg="green",
)
else:
echo(f":thumbs_down: Model {model_id} failed to fetch! {fetch_result.reason}", fg="red")
echo(
f":thumbs_down: Model {model_id} failed to fetch! {fetch_result.reason}",
fg="red",
)

return fetch
1 change: 1 addition & 0 deletions ersilia/cli/commands/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def info_cmd():
Get information about active session as json:
$ ersilia info --as_json
"""

@ersilia_cli.command(
short_help="Get model information", help="Get model information"
)
Expand Down
1 change: 1 addition & 0 deletions ersilia/cli/commands/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def publish_cmd():
Rebase a model:
$ ersilia publish rebase <model_id>
"""

def _publish(mf, model_id):
mf.publish(model_id)

Expand Down
1 change: 1 addition & 0 deletions ersilia/cli/commands/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def run_cmd():
Run a model with batch size:
$ ersilia run -i <input_data> -b 50
"""

# Example usage: ersilia run -i {INPUT} [-o {OUTPUT} -b {BATCH_SIZE}]
@ersilia_cli.command(short_help="Run a served model", help="Run a served model")
@click.option("-i", "--input", "input", required=True, type=click.STRING)
Expand Down
3 changes: 2 additions & 1 deletion ersilia/cli/commands/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def serve_cmd():
Serve a model and track the session:
$ ersilia serve <model_id> --track
"""

# Example usage: ersilia serve {MODEL}
@ersilia_cli.command(short_help="Serve model", help="Serve model")
@click.argument("model", type=click.STRING)
Expand Down Expand Up @@ -77,7 +78,7 @@ def serve(model, output_source, lake, port, track):
if mdl.url is None:
echo("No URL found. Service unsuccessful.", fg="red")
return

register_model_session(mdl.model_id, mdl.session._session_dir)
echo(
":rocket: Serving model {0}: {1}".format(mdl.model_id, mdl.slug), fg="green"
Expand Down
1 change: 1 addition & 0 deletions ersilia/cli/commands/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def setup_cmd():
Set up the environment with base installation:
$ ersilia setup --base
"""

# Example usage: ersilia setup
@ersilia_cli.command(
short_help="Setup ersilia",
Expand Down
Loading

0 comments on commit 68e3798

Please sign in to comment.