-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scottx611x/read input from url #20
Conversation
…ontainers with `INPUT_JSON_URL`
…sn't around anymore
build_run_test.sh
Outdated
# Returns a url that will resolve to the SimpleHTTPServer we spin up below | ||
# so that the Docker container can make requests to files existing | ||
# under the cwd i.e. `./test-data/input.json` | ||
get_python_server_url() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mccalluc I feel bad about using this again, but it works...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't do this. it might be catching edge cases we're unaware of, but if it did break, we're not in a place to understand it's behavior. There's a grep example earlier in that thread, or I could find perl readable here:
ifconfig | perl -ne 'print $2 if /inet (addr:)?(\d+\.\d+\.\d+\.\d+)/ and $2 ne "127.0.0.1"'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or move this whole script into python?
build_run_test.sh
Outdated
|
||
# Spin up a server so that the container can GET input data from the `test-data` dir | ||
python -m SimpleHTTPServer $PYTHON_SERVER_PORT & | ||
PYTHON_SERVER_PID=$! | ||
|
||
for FIXTURE in `ls input_fixtures`; do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just glob instead of subprocess?:
for FIXTURE in input_fixtures/*; do
build_run_test.sh
Outdated
python test.py | ||
|
||
kill $PYTHON_SERVER_PID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless you nohup, shouldn't the child exit with the parent?
from cgi import escape | ||
|
||
|
||
def get_refinery_input(): | ||
""" Make a GET request to acquire the input data for the container""" | ||
return requests.get(os.environ["INPUT_JSON_URL"]).json() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But isn't refinery using using json in INPUT_JSON
? I could be confused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
INPUT_JSON_URL
is what refinery is passing along to containers after: refinery-platform/refinery-platform#2677
context/on_startup.py
Outdated
status = requests.get( | ||
url, headers={ | ||
'Range': 'bytes=0-0'}).status_code | ||
except requests.exceptions.RequestException as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
weird line breaks...
build_run_test.sh
Outdated
} | ||
|
||
# Spin up a server so that the container can GET input data from the `test-data` dir | ||
python -m SimpleHTTPServer $PYTHON_SERVER_PORT & |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
http.server for python3?
test.py
Outdated
|
||
|
||
class ContainerTest(unittest.TestCase): | ||
|
||
def get_url(self, name): | ||
command = "docker port {} | perl -pne 's/.*://'".format(name) | ||
port = subprocess.check_output(command, shell=True).strip().decode('utf-8') | ||
port = subprocess.check_output( | ||
command, shell=True).strip().decode('utf-8') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would put another linebreak after True to respect structure.
test.py
Outdated
self.assertIn(expected, response.text) | ||
# TODO: Not ideal for error pages | ||
self.assertEqual(200, response.status_code) | ||
if expected is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need this? Stricter tests are usually better.
test.py
Outdated
def test_data_directory(self): | ||
self.assert_expected_response('good', '{', '/data/input.json') | ||
def test_input_data_url(self): | ||
self.assert_expected_response('good', path='/options.json') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why no expected
?
test.py
Outdated
print '{} -> {}'.format(name, url) | ||
return url | ||
print('Still waiting for server...') | ||
time.sleep(1) | ||
self.fail('Server never came up: ' + name) | ||
|
||
def assert_expected_response(self, name, expected, path='/'): | ||
def assert_expected_response(self, name, expected=None, path='/'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can still using positional params when a default is given...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lots of little things...
…get around the SSL InsecurePlatformWarning errors
@@ -61,7 +71,7 @@ def validate_urls(urls): | |||
if status != 206 # If byte-ranges are handled, should be 206, not 200. | |||
] | |||
if messages: | |||
raise StandardError('\n'.join(messages)) | |||
raise Exception('\n'.join(messages)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
back to StandardError? Or move to Python3
@@ -72,9 +82,10 @@ def start_server(): | |||
if __name__ == '__main__': | |||
try: | |||
write_igv_configuration() | |||
except StandardError, e: | |||
except Exception as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
back to StandardError? Or move to Python3
define_repo.sh
Outdated
@@ -2,4 +2,5 @@ | |||
|
|||
OWNER=gehlenborglab | |||
NAME=docker_igv_js | |||
export NAME=$NAME |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export NAME=docker_igv_js
test.py
Outdated
url = 'http://localhost:{}'.format(port) | ||
for i in xrange(5): | ||
if 0 == subprocess.call('curl --fail --silent ' + url + ' > /dev/null', shell=True): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was updated to requests somewhee, use that code
test.py
Outdated
import requests | ||
import unittest | ||
|
||
from test_utils import TestContainerRunner | ||
|
||
|
||
class ContainerTest(unittest.TestCase): | ||
|
||
def get_url(self, name): | ||
command = "docker port {} | perl -pne 's/.*://'".format(name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
double check docker-py functionality for getting port
test.py
Outdated
test_container_runner.cleanup_containers() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe look into bumping this out
test.py
Outdated
@@ -55,10 +67,14 @@ def test_no_parameters(self): | |||
|
|||
|
|||
if __name__ == '__main__': | |||
test_container_runner = TestContainerRunner() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as a context manager?
test_utils.py
Outdated
self.containers.append(container) | ||
|
||
def cleanup_containers(self): | ||
map( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for container in containers:
container remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix these, please
No description provided.