From a84b7fc7725e57c0592dbf66840bdc6f83b5e331 Mon Sep 17 00:00:00 2001 From: Julien Esseiva Date: Thu, 3 Oct 2024 17:35:37 -0700 Subject: [PATCH 1/5] add pyproject setup --- .gitignore | 2 ++ pyproject.toml | 61 ++++++++++++++++++++++++++++++++++++++++ setup.py | 44 ----------------------------- src/raythena/__init__.py | 6 +++- 4 files changed, 68 insertions(+), 45 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/.gitignore b/.gitignore index 11eda8d..13dfb85 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ core .vscode .idea build +dist +src/raythena/_version.py diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..a39f0b6 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,61 @@ +[build-system] +requires = ["hatchling", "hatch-vcs"] +build-backend = "hatchling.build" + +[project] +name = "raythena" +dynamic = ["version"] +readme = "README.md" +license = {file = "LICENSE"} +authors = [ + { name = "Julien Esseiva", email = "jesseiva@lbl.gov" }, +] +requires-python = ">=3.11" +dependencies = [ + "aiohttp", + "click", + "protobuf", + "psutil", + "ray", + "setproctitle", + "uvloop", +] + +[project.scripts] +raythena = "raythena.scripts.raythena:main" + +[tool.hatch.version] +source = "vcs" + +[tool.hatch.build.hooks.vcs] +version-file = "src/raythena/_version.py" + +[tool.hatch.envs.test] +dependencies = [ + "pytest" +] + +[tool.hatch.build.targets.wheel.shared-data] +"conf/cori.yaml" = "conf/cori.yaml" + +[tool.ruff] + +line-length = 80 +indent-width = 4 + +[tool.ruff.lint] + +select = [ + # pycodestyle + "E", + # Pyflakes + "F", + # pyupgrade + "UP", + # flake8-bugbear + "B", + # flake8-simplify + "SIM", + # isort + "I" +] diff --git a/setup.py b/setup.py deleted file mode 100644 index a01dd7b..0000000 --- a/setup.py +++ /dev/null @@ -1,44 +0,0 @@ -from setuptools import setup, find_packages -import re - - -def find_version(path): - with open(path) as fp: - version_match = re.search( - r"^__version__ = ['\"]([^'\"]*)['\"]", fp.read(), re.M - ) - if version_match: - return version_match.group(1) - - -setup( - name='raythena', - version=find_version('src/raythena/__init__.py'), - author='Miha Muskinja', - author_email='MihaMuskinja@lbl.gov', - packages=find_packages(where='src'), - package_dir={'': 'src'}, - scripts=[ - 'bin/ray_start_head', - 'bin/ray_start_worker', - 'bin/ray_sync', - 'bin/validate-raythena-job.py', - 'example/setup_ray_cluster_slurm.sh', - 'example/standalone_ray_test_hello_world.py', - ], - entry_points={ - 'console_scripts': ['raythena=raythena.scripts.raythena:main'] - }, - data_files=[ - ('conf', ['conf/cori.yaml']) - ], - install_requires=[ - 'ray', - 'psutil', - 'uvloop', - 'aiohttp', - 'click', - 'setproctitle', - 'protobuf', - ] -) diff --git a/src/raythena/__init__.py b/src/raythena/__init__.py index 5becc17..c010cb0 100644 --- a/src/raythena/__init__.py +++ b/src/raythena/__init__.py @@ -1 +1,5 @@ -__version__ = "1.0.0" +try: + from . import _version + __version__ = _version.__version__ +except: # noqa: E722 + __version__ = "0.0.0" From 986fce5c7db34502cd41fa5019a4f2dec642ecec Mon Sep 17 00:00:00 2001 From: Julien Esseiva Date: Thu, 3 Oct 2024 17:49:20 -0700 Subject: [PATCH 2/5] update actions --- .github/workflows/main.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4714050..4b040aa 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,22 +11,24 @@ on: jobs: tests: name: tests - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - name: Checkout repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup python version uses: actions/setup-python@v4 with: python-version: '3.11.3' architecture: x64 - name: Restore cached deps - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }} + key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }} restore-keys: | ${{ runner.os }}-pip- + - name: Install Hatch + uses: pypa/hatch@a3c83ab3d481fbc2dc91dd0088628817488dd1d5 - name: Install application and deps run: | python -m pip install --upgrade pip @@ -37,5 +39,4 @@ jobs: flake8 . - name: Run tests run: | - pip install pytest requests six - pytest + hatch run test:pytest From f30250476d2205b314f9fd6c6ace785cb31aa4c4 Mon Sep 17 00:00:00 2001 From: Julien Esseiva Date: Thu, 3 Oct 2024 17:51:46 -0700 Subject: [PATCH 3/5] fix whitespace --- src/raythena/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/raythena/__init__.py b/src/raythena/__init__.py index c010cb0..70edd66 100644 --- a/src/raythena/__init__.py +++ b/src/raythena/__init__.py @@ -1,4 +1,4 @@ -try: +try: from . import _version __version__ = _version.__version__ except: # noqa: E722 From 374ee228990f3eb6651d90610c0d29ed2b712cb8 Mon Sep 17 00:00:00 2001 From: Julien Esseiva Date: Fri, 4 Oct 2024 11:44:58 -0700 Subject: [PATCH 4/5] update python version, install scripts --- pyproject.toml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a39f0b6..be8d499 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ license = {file = "LICENSE"} authors = [ { name = "Julien Esseiva", email = "jesseiva@lbl.gov" }, ] -requires-python = ">=3.11" +requires-python = ">=3.9" dependencies = [ "aiohttp", "click", @@ -35,6 +35,10 @@ dependencies = [ "pytest" ] +[tool.hatch.build.targets.wheel.shared-scripts] +"bin/ray_start_head" = "ray_start_head" +"bin/ray_start_worker" = "ray_start_worker" + [tool.hatch.build.targets.wheel.shared-data] "conf/cori.yaml" = "conf/cori.yaml" From fb25930edd4075e2838cb7a84ff4060eb405b1f4 Mon Sep 17 00:00:00 2001 From: Julien Esseiva Date: Fri, 4 Oct 2024 12:26:42 -0700 Subject: [PATCH 5/5] add ray_sync script --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index be8d499..113b8b4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,6 +38,7 @@ dependencies = [ [tool.hatch.build.targets.wheel.shared-scripts] "bin/ray_start_head" = "ray_start_head" "bin/ray_start_worker" = "ray_start_worker" +"bin/ray_sync" = "ray_sync" [tool.hatch.build.targets.wheel.shared-data] "conf/cori.yaml" = "conf/cori.yaml"