Skip to content
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

Url fix #1258

Merged
merged 10 commits into from Jul 25, 2018
Merged

Url fix #1258

merged 10 commits into from Jul 25, 2018

Conversation

twhughes
Copy link
Contributor

@twhughes twhughes commented Jul 25, 2018

rasa_nlu was throwing errors when trying to load training data via url. This was due to a byte encoding error. Fixes issue
RasaHQ/rasa_platform#51

Proposed changes:

changes
f = tempfile.NamedTemporaryFile("w+", suffix=suffix, delete=False, encoding="utf-8")
to
f = tempfile.NamedTemporaryFile("w+b", suffix=suffix, delete=False)
for python 3

Status (please check what you already did):

  • made PR ready for code review
  • added some tests for the functionality
  • updated the documentation
  • updated the changelog

`rasa_nlu` was throwing errors when trying to load training data via url.  This was due to a byte encoding error.  Fixes issue #51
@twhughes twhughes requested a review from tmbo July 25, 2018 08:13
def test_url_data_format():
test_url = 'http://website-demo.rasa.com/api/default/data.json?api_token=e8c436157a24b007ed5cdc9ba4d062ed66c4f63d'
r = requests.get(test_url)
data = r.json()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need to do the request right? can't we just put the value in data?

(the tests should be able to run as independent if possible, in this case this test would randomly start failing if, e.g. the demo is not available, is getting restarted, or if the token changed).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I was wondering about this. And actually now that I think about it some more, this doesn't actually test much besides whether the link is working. I'll come up with a better test.

@twhughes
Copy link
Contributor Author

@tmbo I think the test is correct now but now Travis is failing on test_server.py tests for python 3 and I'm not exactly sure why. Is it due to the changes I made in this PR? @ricwo maybe could you take a look?

@ricwo
Copy link
Contributor

ricwo commented Jul 25, 2018

@twhughes the mode parameters should be different for byte and string input. I've made it a parameter now

}
]
},
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think this additional second item adds anything to the test, does it? if not I'd remove one of the common examples and only keep one

}"""
fname = utils.create_temporary_file(data.encode("utf-8"), suffix="_tmp_training_data.json")
data = utils.read_json_file(fname)
validate_rasa_nlu_data(data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert data is not None at the end or something like that

@tmbo tmbo merged commit d7c6f0d into master Jul 25, 2018
@twhughes twhughes deleted the url-fix branch July 26, 2018 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants