Skip to content

Commit

Permalink
update other server tests to accomodate zip file
Browse files Browse the repository at this point in the history
  • Loading branch information
EPedrotti committed Feb 22, 2019
1 parent 28a76e4 commit 649e453
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 2 deletions.
1 change: 1 addition & 0 deletions rasa_nlu/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ def train(self, request):
request.setResponseCode(404)
returnValue(json_to_string({"error": "{}".format(e)}))
except TrainingException as e:
logger.error(e)
request.setResponseCode(500)
returnValue(json_to_string({"error": "{}".format(e)}))

Expand Down
2 changes: 1 addition & 1 deletion rasa_nlu/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def zip_folder(folder: Text, library: Text = None) -> Text:

if library == 'zipfile':
zip_name = zipped_path.name
file = zipfile.ZipFile(zip_name, 'r',
file = zipfile.ZipFile(zip_name, 'rb',
zipfile.ZIP_DEFLATED)
_zipdir(folder, file)
file.close()
Expand Down
133 changes: 133 additions & 0 deletions test_download.zip
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
<html><head><title>web.Server Traceback (most recent call last)</title></head><body><b>web.Server Traceback (most recent call last):</b>

<div>
<style type="text/css">
div.error {
color: red;
font-family: Verdana, Arial, helvetica, sans-serif;
font-weight: bold;
}

div {
font-family: Verdana, Arial, helvetica, sans-serif;
}

div.stackTrace {
}

div.frame {
padding: 1em;
background: white;
border-bottom: thin black dashed;
}

div.frame:first-child {
padding: 1em;
background: white;
border-top: thin black dashed;
border-bottom: thin black dashed;
}

div.location {
}

span.function {
font-weight: bold;
font-family: "Courier New", courier, monospace;
}

div.snippet {
margin-bottom: 0.5em;
margin-left: 1em;
background: #FFFFDD;
}

div.snippetHighlightLine {
color: red;
}

span.code {
font-family: "Courier New", courier, monospace;
}
</style>

<div class="error">
<span>builtins.ValueError</span>: <span>ZipFile requires mode 'r', 'w', 'x', or 'a'</span>
</div>
<div class="stackTrace">
<div class="frame">
<div class="location">
<span>/usr/local/lib/python3.6/site-packages/twisted/internet/defer.py</span>:<span>1418</span> in
<span class="function">_inlineCallbacks</span>
</div>
<div class="snippet">
<div class="snippetLine">
<span class="lineno">1417</span>
<code class="code"> &#160; &#160; &#160; &#160; &#160; &#160;else:</code>
</div><div class="snippetHighlightLine">
<span class="lineno">1418</span>
<code class="code"> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;result = g.send(result)</code>
</div><div class="snippetLine">
<span class="lineno">1419</span>
<code class="code"> &#160; &#160; &#160; &#160;except StopIteration as e:</code>
</div>
</div>
</div><div class="frame">
<div class="location">
<span>/Users/edoardopedrotti/projects/rasa_nlu/rasa_nlu/server.py</span>:<span>354</span> in
<span class="function">train</span>
</div>
<div class="snippet">
<div class="snippetLine">
<span class="lineno">353</span>
<code class="code"> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;RasaNLUModelConfig(model_config), model_name)</code>
</div><div class="snippetHighlightLine">
<span class="lineno">354</span>
<code class="code"> &#160; &#160; &#160; &#160; &#160; &#160;zipped_path = utils.zip_folder(path_to_model, 'zipfile')</code>
</div><div class="snippetLine">
<span class="lineno">355</span>
<code class="code"></code>
</div>
</div>
</div><div class="frame">
<div class="location">
<span>/Users/edoardopedrotti/projects/rasa_nlu/rasa_nlu/utils/__init__.py</span>:<span>391</span> in
<span class="function">zip_folder</span>
</div>
<div class="snippet">
<div class="snippetLine">
<span class="lineno">390</span>
<code class="code"> &#160; &#160; &#160; &#160;file = zipfile.ZipFile(zip_name, 'rb',</code>
</div><div class="snippetHighlightLine">
<span class="lineno">391</span>
<code class="code"> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; zipfile.ZIP_DEFLATED)</code>
</div><div class="snippetLine">
<span class="lineno">392</span>
<code class="code"> &#160; &#160; &#160; &#160;_zipdir(folder, file)</code>
</div>
</div>
</div><div class="frame">
<div class="location">
<span>/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/zipfile.py</span>:<span>1064</span> in
<span class="function">__init__</span>
</div>
<div class="snippet">
<div class="snippetLine">
<span class="lineno">1063</span>
<code class="code"> &#160; &#160; &#160; &#160;if mode not in ('r', 'w', 'x', 'a'):</code>
</div><div class="snippetHighlightLine">
<span class="lineno">1064</span>
<code class="code"> &#160; &#160; &#160; &#160; &#160; &#160;raise ValueError("ZipFile requires mode 'r', 'w', 'x', or 'a'")</code>
</div><div class="snippetLine">
<span class="lineno">1065</span>
<code class="code"></code>
</div>
</div>
</div>
</div>
<div class="error">
<span>builtins.ValueError</span>: <span>ZipFile requires mode 'r', 'w', 'x', or 'a'</span>
</div>
</div>

</body></html>
2 changes: 1 addition & 1 deletion tests/base/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def test_model_hot_reloading(app, rasa_default_train_data):
response = app.post(train_u,
headers={b"Content-Type": b"application/x-yml"},
data=model_str)
time.sleep(3)
time.sleep(30)
app.flush()
response = yield response
assert response.code == 200, "Training should end successfully"
Expand Down

0 comments on commit 649e453

Please sign in to comment.