Skip to content

Commit 7abeba4

Browse files
authored
Merge pull request #132 from spjuhel/develop
v0.6.0 - Grace Brewster Hopper
2 parents b4eeaa0 + de2ee55 commit 7abeba4

File tree

72 files changed

+8291
-6820
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+8291
-6820
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ updates:
1010
target-branch: "develop"
1111
schedule:
1212
interval: "weekly"
13-
13+
1414
- package-ecosystem: "github-actions"
1515
# Workflow files stored in the default location of `.github/workflows`. (You don't need to specify `/.github/workflows` for `directory`. You can use `directory: "/"`.)
1616
directory: "/"

.github/pull_request_template.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Changes proposed in this PR:
2-
-
3-
-
2+
-
3+
-
44

55
This PR fixes #
66

.github/workflows/CI.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
strategy:
77
fail-fast: false
88
matrix:
9-
python-version: ["3.9", "3.10", "3.11"]
9+
python-version: ["3.10", "3.11", "3.12"]
1010
os: [ubuntu-latest, macos-latest, windows-latest]
1111
runs-on: ${{ matrix.os }}
1212
steps:
@@ -22,4 +22,4 @@ jobs:
2222
- name: Run black
2323
run: poetry run black --check --verbose ./boario
2424
- name: Run the automated tests (for example)
25-
run: poetry run pytest -v
25+
run: poetry run pytest -v

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pyrightconfig.json
99
shortlicence
1010
src/docs/source/_build
1111
docs/pages
12+
docs/source/_autosummary/
1213
testing
1314

1415
snakejob.*

.pre-commit-config.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# See https://pre-commit.com for more information
2+
default_language_version:
3+
python: python3
4+
5+
# See https://pre-commit.com/hooks.html for more hooks
6+
repos:
7+
- repo: https://github.com/pre-commit/pre-commit-hooks
8+
rev: v3.2.0
9+
hooks:
10+
- id: end-of-file-fixer
11+
- id: trailing-whitespace
12+
13+
# Using this mirror lets us use mypyc-compiled black, which is about 2x faster
14+
- repo: https://github.com/psf/black-pre-commit-mirror
15+
rev: '24.4.2'
16+
hooks:
17+
- id: black-jupyter

CONTRIBUTING.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ If you want to start working on a bug then please write short message on the iss
3939
Implement Features
4040
==================
4141

42-
Look through the Github issues for features or add your own request
43-
using the Code feature request template `here <https://github.com/spjuhel/BoARIO/issues/new/choose>`_
42+
Look through the Github issues for features or add your own request
43+
using the Code feature request template `here <https://github.com/spjuhel/BoARIO/issues/new/choose>`_
4444
and assign yourself.
4545

4646
Write Documentation
@@ -101,4 +101,4 @@ From the base BoARIO folder you call :code:`pytest` to run all the tests, or cho
101101
$ pytest
102102
$ pytest tests/tests.py::test_log_input
103103
104-
If you introduce a new feature you should add a new test to the tests directory. See the folder for examples.
104+
If you introduce a new feature you should add a new test to the tests directory. See the folder for examples.

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ This work was supported by the French Environment and Energy Management Agency
159159
Development
160160
------------
161161

162-
** Samuel Juhel (pro@sjuhel.org)
162+
- Samuel Juhel (pro@sjuhel.org)
163163

164164
Contributions
165165
---------------

api-examples/simulation/example-read_events_from_list.rstinc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@
5050
>>> }
5151
>>> ]
5252
>>> model.read_events_from_list(events)
53-
15:00:25 [INFO] - [simulation.py > read_events_from_list() > 417] - Reading events from given list and adding them to the model
53+
15:00:25 [INFO] - [simulation.py > read_events_from_list() > 417] - Reading events from given list and adding them to the model

boario/__init__.py

Lines changed: 7 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -16,72 +16,27 @@
1616

1717
"""BoARIO : The Adaptative Regional Input Output model in python."""
1818

