Skip to content

Commit f07c03e

Browse files
author
Ryan Clancy
authored
Add requirements.txt... (#63)
* Add requirements.txt... and also some minor formatting * Add docs
1 parent 0757500 commit f07c03e

File tree

5 files changed

+35
-19
lines changed

5 files changed

+35
-19
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ To get started, download + compile `trec_eval` with the following:
88
git clone https://github.com/usnistgov/trec_eval.git && make -C trec_eval
99
```
1010

11+
Make sure the Docker Python package is installed (via pip, conda, etc.):
12+
```
13+
pip install -r requirements.txt
14+
```
15+
16+
1117
For common test collections, [topics](topics/) and [qrels](qrels/) are already checked into this repo.
1218

1319
To test the jig with an Anserini image using default parameters, try:

interactor.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import json
2-
import os
32
import sys
43

4+
55
class Interactor:
66

77
def __init__(self, interactor_config=None):
88
self.config = interactor_config
9-
9+
1010
def set_config(self, interactor_config):
1111
self.config = interactor_config
12-
12+
1313
def interact(self, client, generate_save_tag):
1414
"""
1515
Starts a container from a saved image that has already been initialized/indexed.
@@ -23,7 +23,7 @@ def interact(self, client, generate_save_tag):
2323
exists = len(client.images.list(filters={"reference": "{}:{}".format(self.config.repo, save_tag)})) != 0
2424
if not exists:
2525
sys.exit("Must prepare image first...")
26-
26+
2727
interact_args = {
2828
"opts": {key: value for (key, value) in map(lambda x: x.split("="), self.config.opts)}
2929
}
@@ -32,11 +32,11 @@ def interact(self, client, generate_save_tag):
3232
# create with sh command to override any default command
3333
container = client.containers.create("{}:{}".format(self.config.repo, save_tag), command="sh", tty=True)
3434
container.start()
35-
35+
3636
print("Running interact script in container...")
37-
log = container.exec_run("sh -c '/interact --json {}'".format(json.dumps(json.dumps(interact_args))),
38-
stdout=True, stderr=True, stream=True)
39-
37+
log = container.exec_run("sh -c '/interact --json {}'".format(json.dumps(json.dumps(interact_args))),
38+
stdout=True, stderr=True, stream=True)
39+
4040
print("Logs for interact in container with ID {}...".format(container.id))
4141
for line in log[1]:
4242
print(str(line.decode('utf-8')), end="")
@@ -47,7 +47,7 @@ def interact(self, client, generate_save_tag):
4747
print("Exiting...")
4848
print("Don't forget to stop and remove the container after you are done!")
4949
return
50-
50+
5151
wait = input("Press ENTER to stop and remove container")
5252
print("Stopping container {}...".format(container.id))
5353
container.stop()

manager.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import os
21
import hashlib
2+
import os
33

44
import docker
55

6+
from interactor import Interactor
67
from preparer import Preparer
78
from searcher import Searcher
8-
from interactor import Interactor
99

1010
TOPIC_PATH_HOST = os.path.abspath("topics")
1111
TOPIC_PATH_GUEST = "/input/topics/"
@@ -28,7 +28,7 @@ def set_preparer_config(self, preparer_config):
2828

2929
def set_searcher_config(self, searcher_config):
3030
self.searcher.set_config(searcher_config)
31-
31+
3232
def set_interactor_config(self, interactor_config):
3333
self.interactor.set_config(interactor_config)
3434

requirements.txt

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
certifi==2019.3.9
2+
chardet==3.0.4
3+
docker==3.7.2
4+
docker-pycreds==0.4.0
5+
idna==2.8
6+
requests==2.21.0
7+
six==1.12.0
8+
urllib3==1.24.2
9+
websocket-client==0.56.0

run.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
from manager import Manager
44

5+
56
def str_to_bool(s):
6-
s = s.lower()
7-
if s == "true":
8-
return True
9-
elif s == "false":
10-
return False
11-
else:
12-
raise argparse.ArgumentTypeError("Expected boolean value.")
7+
s = s.lower()
8+
if s == "true":
9+
return True
10+
elif s == "false":
11+
return False
12+
else:
13+
raise argparse.ArgumentTypeError("Expected boolean value.")
1314

1415

1516
if __name__ == "__main__":

0 commit comments

Comments
 (0)