Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ca31987

Browse files
author
Ryan Clancy
authored
Mount directory the topic file is in as volume rather than fixed directory (#86)
1 parent 9714620 commit ca31987

2 files changed

Lines changed: 8 additions & 13 deletions

File tree

manager.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import hashlib
2-
import os
32

43
import docker
54

@@ -8,10 +7,8 @@
87
from searcher import Searcher
98
from trainer import Trainer
109

11-
TOPIC_PATH_HOST = os.path.abspath("topics")
12-
TOPIC_PATH_GUEST = "/input/topics/"
13-
1410
COLLECTION_PATH_GUEST = "/input/collections/"
11+
TOPIC_PATH_GUEST = "/input/topics/"
1512
OUTPUT_PATH_GUEST = "/output"
1613

1714
TEST_SPLIT_PATH_GUEST = '/data/splits/test_split.txt'
@@ -48,14 +45,12 @@ def prepare(self, preparer_config=None):
4845
def search(self, searcher_config=None):
4946
if searcher_config:
5047
self.set_searcher_config(searcher_config)
51-
self.searcher.search(self.client, OUTPUT_PATH_GUEST, TOPIC_PATH_HOST, TOPIC_PATH_GUEST, TEST_SPLIT_PATH_GUEST,
52-
self.generate_save_tag)
48+
self.searcher.search(self.client, OUTPUT_PATH_GUEST, TOPIC_PATH_GUEST, TEST_SPLIT_PATH_GUEST, self.generate_save_tag)
5349

5450
def train(self, trainer_config=None):
5551
if trainer_config:
5652
self.set_trainer_config(trainer_config)
57-
self.trainer.train(self.client, TOPIC_PATH_GUEST, TEST_SPLIT_PATH_GUEST, VALIDATION_SPLIT_PATH_GUEST,
58-
self.generate_save_tag)
53+
self.trainer.train(self.client, TOPIC_PATH_GUEST, TEST_SPLIT_PATH_GUEST, VALIDATION_SPLIT_PATH_GUEST, self.generate_save_tag)
5954

6055
def interact(self, interactor_config=None):
6156
if interactor_config:

searcher.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ def __init__(self, searcher_config=None):
1313
def set_config(self, searcher_config):
1414
self.config = searcher_config
1515

16-
def search(self, client, output_path_guest, topic_path_host, topic_path_guest,
17-
test_split_path_guest, generate_save_tag):
16+
def search(self, client, output_path_guest, topic_path_guest, test_split_path_guest, generate_save_tag):
1817
"""
1918
Runs the search and evaluates the results (run files placed into the /output directory) using trec_eval
2019
"""
@@ -24,20 +23,21 @@ def search(self, client, output_path_guest, topic_path_host, topic_path_guest,
2423
if not exists:
2524
sys.exit("Must prepare image first...")
2625

26+
topic_path_host = os.path.dirname(os.path.abspath(self.config.topic))
27+
2728
volumes = {
2829
os.path.abspath(self.config.output): {
2930
"bind": output_path_guest,
3031
"mode": "rw"
3132
},
32-
os.path.abspath(topic_path_host): {
33+
topic_path_host: {
3334
"bind": topic_path_guest,
3435
"mode": "ro"
3536
}
3637
}
3738

3839
if len(self.config.test_split) > 0:
39-
volumes[os.path.abspath(self.config.test_split)] = {
40-
"bind": test_split_path_guest, "mode": "ro"}
40+
volumes[os.path.abspath(self.config.test_split)] = {"bind": test_split_path_guest, "mode": "ro"}
4141

4242
search_args = {
4343
"collection": {

0 commit comments

Comments
 (0)