Skip to content

Commit c0d8aeb

Browse files
committed
Migrate to uv and commit hook
1 parent 72f1d19 commit c0d8aeb

File tree

11 files changed

+2512
-151
lines changed

11 files changed

+2512
-151
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,10 @@ cython_debug/
170170
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
171171
# and can be added to the global gitignore or merged into this file. For a more nuclear
172172
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
173-
#.idea/
173+
.idea/
174174

175175
# Ruff stuff:
176176
.ruff_cache/
177177

178178
# PyPI configuration file
179179
.pypirc
180-

.pre-commit-config.yaml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
ci:
2+
autoupdate_commit_msg: "chore: update pre-commit hooks"
3+
autofix_commit_msg: "style: pre-commit fixes"
4+
5+
exclude: ^.cruft.json|.copier-answers.yml$
6+
7+
repos:
8+
- repo: https://github.com/adamchainz/blacken-docs
9+
rev: "1.19.1"
10+
hooks:
11+
- id: blacken-docs
12+
additional_dependencies: [black==24.*]
13+
14+
- repo: https://github.com/pre-commit/pre-commit-hooks
15+
rev: "v5.0.0"
16+
hooks:
17+
- id: check-added-large-files
18+
- id: check-case-conflict
19+
- id: check-merge-conflict
20+
- id: check-symlinks
21+
- id: check-yaml
22+
- id: debug-statements
23+
- id: end-of-file-fixer
24+
- id: mixed-line-ending
25+
- id: name-tests-test
26+
args: ["--pytest-test-first"]
27+
- id: requirements-txt-fixer
28+
- id: trailing-whitespace
29+
30+
- repo: https://github.com/pre-commit/pygrep-hooks
31+
rev: "v1.10.0"
32+
hooks:
33+
- id: rst-backticks
34+
- id: rst-directive-colons
35+
- id: rst-inline-touching-normal
36+
37+
- repo: https://github.com/rbubley/mirrors-prettier
38+
rev: "v3.5.2"
39+
hooks:
40+
- id: prettier
41+
types_or: [yaml, markdown, html, css, scss, javascript, json]
42+
args: [--prose-wrap=always]
43+
44+
- repo: https://github.com/astral-sh/ruff-pre-commit
45+
rev: "v0.9.9"
46+
hooks:
47+
- id: ruff
48+
args: ["--fix", "--show-fixes"]
49+
- id: ruff-format
50+
51+
- repo: https://github.com/codespell-project/codespell
52+
rev: "v2.4.1"
53+
hooks:
54+
- id: codespell
55+
56+
- repo: https://github.com/shellcheck-py/shellcheck-py
57+
rev: "v0.10.0.1"
58+
hooks:
59+
- id: shellcheck
60+
61+
- repo: local
62+
hooks:
63+
- id: disallow-caps
64+
name: Disallow improper capitalization
65+
language: pygrep
66+
entry: PyBind|Numpy|Cmake|CCache|Github|PyTest
67+
exclude: .pre-commit-config.yaml
68+
69+
- repo: https://github.com/abravalheri/validate-pyproject
70+
rev: "v0.23"
71+
hooks:
72+
- id: validate-pyproject
73+
additional_dependencies: ["validate-pyproject-schema-store[all]"]
74+
75+
- repo: https://github.com/python-jsonschema/check-jsonschema
76+
rev: "0.31.2"
77+
hooks:
78+
- id: check-dependabot
79+
- id: check-github-workflows
80+
- id: check-readthedocs

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM python:3.11.6
2+
RUN python -m pip install --upgrade pip && \
3+
python -m pip install dask dask-gateway distributed numpy pandas xarray zarr netcdf4 \
4+
intake bokeh

README.md

Lines changed: 51 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,38 @@
1-
# HTCdaskGateway
1+
# NCSA HTCdaskGateway
22

