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

Expose filename header in model training api #6075

Closed
Ezhvsalate opened this issue Jun 26, 2020 · 6 comments
Closed

Expose filename header in model training api #6075

Ezhvsalate opened this issue Jun 26, 2020 · 6 comments
Labels
area:rasa-oss 🎡 Anything related to the open source Rasa framework type:bug 🐛 Inconsistencies or issues which will cause an issue or problem for users or implementors.

Comments

@Ezhvsalate
Copy link
Contributor

Rasa version: Rasa 1.10.1

Python version: 3.6.9

Operating system: Ubuntu 18.04.3 LTS (Bionic Beaver)

Issue:

I train a model using HTTP /model/train API and want to get a trained model filename as response header as defined in docs.

Unfortunately it seems like I can't do this: browser doesn't see response 'filename' header.
All I get are following:

HTTP/1.1 200 OK
Connection: keep-alive
Keep-Alive: 5
Access-Control-Allow-Origin: http://localhost:3000
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: content-type
Access-Control-Max-Age: None
Access-Control-Allow-Methods: DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT
Vary: Origin
Content-Length: 0

Looks like this is issue about 'Access-Control-Expose-Headers'. Can we add 'filename' to exposed headers?

@Ezhvsalate Ezhvsalate added area:rasa-oss 🎡 Anything related to the open source Rasa framework type:bug 🐛 Inconsistencies or issues which will cause an issue or problem for users or implementors. labels Jun 26, 2020
@sara-tagger
Copy link
Collaborator

Thanks for the issue, @melindaloubser1 will get back to you about it soon!

You may find help in the docs and the forum, too 🤗

@indam23
Copy link
Contributor

indam23 commented Jun 29, 2020

Can you post the request you're making/how you're making it? I do see the filename header returned with the request below:

curl --request POST --url http://localhost:5005/model/train \ 
--output model.tar.gz   \
  --header 'content-type: application/json' \
  --data '{
  "domain": "intents:\n  - greet\n  - goodbye\n  - affirm\n  - deny\n  - mood_great\n  - mood_unhappy\n\nactions:\n  - utter_greet\n  - utter_cheer_up\n  - utter_did_that_help\n  - utter_happy\n  - utter_goodbye\n\ntemplates:\n  utter_greet:\n  - text: \"Hey! How are you?\"\n\n  utter_cheer_up:\n  - text: \"Here is something to cheer you up:\"\n    image: \"https://i.imgur.com/nGF1K8f.jpg\"\n\n  utter_did_that_help:\n  - text: \"Did that help you?\"\n\n  utter_happy:\n  - text: \"Great carry on!\"\n\n  utter_goodbye:\n  - text: \"Bye\"",
  "config": "language: en\npipeline: supervised_embeddings\npolicies:\n  - name: MemoizationPolicy\n  - name: KerasPolicy",
  "nlu": "## intent:greet\n- hey\n- hello\n- hi\n## intent:goodbye\n- bye\n- goodbye\n- have a nice day\n- see you\n## intent:affirm\n- yes\n- indeed\n## intent:deny\n- no\n- never\n## intent:mood_great\n- perfect\n- very good\n- great\n## intent:mood_unhappy\n- sad\n- not good\n- unhappy",
  "stories": "## happy path\n* greet\n\n  - utter_greet\n\n* mood_great\n\n  - utter_happy\n\n## sad path 1\n* greet\n\n  - utter_greet\n\n* mood_unhappy\n\n  - utter_cheer_up\n\n  - utter_did_that_help\n\n* affirm\n\n  - utter_happy\n\n## sad path 2\n* greet\n\n  - utter_greet\n\n* mood_unhappy\n\n  - utter_cheer_up\n\n  - utter_did_that_help\n\n* deny\n\n  - utter_goodbye\n\n## say goodbye\n* goodbye\n\n  - utter_goodbye",
  "force": false,
  "save_to_default_model_directory": true
}' --dump-header header.txt

header.txt contains:

HTTP/1.1 100 Continue

HTTP/1.1 200 OK
Connection: keep-alive
Keep-Alive: 5
filename: 20200629-154807.tar.gz
Content-Disposition: attachment; filename="20200629-154807.tar.gz"
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Content-Length: 1916881
Content-Type: application/x-tar

Ezhvsalate pushed a commit to Ezhvsalate/rasa-expose-headers-demo that referenced this issue Jun 30, 2020
@Ezhvsalate
Copy link
Contributor Author

@melindaloubser1, sure, curl or other tool like that will see custom header. But for js code in browser it won't be accessible by default. Please check this link for more info.

I have prepared a demo app here, you can reproduce this yourself.

It starts a simple react app, containing one button which launches model training at http://localhost:5005 and prints to browser console available response's headers:

image

Then add the line here to configure sanic-cors:

 app.config.CORS_EXPOSE_HEADERS = '*'

After that much more info is available to browser:
image

Or less broadly:

 app.config.CORS_EXPOSE_HEADERS = 'filename'

image

If one of options above is suitable for you I can create a PR.

@indam23
Copy link
Contributor

indam23 commented Jun 30, 2020

Ok that makes sense! Yes, if you could open a PR for exposing just filename additionally that'd be great.

@Ezhvsalate
Copy link
Contributor Author

@melindaloubser1 created a PR. Please check it when you have time.

@indam23
Copy link
Contributor

indam23 commented Jul 2, 2020

@Ezhvsalate I don't think the commit you linked to is actually part of a PR, I left a comment on it

indam23 added a commit that referenced this issue Jul 8, 2020
Add 'Access-Control-Expose-Headers' for 'filename' header (#6075)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:rasa-oss 🎡 Anything related to the open source Rasa framework type:bug 🐛 Inconsistencies or issues which will cause an issue or problem for users or implementors.
Projects
None yet
Development

No branches or pull requests

3 participants