Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/pre commit hooks #94

Merged
merged 55 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
6f1f4e8
Fix flake config
Apr 12, 2023
3c50ce4
Refactor docstrings, ignore D102 (missing docstring) for overwritten …
helegraf Apr 12, 2023
12b2c6a
Ignore missing inputs
Apr 12, 2023
240a7c2
Refactor docstrings.
helegraf Apr 12, 2023
f6877b8
Fix mypy errors in utils files
Apr 12, 2023
f815346
Solve merge conflict
Apr 12, 2023
021cbe9
Refactor docstrings
helegraf Jun 28, 2023
4d796df
Add type ignores/ types
helegraf Jun 28, 2023
c973068
Eliminated all D401 in pre-commit
KrissiHub Aug 15, 2023
1dc0505
added a few docstrings
KrissiHub Aug 25, 2023
af13db4
added docstrings
KrissiHub Aug 26, 2023
24d3ee4
added more docstrings
KrissiHub Aug 27, 2023
c0a6a60
added even more docstrings
KrissiHub Aug 28, 2023
a36a4bc
more docstrings added
KrissiHub Aug 28, 2023
388bf37
pydocstyle passes
KrissiHub Aug 29, 2023
d7732ef
added all docstrings
KrissiHub Sep 12, 2023
a87b743
added type annotations and changed the make file
KrissiHub Oct 5, 2023
bce1de4
added some more type annotations
KrissiHub Oct 5, 2023
8baf7fc
changed pre commit, so all errors get caught
KrissiHub Oct 10, 2023
e053e92
fixed a few type annotation problems
KrissiHub Oct 11, 2023
0f00bb7
fixed a few type annotations
KrissiHub Oct 30, 2023
1327166
fixed a few type annotations
KrissiHub Nov 1, 2023
c2d4b90
ajust docs to type annotations
KrissiHub Nov 6, 2023
fea9889
changed a few docstrings
KrissiHub Nov 6, 2023
e20d749
ready for a draft
KrissiHub Nov 6, 2023
e620250
changed a few details
KrissiHub Nov 13, 2023
0391d60
docstrings and noqa/type ignores revised
KrissiHub Nov 14, 2023
2fc0361
changed a few small details
KrissiHub Nov 17, 2023
0d49311
tests should run trough now
KrissiHub Nov 22, 2023
ba394c9
added an install command for examples
KrissiHub Nov 22, 2023
dec68b6
Merge branch 'main' into bug/pre-commit-hooks
KrissiHub Nov 22, 2023
22cf5c9
resolved a conflict
KrissiHub Nov 22, 2023
a78ea11
Merge branch 'main' into bug/pre-commit-hooks
KrissiHub Nov 23, 2023
6e9e9bf
resolved conflicts
KrissiHub Nov 23, 2023
8ab95e7
merge should have worked now
KrissiHub Nov 23, 2023
0909690
docs test error resolved - hopefully
KrissiHub Nov 23, 2023
ff69418
Changed the changelog file accordingly
KrissiHub Nov 23, 2023
4c0dbf6
Fixed Issue #80
KrissiHub Dec 1, 2023
1396581
Fixed a minor merge issue
KrissiHub Dec 1, 2023
3e45b16
revised the evaluators documentation
KrissiHub Jan 19, 2024
a16d3ae
revised layout documentation
KrissiHub Jan 19, 2024
f487b5c
revised a few plugin docstrings
KrissiHub Jan 19, 2024
06276c6
revised a few plugin docstrings
KrissiHub Jan 20, 2024
affdb1a
revised more plugin docstrings
KrissiHub Jan 21, 2024
49e3249
plugin docstrings revised
KrissiHub Jan 22, 2024
d91f3dd
revised the converter docstrings
KrissiHub Jan 25, 2024
1c4c55a
revised more runs docstrings
KrissiHub Jan 25, 2024
bb61cd4
revised runs docstrings
KrissiHub Feb 8, 2024
dadc8cb
revised utils docstrings
KrissiHub Feb 8, 2024
021a111
revised remaining docstrings
KrissiHub Feb 8, 2024
b40b6da
reformatted docstrings for pydocstyle again
KrissiHub Feb 8, 2024
4502afe
minor details adjusted
KrissiHub Feb 8, 2024
967692d
fixed non existing variable model_opt
KrissiHub Feb 9, 2024
f753273
Solve merge conflict
Feb 22, 2024
4eacae3
Minor fixes from PR
Feb 23, 2024
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
6 changes: 4 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ extend-exclude =
.venv
build
extend-ignore =
E203 # No whitespace before ':' in [x : y]
E731 # No lambdas — too strict
# No whitespace before ':' in [x : y]
E203
# No lambdas — too strict
E731
30 changes: 27 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repos:
files: tests

- repo: https://github.com/ambv/black
rev: 23.1.0
rev: 23.3.0
hooks:
- id: black
name: black formatter deepcave
Expand All @@ -33,14 +33,38 @@ repos:
hooks:
- id: pydocstyle
files: deepcave
additional_dependencies: ["toml"] # Needed to parse pyproject.toml
additional_dependencies: ["tomli"] # Needed to parse pyproject.toml

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.930
rev: v1.5.1
hooks:
- id: mypy
name: mypy deepcave
files: deepcave
args: [--install-types, --non-interactive]
additional_dependencies: [
'wheel>=0.41.2',
'setuptools==68.2.2',
'absl-py>=1.0.0',
'jsonlines>=3.0.0',
'pandas>=1.3.4',
'numpy>=1.22.2',
'matplotlib>=3.5.1',
'pyyaml>=6.0.1',
'kaleido>=0.2.1',
'gplearn>=0.4.2',
'sympy>=1.12',
'ConfigSpace==0.6.1',
'pyrfr>=0.9.0',
'hpbandster==0.7.4',
'dash==2.0.0',
'dash-extensions==0.0.71',
'dash-bootstrap-components==1.0.3',
'redis>=4.1.4',
'rq>=1.10.1',
'werkzeug==2.0.3',
'pyPDPPartitioner>=0.1.8'
] # Needed for mypy, so that it knows the types to check

- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@
- Fix errors due to changing inputs before runselection (#64).
- For fANOVA, remove constant hyperparameters from configspace (#9).

## Version-Updates
- Black version from 23.1.0 to 23.3.0
- Mypy from 0.930 to 1.5.1

## Mypy
- Updated args so there are no missing imports
- Updated additional dependencies, so mypy can check all types
- Note: If the installs in requirements change, it has to be adapted in additional dependencies
- Added many type annotations
- In some cases internal refactoring for variables, due to typing

## Pydocstyle and Linter
- Major overhaul of docstrings in various files
- Removed unused imports and variables

## Additional Changes
- Added a "make install examples" in Makefile

# Version 1.1.3

## Bug-Fixes
Expand Down
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ install:
install-dev:
$(PIP) install -e ".[dev]"
pre-commit install


install-examples:
$(PIP) install -e ".[examples]"

check-black:
$(BLACK) ${SOURCE_DIR} --check || :
$(BLACK) ${EXAMPLES_DIR} --check || :
Expand All @@ -62,7 +65,7 @@ check-pydocstyle:
$(PYDOCSTYLE) ${SOURCE_DIR} || :

check-mypy:
$(MYPY) ${SOURCE_DIR} || :
$(MYPY) --check-untyped-defs --install-types --non-interactive --ignore-missing-imports ${SOURCE_DIR} || :

check-flake8:
$(FLAKE8) ${SOURCE_DIR} || :
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ conda install -c anaconda swig
make install-dev
```

If you want to use the given examples, run this after installing:
```bash
make install-examples
```

Please visit the [documentation](https://automl.github.io/DeepCAVE/main/installation.html) to get
further help (e.g. if you can not install redis server or you are on a mac).

Expand Down
57 changes: 54 additions & 3 deletions deepcave/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# noqa: D400
"""
# DeepCAVE

This module is used to initialize and set up the configuration for the DeepCAVE framework.

The Dash application gets created.
"""

from typing import Any, Callable, TypeVar, cast

import datetime
Expand Down Expand Up @@ -25,7 +34,20 @@
ROOT_DIR = Path(__file__).parent


def get_app(title: str):
def get_app(title: str) -> Any:
"""
Get the Dash Proxy.

Parameters
----------
title : str
The title of the application.

Returns
-------
DashProxy
The dash proxy.
"""
import dash_bootstrap_components as dbc
from dash_extensions.enrich import (
DashProxy,
Expand Down Expand Up @@ -61,8 +83,8 @@ def get_app(title: str):
if any(file in _exec_file for file in _exec_files):
from deepcave.custom_queue import Queue
from deepcave.runs.handler import RunHandler
from deepcave.runs.objective import Objective # noqa
from deepcave.runs.recorder import Recorder # noqa
from deepcave.runs.objective import Objective
from deepcave.runs.recorder import Recorder
from deepcave.utils.cache import Cache
from deepcave.utils.configs import parse_config
from deepcave.utils.notification import Notification
Expand Down Expand Up @@ -129,8 +151,37 @@ def get_app(title: str):


def interactive(func: F) -> F:
"""
Define the interactive decorator.

Parameters
----------
func : F
The function to be decorated.

Returns
-------
F
The decorated function.
"""

@wraps(func)
def inner(*args: Any, **kwargs: Any) -> Any:
"""
Inner function of the decorator.

Parameters
----------
*args : Any
Arguments to be passed to the wrap function.
**kwargs : Any
Keyword arguments to be passed to the wrap function.

Returns
-------
Any
The result of the function.
"""
if _api_mode:
return

Expand Down
15 changes: 14 additions & 1 deletion deepcave/cli.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# noqa: D400
"""
# CLI

This module defines command-line options using flags.

This includes the entry point for the programs execution.
"""

from typing import Any

import multiprocessing
import subprocess
from pathlib import Path
Expand All @@ -21,7 +32,8 @@
)


def execute(_) -> None:
def execute(_: Any) -> None:
"""Entry point for the programs execution."""
if (config_key := FLAGS.get_config_value) is not None:
config = FLAGS.config
if config is not None:
Expand All @@ -47,6 +59,7 @@ def execute(_) -> None:


def main() -> None:
"""Call the execute function."""
try:
app.run(execute)
except KeyboardInterrupt:
Expand Down
49 changes: 48 additions & 1 deletion deepcave/config.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,50 @@
# noqa: D400
"""
# Config

This module defines the config object and its constants.
Also defines multiple constants for directories, the server name, available plugins and converters.

## Classes
- Config: Describe the config object.
"""

from typing import Any, Dict, List, Type

from pathlib import Path

from deepcave.runs.run import Run


class Config:
"""
Describe the config object.

Also define the constants of the config object.
Includes multiple constants for directories, the server name, available plugins and converters.

Constants
---------
TITLE : str
DEBUG: bool
REFRESH_RATE: int
SAVE_IMAGES: bool
FIGURE_MARGIN: Dict
FIGURE_HEIGHT: str
REDIS_PORT: int
REDIS_ADDRESS: str
DASH_PORT: int
DASH_ADDRESS: str
META_DEFAULT: Dict

Properties
----------
DASH_ADRESS : str
The address of the server name.
DASH_PORT : int
The port of the server name.
"""

# General config
TITLE: str = "DeepCAVE"
DEBUG: bool = False
Expand Down Expand Up @@ -34,18 +75,22 @@ class Config:

@property
def DEFAULT_WORKING_DIRECTORY(self) -> Path:
"""Specifies the default working directory."""
return Path.cwd() / "logs"

@property
def CACHE_DIR(self) -> Path:
"""Specifies the default cache directory."""
return Path(__file__).parent / "cache"

@property
def SERVER_NAME(self) -> str:
"""Specifies the server name, consisting of address and port."""
return f"http://{self.DASH_ADDRESS}:{self.DASH_PORT}"

@property
def PLUGINS(self) -> Dict[str, List["Plugin"]]:
def PLUGINS(self) -> Dict[str, List[Any]]:
"""A list of available plugins per category."""
from deepcave.plugins.budget.budget_correlation import BudgetCorrelation
from deepcave.plugins.hyperparameter.importances import Importances
from deepcave.plugins.hyperparameter.pdp import PartialDependencies
Expand All @@ -60,6 +105,7 @@ def PLUGINS(self) -> Dict[str, List["Plugin"]]:
from deepcave.plugins.summary.footprint import FootPrint
from deepcave.plugins.summary.overview import Overview

plugins: Dict[str, List[Any]] = {}
plugins = {
"Summary": [
Overview(),
Expand All @@ -85,6 +131,7 @@ def PLUGINS(self) -> Dict[str, List["Plugin"]]:

@property
def CONVERTERS(self) -> List[Type["Run"]]:
"""Get a list of available run converters."""
from deepcave.runs.converters.bohb import BOHBRun
from deepcave.runs.converters.deepcave import DeepCAVERun
from deepcave.runs.converters.smac3v1 import SMAC3v1Run
Expand Down
17 changes: 17 additions & 0 deletions deepcave/constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# noqa: D400
"""
# Constants

This module defines the constants for the DeepCAVE framework.

## Constants
NAN_VALUE: float
NAN_LABEL: str
VALUE_RANGE: List
CONSTANT_VALUE: float
BORDER_CONFIG_ID: int
RANDOM_CONFIG_ID: innt
COMBINED_COST_NAME: str
COMBINED_BUDGET: int
"""

NAN_VALUE = -0.2
NAN_LABEL = "NaN"
VALUE_RANGE = [NAN_VALUE, 1]
Expand Down
Loading
Loading