19-
try:
20-
import coloredlogs as coloredlogs # noqa: F401
21-
except ImportError:
22-
_has_coloredlogs = False
23-
else:
24-
_has_coloredlogs = True
25-
2619
import importlib.metadata
2720
import logging
28-
from functools import lru_cache
2921

3022
__version__ = importlib.metadata.version("boario")
3123
__author__ = "sjuhel <pro@sjuhel.org>"
3224

25+
DEBUG_TRACE = False
3326
DEBUGFORMATTER = logging.Formatter(
34-
fmt="%(asctime)s - boario - [%(levelname)s] - [%(filename)s > %(funcName)s() > %(lineno)s] - %(message)s",
27+
fmt="%(asctime)s - [%(levelname)s] - [%(filename)s > %(funcName)s() > %(lineno)s] - %(message)s",
3528
datefmt="%H:%M:%S",
3629
)
3730
"""Debug file formatter."""
3831

39-
INFOFORMATTER = logging.Formatter(
40-
fmt="%(asctime)s - boario - [%(levelname)s] - %(message)s",
41-
datefmt="%H:%M:%S",
42-
)
43-
"""Info file formatter."""
44-
32+
# INFOFORMATTER = logging.Formatter(
33+
# fmt="%(asctime)s - [%(levelname)s] - %(message)s",
34+
# datefmt="%H:%M:%S",
35+
# )
36+
# """Info file formatter."""
4537

4638
# Create a logger object.
4739
logger = logging.getLogger(__name__)
48-
logger.setLevel(logging.INFO)
49-
50-
# Console logger
51-
ch = logging.StreamHandler()
52-
ch.setLevel(logging.INFO)
53-
ch.setFormatter(INFOFORMATTER)
54-
55-
# Avoid adding multiple handlers in case of repeated imports
56-
if not logger.handlers:
57-
logger.addHandler(ch)
58-
59-
60-
# Functions to activate/deactivate logging
61-
def deactivate_logging():
62-
"""Deactivate logging for the package."""
63-
logger.disabled = True
64-
65-
66-
def activate_logging():
67-
"""Activate logging for the package."""
68-
logger.disabled = False
69-
70-
71-
# Functions to disable/enable console logging
72-
def disable_console_logging():
73-
"""Disable console logging for the package."""
74-
logger.info(
75-
"Disabling logging. You can reenable it with `boario.enable_console_logging()`"
76-
)
77-
logger.removeHandler(ch)
78-
79-
80-
def enable_console_logging():
81-
"""Enable console logging for the package."""
82-
if ch not in logger.handlers:
83-
logger.addHandler(ch)
84-
8540

8641
try:
8742
import pygit2
@@ -95,16 +50,3 @@ def enable_console_logging():
9550
)
9651
except ModuleNotFoundError:
9752
logger.info("Unable to tell git branch as pygit2 was not found.")
98-
99-
100-
logger.info(
101-
"Loaded boario module. You can disable logging in console with `boario.disable_console_logging()`."
102-
)
103-
104-
105-
@lru_cache(10)
106-
def warn_once(logger, msg: str):
107-
logger.warning(msg)
108-
109-
110-
logger.propagate = False

boario/config.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from configparser import ConfigParser
2+
import os
3+
from pathlib import Path
4+
5+
6+
class Config:
7+
def __init__(self, user_conf_path=None):
8+
# Define paths for default and user configuration
9+
self.default_conf_path = (
10+
Path(__file__).parent / "boario-tools.conf"
11+
) # Package folder
12+
self.user_conf_path = Path(user_conf_path or Path.home() / ".boario-tools.conf")
13+
14+
# Initialize the ConfigParser and load configurations
15+
self.settings = self._load_config()
16+
17+
def _load_config(self):
18+
config = ConfigParser(os.environ)
19+
20+
config.read(self.default_conf_path)
21+
22+
if self.user_conf_path.exists():
23+
config.read(self.user_conf_path)
24+
return config
25+
26+
def get(self, section, option, fallback=None):
27+
return self.settings.get(section, option, fallback=fallback)
28+
29+
30+
# Then pass this config to custom_utils when using its functionality
31+
config = Config()

0 commit comments

Comments
 (0)