Skip to content

Commit

Permalink
Refactor project structure to follow Python module conventions (#5)
Browse files Browse the repository at this point in the history
* Refactor project structure to follow Python module conventions

* Add pytest-cov in requirements.txt

* Add coverage conf

* Remove code duplication: extension relies on design space base classes from smt

* Update license

* Expose only required symbols to work with smt at module level

* numpy has to be installed for CI tests

* Avoid importing version from main module

* Bump version 0.2.1

* Use smt master in CI tests

* Take into account smt changes (ext dep removal)

* Use smt master in requirements

* Bump 0.2.2
  • Loading branch information
relf authored Oct 18, 2024
1 parent a259e4c commit a97ee04
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 763 deletions.
14 changes: 14 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[paths]
source =
smt_design_space_ext

[html]
directory = coverage_html_report

[run]
relative_files = True
omit =
*/tests/*
*/examples/*
*/__init__.py
*/setup.py
26 changes: 2 additions & 24 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,6 @@ on:
tags: ['v*']

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- uses: actions/checkout@v4

- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_BUILD: cp38-* cp39-* cp310-* cp311-*
CIBW_SKIP: cp*_i686

- uses: actions/upload-artifact@v4
with:
name: smt-${{ matrix.os }}
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
Expand All @@ -38,20 +18,18 @@ jobs:

- uses: actions/upload-artifact@v4
with:
name: smt-src
name: smt-design-space-ext-src
path: dist/*.tar.gz

upload_pypi:
needs: [build_wheels, build_sdist]
needs: [build_sdist]
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
pattern: smt-*
merge-multiple: true
path: dist

- uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
68 changes: 2 additions & 66 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,67 +1,3 @@
![SMT Logo](./doc/smt_logo.png)
# Surrogate Modeling Toolbox
# SMT Design Space Extension

[![Tests](https://github.com/SMTOrg/smt/workflows/Tests/badge.svg)](https://github.com/SMTorg/smt/actions?query=workflow%3ATests)
[![Coverage Status](https://coveralls.io/repos/github/SMTorg/smt/badge.svg?branch=master)](https://coveralls.io/github/SMTorg/smt?branch=master)
[![Documentation Status](https://readthedocs.org/projects/smt/badge/?version=latest)](https://smt.readthedocs.io/en/latest/?badge=latest)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

The surrogate modeling toolbox (SMT) is a Python package that contains a collection of surrogate modeling methods, sampling techniques, and benchmarking functions. This package provides a library of surrogate models that is simple to use and facilitates the implementation of additional methods.

SMT is different from existing surrogate modeling libraries because of its emphasis on derivatives, including training derivatives used for gradient-enhanced modeling, prediction derivatives, and derivatives with respect to the training data.

It also includes new surrogate models that are not available elsewhere: kriging by partial-least squares reduction and energy-minimizing spline interpolation.
SMT is documented using custom tools for embedding automatically-tested code and dynamically-generated plots to produce high-quality user guides with minimal effort from contributors.

SMT is distributed under the New BSD license.

To cite SMT 2.0: P. Saves and R. Lafage and N. Bartoli and Y. Diouane and J. H. Bussemaker and T. Lefebvre and J. T. Hwang and J. Morlier and J. R. R. A. Martins. SMT 2.0: A Surrogate Modeling Toolbox with a focus on Hierarchical and Mixed Variables Gaussian Processes. Advances in Engineering Software, 2024.

```
@article{saves2024smt,
author = {P. Saves and R. Lafage and N. Bartoli and Y. Diouane and J. Bussemaker and T. Lefebvre and J. T. Hwang and J. Morlier and J. R. R. A. Martins},
title = {{SMT 2.0: A} Surrogate Modeling Toolbox with a focus on Hierarchical and Mixed Variables Gaussian Processes},
journal = {Advances in Engineering Sofware},
year = {2024},
volume = {188},
pages = {103571},
doi = {https://doi.org/10.1016/j.advengsoft.2023.103571}}
```

To cite SMT legacy: M. A. Bouhlel and J. T. Hwang and N. Bartoli and R. Lafage and J. Morlier and J. R. R. A. Martins. A Python surrogate modeling framework with derivatives. Advances in Engineering Software, 2019.

```
@article{SMT2019,
Author = {Mohamed Amine Bouhlel and John T. Hwang and Nathalie Bartoli and Rémi Lafage and Joseph Morlier and Joaquim R. R. A. Martins},
Journal = {Advances in Engineering Software},
Title = {A Python surrogate modeling framework with derivatives},
pages = {102662},
issn = {0965-9978},
doi = {https://doi.org/10.1016/j.advengsoft.2019.03.005},
Year = {2019}}
```

# Required packages
SMT depends on the following modules: numpy, scipy, scikit-learn, pyDOE3 and Cython.

# Installation
If you want to install the latest release

```
pip install smt
```

or else if you want to install from the current master branch

```
pip install git+https://github.com/SMTOrg/smt.git@master
```

# Usage
For examples demonstrating how to use SMT, you can take a look at the [tutorial notebooks](https://github.com/SMTorg/smt/tree/master/tutorial#readme) or go to the 'smt/examples' folder.

# Documentation
[Documentation of Surrogate Modeling Toolbox](http://smt.readthedocs.io/en/stable).

# Contributing
To contribute to SMT refer to the [contributing section](https://smt.readthedocs.io/en/latest/_src_docs/dev_docs.html#contributing-to-smt) of the documentation.
This module allows to use advanced design space implementation for hierachical variables handling.
1 change: 0 additions & 1 deletion __version__.py

This file was deleted.

20 changes: 5 additions & 15 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
Cython
numpy
scipy
scikit-learn
pyDOE3
numba # JIT compiler
matplotlib # used in examples and tests
pytest # tests runner
pytest-xdist # allows running parallel testing with pytest -n <num_workers>
pytest-cov # allows to get coverage report
ruff # format and lint code
smt
jenn >= 1.0.2, <2.0
egobox ~= 0.20.0
smt @ git+https://github.com/SMTorg/smt@master
ConfigSpace==0.6.1
adsg-core==1.1.1
adsg-core==1.1.1
pytest # tests runner
pytest-cov # allows to get coverage report
ruff # format and lint code
23 changes: 9 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,29 @@

from setuptools import setup

version = {}
with open("./__version__.py") as fp:
exec(fp.read(), version)

# Import __version__ without importing the module in setup
exec(open("./smt_design_space_ext/version.py").read())

setup(
name="smt_design_space",
name="smt_design_space_ext",
version=__version__, # noqa
author="Paul Saves et al.",
author_email="[email protected]",
keywords=["SMT, DesignSpace, Graph"],
license="ONERA",
description="SMT Design Space",
license="BSD-3",
description="SMT design space extension for hierarchical variables handling",
install_requires=[
"scipy",
"numpy",
"scikit-learn",
"smt",
"ConfigSpace==0.6.1",
"adsg-core==1.1.1",
],
maintainer="Paul Saves",
maintainer_email="[email protected]",
packages=[
"smt_design_space",
"smt_design_space_ext",
],
include_package_data=True,
python_requires=">=3.8",
version=version["__version__"],
zip_safe=False,
python_requires=">=3.9",
url="https://github.com/SMTorg/smt-design-space", # use the URL to the github repo
download_url="https://github.com/SMTorg/smt-design-space/releases",
)
9 changes: 9 additions & 0 deletions smt_design_space_ext/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from .version import __version__

# Symbols imported in smt to handle hierarchical variables
from smt_design_space_ext.design_space import (
DesignSpace,
ensure_design_space,
)

__all__ = ["__version__", "DesignSpace", "ensure_design_space"]
Loading

0 comments on commit a97ee04

Please sign in to comment.