Skip to content

Commit

Permalink
Merge branch 'main' into feat/JAQPOT-62/torch-graph-training
Browse files Browse the repository at this point in the history
  • Loading branch information
jpitoskas authored Jun 14, 2024
2 parents 044c87d + 198b1c0 commit c3227d2
Show file tree
Hide file tree
Showing 146 changed files with 1,512 additions and 83,769 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Build and test

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
34 changes: 34 additions & 0 deletions .github/workflows/pipy_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Publish to PyPI 📦

on:
push:
tags:
- '*'

jobs:
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: '3.10'
- name: Install pypa/setuptools
run: >-
python -m
pip install wheel
- name: Extract tag name
id: tag
run: echo ::set-output name=TAG_NAME::$(echo $GITHUB_REF | cut -d / -f 3)
- name: Update version in setup.py
run: >-
sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.tag.outputs.TAG_NAME }}/g" setup.py
- name: Build a binary wheel
run: >-
python setup.py sdist bdist_wheel
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
20 changes: 20 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "Lint PR"

on:
pull_request_target:
types:
- opened
- edited
- synchronize

permissions:
pull-requests: read

jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
104 changes: 53 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,91 +1,93 @@
[![Build and test](https://github.com/ntua-unit-of-control-and-informatics/jaqpotpy/actions/workflows/ci.yml/badge.svg)](https://github.com/ntua-unit-of-control-and-informatics/jaqpotpy/actions/workflows/ci.yml) [![Publish to PyPI 📦](https://github.com/ntua-unit-of-control-and-informatics/jaqpotpy/actions/workflows/pipy_release.yml/badge.svg)](https://github.com/ntua-unit-of-control-and-informatics/jaqpotpy/actions/workflows/pipy_release.yml)

# Jaqpotpy
## _Standardizing molecular modeling_

# Jaqpot
The jaqpotpy library enables you to upload and deploy machine learning models to the Jaqpot platform. Once uploaded, you can manage, document, and share your models via the Jaqpot user interface at **https://app.jaqpot.org**. You can also make predictions online or programmatically using the Jaqpot API.

Jaqpot platform is a model repo developed in python and jaqpotpy making the models accessible through a user interface, that allows extensive documentation of the models and sharing through your contacts.
## Getting Started

### Prerequisites

## jaqpotpy
- Python 3.x
- An account on **https://app.jaqpot.org**

jaqpotpy enables model deployment with a simple command.
### Installation

### First register to Jaqpot through **https://app.jaqpot.org**
Install jaqpotpy using pip:

`jaqpot = Jaqpot()` initializes jaqpot upon the standard available API that
is integrated with the application and user interface at **https://app.jaqpot.org/** .



### Let jaqpot know who you are

Login and have access on the jaqpot services

In order to do so you can use the functions:

* `jaqpot.login('username', 'password')`

Will login and set the api key that is needed.

* `jaqpot.request_key('username', 'password')`

Same as above you request the key and set it on jaqpot

* `jaqpot.request_key_safe()`

Will ask the user for the username and password by hidding the password if
jaqpot is used through a jupiter notebook etc
```bash
pip install jaqpotpy
```

### Set Key without login
### Logging In

Some users may have logged in through google or github. At the account page
a user can find an api key that can be used in order to have access on the services.
These keys have short life and should be updated on each login.
To use jaqpotpy, you need to log in to the Jaqpot platform. You can log in using your username and password or by setting an API key.

* `jaqpot.set_api_key("api_key")`
#### Login with Username and Password

#### Get the key from user interface
```python
from jaqpotpy import Jaqpot

jaqpot = Jaqpot()
jaqpot.login('your_username', 'your_password')
```

### Model training and deployment
#### Request and Set API Key

You can request an API key and set it:
```python
jaqpot.request_key('your_username', 'your_password')
```
or
```python
jaqpot.request_key_safe() # Prompts for username and password securely
```
#### Set API Key Directly

An example code that demonstrates a model deployemnt.
If you already have an API key (you can retrieve one from https://app.jaqpot.org), you can set it directly:

```python
jaqpot.set_api_key("your_api_key")
```

### Model Training and Deployment

Follow these steps to train and deploy your model on Jaqpot:

* Warning! One of the things that may differ from simpler training and validation routes is that you need to train your model with a pandas dataframe as input and not with Numpy arrays!
1. Train your model using pandas DataFrame as input.
2. Deploy the trained model using the deploy_on_jaqpot function.

#### Example Code
_Note: Ensure you use a pandas DataFrame for training your model._

```python
from jaqpotpy import Jaqpot
import pandas as pd
from sklearn.linear_model import LinearRegression

# Initialize Jaqpot
jaqpot = Jaqpot()

# Load your data
df = pd.read_csv('/path/to/gdp.csv')
lm = LinearRegression()

# Train your model
lm = LinearRegression()
y = df['GDP']
X = df[['LFG', 'EQP', 'NEQ', 'GAP']]

model = lm.fit(X=X, y=y)

jaqpot.deploy_sklearn(model, X, y, title="Title", description="Describe")
# Deploy the model on Jaqpot
jaqpot.deploy_sklearn(model, X, y, title="GDP Model", description="Predicting GDP based on various factors")
```

The function will inform you about the model id that is created and is available through the user interface and the API.
The function will provide you with the model ID that you can use to manage your model through the user interface and API.

Result:
```text
- INFO - Model with ID: <model_id> created. Visit the application to proceed.
```

* Result


- INFO - Model with id: <model_id> created. Visit the application to proceed



### Continue furter through the jaqpot user interface

#### Managing Your Models

You can further manage your models through the Jaqpot user interface at https://app.jaqpot.org. This platform allows you to view detailed documentation, share models with your contacts, and make predictions.
10 changes: 10 additions & 0 deletions etc/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

# [DEPRECATED] Previous script to upload jaqpotpy library to pip
# This will be moved to a github action after creating a release

python setup.py bdist_wheel
twine upload dist/*
twine upload --repository testpypi dist/jaqpotpy-2.0.0b0-py3-none-any.whl
twine upload dist/jaqpotpy-1.0.84-py3-none-any.whl
docker build -t upcintua/jaqpotpy:1.0.3 --no-cache python setup.py bdist_wheel--build-arg tag=1.0.3 .
16 changes: 16 additions & 0 deletions jaqpotpy/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": false
}
]
}
1 change: 0 additions & 1 deletion jaqpotpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from .jaqpot import Jaqpot


__version__ = '1.0.100'
2 changes: 1 addition & 1 deletion jaqpotpy/cfg/tests/test_config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest
from jaqpotpy.cfg import config


@unittest.skip("Not clear what this test was supposed to do")
class TestConfig(unittest.TestCase):

def test_config_1(self):
Expand Down
8 changes: 5 additions & 3 deletions jaqpotpy/datasets/tests/test_material_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,22 +138,23 @@ def setUp(self) -> None:

# self.path = ''


@unittest.skip("Material modelling has not been tested yet in the newest version of jaqpotpy")
def test_composition_manual(self):
featurizer = ElementNet()
dataset = CompositionDataset(compositions=self.compositions, y=self.ys_regr, task='regression', featurizer=featurizer)
dataset.create()
# print(dataset.materials)
return


@unittest.skip("Material modelling has not been tested yet in the newest version of jaqpotpy")
def test_composition_csv(self):
featurizer = ElementNet()
dataset = CompositionDataset(path=self.path, compositions='Comps', keep_cols=['Feature1','Feature2'], y_cols=['class','reg'], task='regression', featurizer=featurizer)
dataset.create()
assert 'Feature1' in dataset.df.columns
return


@unittest.skip("Material modelling has not been tested yet in the newest version of jaqpotpy")
def test_structure_from_structs(self):
featurizer = SineCoulombMatrix()
structs = [
Expand All @@ -165,6 +166,7 @@ def test_structure_from_structs(self):
assert 'Feat_0' in dataset.df.columns
assert 'Endpoint' in dataset.df.columns

@unittest.skip("Material modelling has not been tested yet in the newest version of jaqpotpy")
def test_structure_from_dict(self):
featurizer = SineCoulombMatrix()
dataset = StructureDataset(structures=[{
Expand Down
Loading

0 comments on commit c3227d2

Please sign in to comment.