Skip to content

Commit 7050948

Browse files
authored
v0.5.1 (#189)
* Provide htcondor module version info as a constant instead of a function * Test infrastructure update (#188) * resolve #186
1 parent 5be40dd commit 7050948

27 files changed

+247
-215
lines changed

.codecov.yml

-7
This file was deleted.

.coveragerc

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[run]
22
branch = True
33

4+
data_file = /tmp/htmap-test-coverage
5+
46
include =
57
htmap/*
68

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,5 @@ venv.bak/
108108
.vscode/
109109

110110
!htmap-exec/singularity.d/*
111+
112+
prof/

.travis.yml

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1+
os: linux
12
dist: xenial
2-
sudo: required
33
services:
44
- docker
55

66
language: python
77
python:
88
- "3.6"
99
- "3.7"
10+
# - "3.8"
1011
env:
1112
- HTCONDOR_VERSION=8.8
1213
- HTCONDOR_VERSION=8.9
1314

14-
matrix:
15+
jobs:
1516
fast_finish: true
1617

1718
install:
18-
- travis_retry docker build -t htmap-test --file tests/_inf/Dockerfile --build-arg HTCONDOR_VERSION --build-arg PYTHON_VERSION=$TRAVIS_PYTHON_VERSION .
19+
- pip install codecov
20+
- travis_retry docker build -t htmap-test --file tests/_inf/Dockerfile --build-arg HTCONDOR_VERSION --build-arg PYTHON_VERSION=${TRAVIS_PYTHON_VERSION} .
1921

2022
script:
21-
- docker run htmap-test tests/_inf/travis.sh
23+
- docker run --mount type=bind,src="$PWD",dst=/home/mapper/htmap,readonly htmap-test bash tests/_inf/travis.sh

codecov.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
coverage:
2+
range: 50..90
3+
round: down
4+
precision: 0
5+
status:
6+
project:
7+
default:
8+
threshold: 1% # allow coverage to drop by up to 1% in a PR before marking it failed
9+
10+
comment:
11+
layout: "diff, files"

docs/source/devs/release.rst

+13-13
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ How to Release a New HTMap Version
66
77
To release a new version of HTMap:
88

9-
1. Merge the version PR into ``master`` via GitHub.
10-
1. Make a GitHub release from https://github.com/htcondor/htmap/releases .
11-
Name it exactly ``vX.Y.Z``, and link to the release notes for that version
12-
(like https://htmap.readthedocs.io/en/latest/versions/vX_Y_Z.html )
13-
in the description (the page will not actually exist yet).
14-
1. Delete anything in the ``dist/`` directory in your copy of the repository.
15-
1. On your machine, make sure ``master`` is up-to-date, then run
16-
``python3 setup.py sdist bdist_wheel`` to create the source distribution
17-
and the wheel. (This is where the files in ``dist/`` are created.)
18-
1. Install Twine: ``pip install twine``.
19-
1. Upload to PyPI:
20-
``python3 -m twine upload dist/*``.
21-
You will be prompted for your PyPI login.
9+
#. Merge the version PR into ``master`` via GitHub.
10+
#. Make a GitHub release from https://github.com/htcondor/htmap/releases .
11+
Name it exactly ``vX.Y.Z``, and link to the release notes for that version
12+
(like https://htmap.readthedocs.io/en/latest/versions/vX_Y_Z.html )
13+
in the description (the page will not actually exist yet).
14+
#. Delete anything in the ``dist/`` directory in your copy of the repository.
15+
#. On your machine, make sure ``master`` is up-to-date, then run
16+
``python3 setup.py sdist bdist_wheel`` to create the source distribution
17+
and the wheel. (This is where the files in ``dist/`` are created.)
18+
#. Install Twine: ``pip install twine``.
19+
#. Upload to PyPI:
20+
``python3 -m twine upload dist/*``.
21+
You will be prompted for your PyPI login.

docs/source/versions/v0_5_1.rst

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
v0.5.1
2+
======
3+
4+
New Features
5+
------------
6+
7+
8+
Deprecated Features
9+
-------------------
10+
11+
12+
Bug Fixes
13+
---------
14+
15+
* Maps can now be force-removed even if the schedd cannot be contacted.
16+
Graceful removal still requires contact with the schedd.
17+
Issue: https://github.com/htcondor/htmap/issues/186
18+
19+
20+
Known Issues
21+
------------
22+
23+
* Execution errors that result in the job being terminated but no output being
24+
produced are still not handled entirely gracefully. Right now, the component
25+
state will just show as ``ERRORED``, but there won't be an actual error report.
26+
* Map component state may become corrupted when a map is manually vacated.
27+
Force-removal may be needed to clean up maps if HTCondor and HTMap disagree
28+
about the state of their components.
29+
Issue: https://github.com/htcondor/htmap/issues/129

dr

100644100755
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env bash
22

3-
CONTAINER_TAG=htmap-tests
3+
CONTAINER_TAG='htmap-tests'
44

55
set -e
66
echo "Building HTMap testing container..."
77
docker build --quiet -t ${CONTAINER_TAG} --file tests/_inf/Dockerfile .
8-
docker run -it --rm ${CONTAINER_TAG} $@
8+
docker run -it --rm --mount type=bind,src="$PWD",dst=/home/mapper/htmap ${CONTAINER_TAG} $@

htmap/maps.py

+12-5
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ def wait(
262262

263263
previous_pbar_len = 0
264264

265-
ok_statuses = set([state.ComponentStatus.COMPLETED])
265+
ok_statuses = {state.ComponentStatus.COMPLETED}
266266
if holds_ok:
267267
ok_statuses.add(state.ComponentStatus.HELD)
268268
if errors_ok:
@@ -707,7 +707,14 @@ def remove(self, force: bool = False) -> None:
707707
force
708708
If ``True``, do not wait for HTCondor to confirm that all map components have been removed.
709709
"""
710-
self._remove_from_queue()
710+
try:
711+
self._remove_from_queue()
712+
except Exception as e:
713+
if not force:
714+
raise e
715+
716+
logger.exception(f"Encountered error while force-removing map {self.tag}; ignoring and moving to cleanup step")
717+
711718
self._cleanup_local_data(force = force)
712719
MAPS.remove(self)
713720

@@ -736,7 +743,7 @@ def _cleanup_local_data(self, force: bool = False) -> None:
736743
)
737744
for cs in self.component_statuses
738745
):
739-
time.sleep(.01)
746+
time.sleep(settings["WAIT_TIME"])
740747

741748
# move the tagfile to the removed tags dir
742749
# renamed by uid to prevent duplicates
@@ -757,8 +764,8 @@ def _cleanup_local_data(self, force: bool = False) -> None:
757764
logger.debug(f'Removed tag file for map {self.tag}')
758765
return # break out of the loop
759766
except OSError:
760-
logger.exception(f'Failed to remove map directory for map {self.tag}, retrying in .1 seconds')
761-
time.sleep(.1)
767+
logger.exception(f'Failed to remove map directory for map {self.tag}, retrying in {settings["WAIT_TIME"]} seconds')
768+
time.sleep(settings["WAIT_TIME"])
762769
logger.error(f'Failed to remove map directory for map {self.tag}, run htmap.clean() to try to remove later')
763770

764771
@property

htmap/state.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def _read_events(self):
170170
if handled_events:
171171
self.map._local_data = None # invalidate cache if any events were received
172172

173-
if utils.htcondor_version_info() >= (8, 9, 3):
173+
if utils.HTCONDOR_VERSION_INFO >= (8, 9, 3):
174174
self.save()
175175

176176
def save(self) -> Path:
@@ -188,7 +188,7 @@ def save(self) -> Path:
188188

189189
@staticmethod
190190
def load(map):
191-
if utils.htcondor_version_info() < (8, 9, 3):
191+
if utils.HTCONDOR_VERSION_INFO < (8, 9, 3):
192192
raise exceptions.InsufficientHTCondorVersion("Map state can only be saved with HTCondor 8.9.3 or greater")
193193

194194
with (map._map_dir / names.MAP_STATE).open(mode = 'rb') as f:

htmap/utils.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,4 @@ def parse_version(v: str) -> Tuple[int, int, int, str, int]:
253253

254254
EXTRACT_HTCONDOR_VERSION_RE = re.compile(r"(\d+\.\d+\.\d+)", flags = re.ASCII)
255255

256-
257-
def htcondor_version_info() -> Tuple[int, int, int, str, int]:
258-
return parse_version(EXTRACT_HTCONDOR_VERSION_RE.search(htcondor.version()).group(0))
256+
HTCONDOR_VERSION_INFO = parse_version(EXTRACT_HTCONDOR_VERSION_RE.search(htcondor.version()).group(0))

htmap/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
from . import utils
1919

20-
__version__ = '0.5.0'
20+
__version__ = '0.5.1'
2121

2222

2323
def version() -> str:

pytest.ini

+9
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,12 @@
33
testspaths = tests
44

55
console_output_style = count
6+
7+
log_format = %(levelname)-8s %(asctime)s %(message)s
8+
log_date_format = %Y-%m-%d %H:%M:%S
9+
10+
cache_dir = /tmp/htmap-pytest-cache
11+
12+
markers =
13+
issue: marks a test as corresponding to a particular GitHub issue
14+

requirements-dev.txt

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ pytest >= 4.1.1
33
pytest-mock
44
pytest-xdist
55
pytest-timeout
6+
pytest-watch
7+
pytest-profiling
68
coverage
79
pytest-cov
810
codecov

requirements.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
htcondor >= 8.8.0
22
cloudpickle ~= 1.2
3-
toml ~= 0.10.0
3+
toml ~= 0.10
44
tqdm ~= 4.36
55
click ~= 7.0
6-
click-didyoumean == 0.0.3
7-
halo == 0.0.28
6+
click-didyoumean ~= 0.0.3
7+
halo ~= 0.0.28

tests/_inf/.htmaprc

-4
This file was deleted.

tests/_inf/Dockerfile

+26-39
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,21 @@
1515

1616
# this dockerfile builds a test environment for HTMap
1717

18-
FROM ubuntu:bionic
18+
ARG PYTHON_VERSION=3.6
19+
FROM python:${PYTHON_VERSION}
20+
21+
# build config
22+
ARG HTCONDOR_VERSION=8.8
1923

2024
# switch to root to do root-level config
2125
USER root
2226

23-
# build config
24-
ARG PYTHON_VERSION=3.7
25-
ARG HTCONDOR_VERSION=8.9
26-
ARG MINICONDA_VERSION=latest
27-
2827
# environment setup
2928
ENV DEBIAN_FRONTEND=noninteractive
3029

3130
# install utils and dependencies
3231
RUN apt-get update \
33-
&& apt-get -y install --no-install-recommends vim less git gnupg wget ca-certificates locales \
32+
&& apt-get -y install --no-install-recommends vim less git gnupg wget ca-certificates locales graphviz \
3433
&& apt-get -y clean \
3534
&& rm -rf /var/lib/apt/lists/* \
3635
&& echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \
@@ -41,50 +40,38 @@ ENV LC_ALL=en_US.UTF-8 \
4140
LANGUAGE=en_US.UTF-8
4241

4342
# install HTCondor version specified in config
44-
RUN wget -qO - https://research.cs.wisc.edu/htcondor/ubuntu/HTCondor-Release.gpg.key | apt-key add - \
45-
&& echo "deb http://research.cs.wisc.edu/htcondor/ubuntu/${HTCONDOR_VERSION}/bionic bionic contrib" >> /etc/apt/sources.list \
43+
RUN wget -qO - https://research.cs.wisc.edu/htcondor/debian/HTCondor-Release.gpg.key | apt-key add - \
44+
&& echo "deb http://research.cs.wisc.edu/htcondor/debian/${HTCONDOR_VERSION}/buster buster contrib" >> /etc/apt/sources.list.d/htcondor.list \
4645
&& apt-get -y update \
4746
&& apt-get -y install --no-install-recommends htcondor \
4847
&& apt-get -y clean \
4948
&& rm -rf /var/lib/apt/lists/*
5049

51-
# create a user to be our submitter and set conda install location
52-
ENV SUBMIT_USER=mapper
53-
ENV CONDA_DIR=/home/${SUBMIT_USER}/conda
54-
ENV PATH=${CONDA_DIR}/bin:${PATH}
50+
# copy entrypoint into place and make executable
51+
COPY tests/_inf/entrypoint.sh /.entrypoint.sh
52+
RUN chmod +x /.entrypoint.sh
53+
54+
# create a user, set their PATH and PYTHONPATH
55+
ENV SUBMIT_USER=mapper \
56+
PATH="/home/mapper/.local/bin:${PATH}" \
57+
PYTHONPATH="/home/mapper/htmap:${PYTHONPATH}"
5558
RUN groupadd ${SUBMIT_USER} \
5659
&& useradd -m -g ${SUBMIT_USER} ${SUBMIT_USER}
5760

58-
# switch to submit user, don't need root anymore
61+
# switch to the user, don't need root anymore
5962
USER ${SUBMIT_USER}
6063

61-
# install miniconda and python version specified in config
62-
# (and ipython, which is nice for debugging inside the container)
63-
RUN cd /tmp \
64-
&& wget --quiet https://repo.continuum.io/miniconda/Miniconda3-${MINICONDA_VERSION}-Linux-x86_64.sh \
65-
&& bash Miniconda3-${MINICONDA_VERSION}-Linux-x86_64.sh -f -b -p $CONDA_DIR \
66-
&& rm Miniconda3-${MINICONDA_VERSION}-Linux-x86_64.sh \
67-
&& conda install python=${PYTHON_VERSION} ipython \
68-
&& conda clean -y --all
69-
70-
# install htmap dependencies early for docker build caching
71-
COPY requirements* /home/${SUBMIT_USER}/
72-
RUN pip install --no-cache-dir -r /home/${SUBMIT_USER}/requirements-dev.txt \
73-
&& pip install --no-cache-dir --upgrade htcondor==${HTCONDOR_VERSION}.* \
74-
&& rm /home/${SUBMIT_USER}/requirements*
75-
76-
# set default entrypoint and command
77-
# the entrypoint is critical: it starts HTCondor in the container
78-
ENTRYPOINT ["tests/_inf/entrypoint.sh"]
79-
CMD ["pytest"]
64+
# install htmap dependencies and debugging tools early for docker build caching
65+
COPY requirements* /tmp/
66+
RUN pip install --user --no-cache-dir -r /tmp/requirements-dev.txt \
67+
&& pip install --user --no-cache-dir ipython \
68+
&& pip install --user --no-cache-dir --upgrade htcondor==${HTCONDOR_VERSION}.*
8069

8170
# copy HTCondor and HTMap testing configs into place
8271
COPY tests/_inf/condor_config.local /etc/condor/condor_config.local
83-
COPY tests/_inf/.htmaprc /home/${SUBMIT_USER}/.htmaprc
8472

85-
# copy htmap package into container and install it
86-
# this is the only part that can't be cached against editing the package
87-
COPY --chown=mapper:mapper . /home/${SUBMIT_USER}/htmap
88-
RUN chmod +x /home/${SUBMIT_USER}/htmap/tests/_inf/entrypoint.sh /home/${SUBMIT_USER}/htmap/tests/_inf/travis.sh \
89-
&& pip install --no-cache-dir --no-deps -e /home/${SUBMIT_USER}/htmap
73+
# set default entrypoint and command
74+
# the entrypoint is critical: it starts HTCondor in the container
9075
WORKDIR /home/${SUBMIT_USER}/htmap
76+
ENTRYPOINT ["/.entrypoint.sh"]
77+
CMD ["pytest"]

tests/_inf/condor_config.local

+10-7
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,21 @@ SHADOW_QUEUE_UPDATE_INTERVAL=10
2222
UPDATE_INTERVAL=5
2323
RUNBENCHMARKS=0
2424

25-
# Don't use all the machine resources
26-
RESERVED_MEMORY = ( $(DETECTED_MEMORY) / 2 )
25+
# Put all of the machine resources under a single partitionable slot
26+
NUM_SLOTS = 1
27+
NUM_SLOTS_TYPE_1 = 1
28+
SLOT_TYPE_1 = 100%
29+
SLOT_TYPE_1_PARTITIONABLE = TRUE
30+
2731
JOB_RENICE_INCREMENT=5
2832
SCHED_UNIV_RENICE_INCREMENT=5
2933
SHADOW_RENICE_INCREMENT=5
3034

31-
# If the job does not explicitly set an environment, define
32-
# some default environment variables that put Conda in the path.
33-
JOB_TRANSFORM_NAMES = $(JOB_TRANSFORM_NAMES) SetCondaVars
34-
JOB_TRANSFORM_SetCondaVars @=end
35+
# Get the HTMap source into the Python path
36+
JOB_TRANSFORM_NAMES = $(JOB_TRANSFORM_NAMES) SetPyVars
37+
JOB_TRANSFORM_SetPyVars @=end
3538
[
3639
Requirements = ((Env?:"") == "") && ((Environment?:"") == "");
37-
set_Environment = "PATH=/home/mapper/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin CONDA_DIR=/home/mapper/conda";
40+
set_Environment = "PATH=/home/mapper/.local/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin PYTHONPATH=/home/mapper/htmap";
3841
]
3942
@end

tests/_inf/entrypoint.sh

+5-3
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ mkdir -p "$_condor_local_dir/lock" "$_condor_local_dir/log" "$_condor_local_dir/
88

99
# start condor
1010
condor_master
11-
echo "HTCondor is starting..."
11+
echo "Starting HTCondor..."
1212

13-
# wait until the scheduler is awake
14-
while [[ ! -f ${_condor_local_dir}/spool/job_queue.log ]]
13+
# once the shared port daemon wakes up, use condor_who to wait for condor to stand up
14+
while [[ ! -s "${_condor_local_dir}/log/SharedPortLog" ]]
1515
do
1616
sleep .01
1717
done
18+
sleep 1 # fudge factor to let shared port *actually* wake up
19+
condor_who -wait:60 'IsReady && STARTD_State =?= "Ready"' > /dev/null
1820

1921
if [[ -n $@ ]];
2022
then

0 commit comments

Comments
 (0)