Skip to content

Commit

Permalink
Merge pull request #1 (lint and format with ruff)
Browse files Browse the repository at this point in the history
Lint and format with `ruff`
  • Loading branch information
tlestang authored Jan 13, 2025
2 parents ee5b55e + 7a8a036 commit 8573a81
Show file tree
Hide file tree
Showing 135 changed files with 25,767 additions and 16,332 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Lint, format and tests

on:
push:
branches:
- 'main'
pull_request:

jobs:
ruff-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v3
with:
python-version: "3.12"
- run: pip install ruff==0.9.*
- run: ruff check src/

ruff-format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v3
with:
python-version: "3.12"
- run: pip install ruff==0.9.*
- run: ruff format --check src/

6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@ where = ["src"]
[tool.setuptools.package-data]
"vortex.data" = ["geometries.ini"]
"vortex.algo" = ["mpitools_templates/*.tpl"]

[tool.ruff]
line-length = 79

[tool.ruff.lint]
ignore = ["E741"]
99 changes: 61 additions & 38 deletions src/vortex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,45 +20,64 @@
strongly advised.
"""

__version__ = '2.0.0b1'
__prompt__ = 'Vortex v-' + __version__ + ':'
import atexit
import importlib.metadata

from bronx.fancies import loggers as bloggers
import bronx.stdtypes.date

__nextversion__ = '2.0.0b2'
__tocinfoline__ = 'VORTEX core package'
import footprints

# Populate a fake proxy module with footprints shortcuts
from . import proxy, tools, sessions, config

# vortex user API
from .toolbox import input as input
from .toolbox import output as output
from .toolbox import executable as executable
from .toolbox import promise as promise
from .toolbox import diff as diff
from .toolbox import defaults as defaults
from .toolbox import algo as task

from . import nwp as nwp # footprints import

__version__ = "2.0.0b1"
__prompt__ = "Vortex v-" + __version__ + ":"

__nextversion__ = "2.0.0b2"
__tocinfoline__ = "VORTEX core package"

__all__ = [
"input", "output", "executable", "task", "promise", "diff",
"input",
"output",
"executable",
"task",
"promise",
"diff",
]

# Set vortex specific priorities for footprints usage

from bronx.fancies import loggers as bloggers

import footprints
footprints.priorities.set_before('debug', 'olive', 'oper')
footprints.priorities.set_before("debug", "olive", "oper")

# Set a root logging mechanism for vortex

#: Shortcut to Vortex's root logger
logger = bloggers.getLogger('vortex')

# Populate a fake proxy module with footprints shortcuts
logger = bloggers.getLogger("vortex")

from . import proxy
setup = footprints.config.get()
setup.add_proxy(proxy)
proxy.cat = footprints.proxy.cat
proxy.objects = footprints.proxy.objects

# Set a background environment and a root session

from . import tools
from . import sessions
from . import config

rootenv = tools.env.Environment(active=True)

rs = sessions.get(active=True, topenv=rootenv, glove=sessions.getglove(), prompt=__prompt__)
rs = sessions.get(
active=True, topenv=rootenv, glove=sessions.getglove(), prompt=__prompt__
)
if rs.system().systems_reload():
rs.system(refill=True)
del rs
Expand All @@ -70,8 +89,7 @@ def vortexfpdefaults():
"""Return actual glove, according to current environment."""
cur_session = sessions.current()
return dict(
glove=cur_session.glove,
systemtarget=cur_session.sh.default_target
glove=cur_session.glove, systemtarget=cur_session.sh.default_target
)


Expand All @@ -87,49 +105,54 @@ def vortexfpdefaults():

class VortexForceComplete(Exception):
"""Exception for handling fast exit mecanisms."""

pass


# If a config file can be found in current dir, load it
config.load_config()

# Load some superstars sub-packages
from .toolbox import (
input,
output,
executable,
promise,
diff,
defaults,
)
from .toolbox import algo as task
from . import nwp


# Now load plugins that have been installed with the
# 'vtx' entry point. Order matters: since plugins
# will typically depend on objects defined in 'vortex'
# and 'vortex.nwp', these must be imported /before/
# loading plugins.
from importlib.metadata import entry_points
for plugin in entry_points(group='vtx'):
for plugin in importlib.metadata.entry_points(group="vtx"):
plugin.load()
print(f"Loaded plugin {plugin.name}")

# Register proper vortex exit before the end of interpreter session

import bronx.stdtypes.date
# Register proper vortex exit before the end of interpreter session
def complete():
sessions.exit()
import multiprocessing

for kid in multiprocessing.active_children():
logger.warning('Terminate active kid %s', str(kid))
logger.warning("Terminate active kid %s", str(kid))
kid.terminate()
print('Vortex', __version__, 'completed', '(', bronx.stdtypes.date.at_second().reallynice(), ')')
print(
"Vortex",
__version__,
"completed",
"(",
bronx.stdtypes.date.at_second().reallynice(),
")",
)


import atexit
atexit.register(complete)
del atexit, complete

print('Vortex', __version__, 'loaded', '(', bronx.stdtypes.date.at_second().reallynice(), ')')
print(
"Vortex",
__version__,
"loaded",
"(",
bronx.stdtypes.date.at_second().reallynice(),
")",
)

del footprints
5 changes: 3 additions & 2 deletions src/vortex/algo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
Application specific AlgoComponent classes should be defined in dedicated packages.
"""

from . import components, serversynctools
from . import components as components
from . import serversynctools as serversynctools

#: No automatic export
__all__ = []

__tocinfoline__ = 'Generic AlgoComponent classes (and their utility classes)'
__tocinfoline__ = "Generic AlgoComponent classes (and their utility classes)"
Loading

0 comments on commit 8573a81

Please sign in to comment.