Skip to content

Commit

Permalink
poking at #199
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshKarpel committed Apr 27, 2020
1 parent 22a48f7 commit 7fed177
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 16 deletions.
1 change: 1 addition & 0 deletions docker/.htmaprc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DELIVERY_METHOD = "assume"
5 changes: 3 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,12 @@ USER ${SUBMIT_USER}

# install htmap dependencies and debugging tools early for docker build caching
COPY requirements* /tmp/
RUN pip install --user --no-cache-dir -r /tmp/requirements-dev.txt -r /tmp/requirements-docs.txt ipython \
&& pip install --user --no-cache-dir --upgrade htcondor==${HTCONDOR_VERSION}.*
RUN python -m pip install --user --no-cache-dir -r /tmp/requirements-dev.txt -r /tmp/requirements-docs.txt ipython \
&& python -m pip install --user --no-cache-dir --upgrade htcondor==${HTCONDOR_VERSION}.*

# copy HTCondor and HTMap testing configs into place
COPY docker/condor_config.local /etc/condor/condor_config.local
COPY --chown=mapper:mapper docker/.htmaprc /home/${SUBMIT_USER}/

# set default entrypoint and command
# the entrypoint is critical: it starts HTCondor in the container
Expand Down
2 changes: 2 additions & 0 deletions htmap/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ def create_map(
htio.save_submit(map_dir, submit_obj)
htio.save_itemdata(map_dir, itemdata)

logger.debug(f"Submit description for map {tag} is\n{submit_obj}")

logger.debug(f'Submitting map {tag}...')
cluster_id = execute_submit(
submit_object = submit_obj,
Expand Down
36 changes: 22 additions & 14 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import time
from pathlib import Path
from copy import copy

import pytest

Expand All @@ -29,13 +30,32 @@
htmap.settings['WAIT_TIME'] = 0.01
htmap.settings['MAP_OPTIONS.request_memory'] = '10MB'

SETTINGS = copy(htmap.settings)

@pytest.fixture(scope = 'session', autouse = True)
def set_transplant_dir(tmpdir_factory):

@pytest.fixture(scope = 'function', autouse = True)
def reset_settings():
htmap.settings.replace(SETTINGS)


@pytest.fixture(scope = 'function', autouse = True)
def set_transplant_dir(tmpdir_factory, reset_settings):
path = Path(tmpdir_factory.mktemp('htmap_transplant_dir'))
htmap.settings['TRANSPLANT.DIR'] = path


@pytest.fixture(scope = 'function')
def delivery_methods(delivery_method, reset_settings):
htmap.settings['DELIVERY_METHOD'] = delivery_method


@pytest.fixture(scope = 'function', autouse = True)
def set_htmap_dir(tmpdir_factory, reset_settings):
path = Path(tmpdir_factory.mktemp('htmap_dir'))
htmap.settings['HTMAP_DIR'] = path
ensure_htmap_dir_exists()


def pytest_addoption(parser):
parser.addoption(
"--delivery",
Expand All @@ -52,18 +72,6 @@ def pytest_generate_tests(metafunc):
)


@pytest.fixture(scope = 'function')
def delivery_methods(delivery_method):
htmap.settings['DELIVERY_METHOD'] = delivery_method


@pytest.fixture(scope = 'function', autouse = True)
def set_htmap_dir(tmpdir_factory):
path = Path(tmpdir_factory.mktemp('htmap_dir'))
htmap.settings['HTMAP_DIR'] = path
ensure_htmap_dir_exists()


@pytest.fixture(scope = 'session')
def doubler():
def doubler(x):
Expand Down
59 changes: 59 additions & 0 deletions tests/integration/test_input_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Copyright 2018 HTCondor Team, Computer Sciences Department,
# University of Wisconsin-Madison, WI.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


import pytest

from pathlib import Path

import htmap


@pytest.mark.timeout(180)
def test_fixed_input_files_are_transferred_as_list_of_paths(tmp_path):
f1 = tmp_path / 'f1'
f2 = tmp_path / 'f2'

f1.write_text('f1')
f2.write_text('f2')

def test(_):
return Path('f1').read_text() == 'f1' and Path('f2').read_text() == 'f2'

m = htmap.map(test, [None], map_options = htmap.MapOptions(
fixed_input_files = [f1, f2]
))

assert m.get(0)


@pytest.mark.timeout(180)
def test_fixed_input_files_are_transferred_as_list_of_strings(tmp_path):
f1 = tmp_path / 'f1'
f2 = tmp_path / 'f2'

f1.write_text('f1')
f2.write_text('f2')

def test(_):
return Path('f1').read_text() == 'f1' and Path('f2').read_text() == 'f2'

m = htmap.map(test, [None], map_options = htmap.MapOptions(
fixed_input_files = [f1.as_posix(), f2.as_posix()]
))

assert m.get(0)


0 comments on commit 7fed177

Please sign in to comment.