3-
* A Dask Gateway client extension for heterogeneous cluster mode combining the Kubernetes backend for pain-free scheduler networking, with COFFEA-powered HTCondor workers and/or OKD [coming soon].
4-
* Latest [![PyPI version](https://badge.fury.io/py/htcdaskgateway.svg)](https://badge.fury.io/py/htcdaskgateway)
5-
is installed by default and deployed to the COFFEA-DASK notebook on EAF (https://analytics-hub.fnal.gov). A few lines will get you going!
6-
* The current image for workers/schedulers is: coffeateam/coffea-dask-cc7-gateway:0.7.12-fastjet-3.3.4.0rc9-g8a990fa
3+
Subclasses the Dask Gateway client to launch dask clusters in Kubernetes, but
4+
with HTCondor workers. This is a fork of the ingenious original idea by Maria
5+
Acosta at Fermilab as part of their Elastic Analysis Facility project.
6+
7+
## How it Works
8+
9+
This is a drop-in replacement for the official Dask Gateway client. It keeps the
10+
same authentication and interaction with the gateway server (which is assumed to
11+
be running in a Kubernetes cluster). When the user requests a new cluster, this
12+
client communicates with the gateway server and instructs it to launch a
13+
cluster. We are running a modified docker image in the cluster which only
14+
launches the scheduler, and assumes that HTC workers will evetually join.
15+
16+
The client then uses the user's credentials to build an HTC Job file and submits
17+
it to the cluster. These jobs run the dask worker and have the necessary certs
18+
to present themselves to the scheduler.
19+
20+
The scheduler then accepts them into the cluster and we are ready to `compute`
21+
22+
- A Dask Gateway client extension for heterogeneous cluster mode combining the
23+
Kubernetes backend for pain-free scheduler networking, with COFFEA-powered
24+
HTCondor workers and/or OKD [coming soon].
25+
- Latest
26+
[![PyPI version](https://badge.fury.io/py/htcdaskgateway.svg)](https://badge.fury.io/py/htcdaskgateway)
27+
is installed by default and deployed to the COFFEA-DASK notebook on EAF
28+
(https://analytics-hub.fnal.gov). A few lines will get you going!
29+
- The current image for workers/schedulers is:
30+
coffeateam/coffea-dask-cc7-gateway:0.7.12-fastjet-3.3.4.0rc9-g8a990fa
731

832
## Basic usage @ Fermilab [EAF](https://analytics-hub.fnal.gov)
9-
* Make sure the notebook launched supports this functionality (COFFEA-DASK notebook)
33+
34+
- Make sure the notebook launched supports this functionality (COFFEA-DASK
35+
notebook)
1036

1137
```
1238
from htcdaskgateway import HTCGateway
@@ -26,25 +52,38 @@ client
2652
# When computations are finished, shutdown the cluster
2753
cluster.shutdown()
2854
```
55+
2956
## Other functions worth checking out
30-
* This is a multi-tenant environment, and you are authenticated via JupyterHub Oauth which means that you can create as many* clusters as you wish
31-
* To list your clusters:
57+
58+
- This is a multi-tenant environment, and you are authenticated via JupyterHub
59+
Oauth which means that you can create as many\* clusters as you wish
60+
- To list your clusters:
61+
3262
```
3363
# Verify that the gateway is responding to requests by asking to list all its clusters
3464
clusters = gateway.list_clusters()
3565
clusters
3666
```
37-
* To connect to a specific cluster from the list:
67+
68+
- To connect to a specific cluster from the list:
69+
3870
```
3971
cluster = gateway.connect(cluster_name)
4072
cluster
4173
cluster.shutdown()
4274
```
43-
* To gracefully close the cluster and remove HTCondor worker jobs associated to it:
75+
76+
- To gracefully close the cluster and remove HTCondor worker jobs associated to
77+
it:
78+
4479
```
4580
cluster.shutdown()
4681
```
47-
* There are widgets implemented by Dask Gateway. Make sure to give them a try from your EAF COFFEA notebook, just execute the the `client` and `cluster` commands (after properly initializing them) in a cell like:
82+
83+
- There are widgets implemented by Dask Gateway. Make sure to give them a try
84+
from your EAF COFFEA notebook, just execute the `client` and `cluster`
85+
commands (after properly initializing them) in a cell like:
86+
4887
```
4988
-------------
5089
cluster = gateway.new_cluster()
@@ -53,7 +92,7 @@ cluster
5392
-------------
5493
client = cluster.get_client()
5594
client
56-
< Widget will apear after this step >
95+
< Widget will appear after this step >
5796
-------------
5897
cluster
5998
< Widget will appear after this step >

pyproject.toml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
[build-system]
2+
requires = ["hatchling", "hatch-vcs"]
3+
build-backend = "hatchling.build"
4+
5+
6+
[project]
7+
name = "ncsa-htcdaskgateway"
8+
authors = [
9+
{ name = "Ben Galewsky", email = "[email protected]" },
10+
{ name = "Maria P. Acosta F./Fermilab EAF project", email="[email protected]"}
11+
]
12+
description = "Launches a Dask Gateway cluster in K8s and joins HTCondor workers to it"
13+
readme = "README.md"
14+
requires-python = ">=3.9"
15+
classifiers = [
16+
"Development Status :: 1 - Planning",
17+
"Intended Audience :: Science/Research",
18+
"Intended Audience :: Developers",
19+
"License :: OSI Approved :: BSD License",
20+
"Operating System :: OS Independent",
21+
"Programming Language :: Python",
22+
"Programming Language :: Python :: 3",
23+
"Programming Language :: Python :: 3 :: Only",
24+
"Programming Language :: Python :: 3.9",
25+
"Programming Language :: Python :: 3.10",
26+
"Programming Language :: Python :: 3.11",
27+
"Programming Language :: Python :: 3.12",
28+
"Programming Language :: Python :: 3.13",
29+
"Topic :: Scientific/Engineering",
30+
"Typing :: Typed",
31+
]
32+
dynamic = ["version"]
33+
dependencies = [
34+
"dask-gateway==2024.1.0"
35+
]
36+
37+
[project.urls]
38+
Homepage = "https://github.com/ncsa/dagster-ncsa"
39+
"Bug Tracker" = "https://github.com/ncsa/dagster-ncsa/issues"
40+
Discussions = "https://github.com/ncsa/dagster-ncsa/discussions"
41+
Changelog = "https://github.com/ncsa/dagster-ncsa/releases"
42+
43+
44+
[tool.hatch]
45+
version.source = "vcs"
46+
build.hooks.vcs.version-file = "src/htcdaskgateway/_version.py"
47+
48+
[tool.hatch.envs.default]
49+
features = ["test"]
50+
scripts.test = "pytest {args}"
51+
52+
53+
[tool.uv]
54+
dev-dependencies = [
55+
"dagster_ncsa[test]",
56+
]
57+
58+
59+
[tool.ruff]
60+
exclude = ["_version.py"]
61+
62+
[tool.ruff.lint]
63+
extend-select = [
64+
"ARG", # flake8-unused-arguments
65+
"B", # flake8-bugbear
66+
"C4", # flake8-comprehensions
67+
"EM", # flake8-errmsg
68+
"EXE", # flake8-executable
69+
"G", # flake8-logging-format
70+
"I", # isort
71+
"ICN", # flake8-import-conventions
72+
"NPY", # NumPy specific rules
73+
"PD", # pandas-vet
74+
"PGH", # pygrep-hooks
75+
"PIE", # flake8-pie
76+
"PL", # pylint
77+
"PT", # flake8-pytest-style
78+
"PTH", # flake8-use-pathlib
79+
"RET", # flake8-return
80+
"RUF", # Ruff-specific
81+
"SIM", # flake8-simplify
82+
"T20", # flake8-print
83+
"UP", # pyupgrade
84+
"YTT", # flake8-2020
85+
]
86+
ignore = [
87+
"PLR09", # Too many <...>
88+
"PLR2004", # Magic value used in comparison
89+
]
90+
isort.required-imports = ["from __future__ import annotations"]
91+
# Uncomment if using a _compat.typing backport
92+
# typing-modules = ["dagster_ncsa._compat.typing"]
93+
94+
[tool.ruff.lint.per-file-ignores]
95+
"tests/**" = ["T20"]
96+
"noxfile.py" = ["T20"]
97+
"_version.py" = ["UP035", "UP006"]

setup.py

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/htcdaskgateway/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
from .cluster import HTCGatewayCluster
2-
from .gateway import HTCGateway
1+
from __future__ import annotations
2+
3+
from .cluster import HTCGatewayCluster
4+
from .gateway import HTCGateway
35

46
# @author Maria A. - mapsacosta
57

6-
__all__ = ["HTCGatewayCluster", "HTCGateway"]
8+
__all__ = ["HTCGateway", "HTCGatewayCluster"]

src/htcdaskgateway/_version.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# file generated by setuptools-scm
2+
# don't change, don't track in version control
3+
4+
__all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
5+
6+
TYPE_CHECKING = False
7+
if TYPE_CHECKING:
8+
from typing import Tuple
9+
from typing import Union
10+
11+
VERSION_TUPLE = Tuple[Union[int, str], ...]
12+
else:
13+
VERSION_TUPLE = object
14+
15+
version: str
16+
__version__: str
17+
__version_tuple__: VERSION_TUPLE
18+
version_tuple: VERSION_TUPLE
19+
20+
__version__ = version = '0.1.23.dev12+g72f1d19.d20250317'
21+
__version_tuple__ = version_tuple = (0, 1, 23, 'dev12', 'g72f1d19.d20250317')

0 commit comments

Comments
 (0)