Closed FADHLyemen closed 7 years ago
Thank you for submitting this! It actually pointed out some missing documentation. The problem is your config file, which is close. Here's some steps that I think will get the tests working for you:
Thank you, for your updating, the last error is resolved but I have another error that I appreciate your kind reply.
ClueApiClient request failed response.status_code: 401 response.reason: Unauthorized
DEBUG 2017-09-25 12:21:58,283 connectionpool _new_conn Starting new HTTPS connection (1): dev-api.clue.io
DEBUG 2017-09-25 12:21:58,877 connectionpool _make_request https://dev-api.clue.io:443 "GET /api/genes?filter=%7B%22fields%22%3A+%7B%22pr_gene_symbol%22%3A+true%7D%2C+%22where%22%3A+%7B%22pr_gene_symbol%22%3A+%7B%22inq%22%3A+%5B%22AKT1%22%2C+%22BRAF%22%2C+%22Dave+Lahr%27s+fake+cell+line+that+never+existed%22%5D%7D%7D%7D HTTP/1.1" 401 33
DEBUG 2017-09-25 12:21:58,881 clue_api_client run_filter_query requests.get result r.status_code: 401
FWARNING 2017-09-25 12:21:58,884 gene_queries are_genes_in_api provided gene_symbols was empty, cannot run query
DEBUG 2017-09-25 12:21:58,886 test_genes_queries test_are_genes_in_api_no_genes_provided r: set([])
.
======================================================================
FAIL: test_are_genes_in_api (__main__.TestGenesQueries)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/fadl2/cmapPy/cmapPy/clue_api_client/tests/test_genes_queries.py", line 19, in test_are_genes_in_api
r = gq.are_genes_in_api(cao, ["AKT1", "BRAF", "Dave Lahr's fake cell line that never existed"])
File "/home/fadl2/anaconda3/envs/my_cmapPy_env2/lib/python2.7/site-packages/cmapPy/clue_api_client/gene_queries.py", line 27, in are_genes_in_api
{"where":{"pr_gene_symbol":{"inq":query_gene_symbols}}, "fields":{"pr_gene_symbol":True}})
File "/home/fadl2/anaconda3/envs/my_cmapPy_env2/lib/python2.7/site-packages/cmapPy/clue_api_client/clue_api_client.py", line 44, in run_filter_query
ClueApiClient._check_request_response(r)
File "/home/fadl2/anaconda3/envs/my_cmapPy_env2/lib/python2.7/site-packages/cmapPy/clue_api_client/clue_api_client.py", line 100, in _check_request_response
response.status_code, response.reason)
AssertionError: ClueApiClient request failed response.status_code: 401 response.reason: Unauthorized
----------------------------------------------------------------------
Ran 2 tests in 0.607s
FAILED (failures=1)
Glad to hear you're making progress. From the error message "401 Unauthorized" it looks like it is not using a valid API key. Did you change the API key entry in the config file, did you use the one you got from your account on clue.io?
Also, why are you using "dev-api" ? Thats obviously development (internal). Was there a doc or code that had dev-api harcoded in?
Please let us know.
Thanks
On Mon, Sep 25, 2017 at 10:13 PM, Dave Lahr notifications@github.com wrote:
Glad to hear you're making progress. From the error message "401 Unauthorized" it looks like it is not using a valid API key. Did you change the API key entry in the config file, did you use the one you got from your account on clue.io?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/cmap/cmapPy/issues/10#issuecomment-332065839, or mute the thread https://github.com/notifications/unsubscribe-auth/AA381mz7C14XpY3j51XVH3PQQT0QteqRks5smF3TgaJpZM4PjRu- .
Yes dllahr, I used the same API user key. Yes in4matx, the config file "cmapPy.cfg" has dev-api,
[prod]
clue_api_url = https://api.clue.io/api
clue_api_user_key ="my user key"
[test]
clue_api_url = https://dev-api.clue.io/api
clue_api_user_key ="my user key"
when I change https://dev-api.clue.io/api to https://api.clue.io/api as you suggest I got the below error:
FAIL: test_are_genes_in_api (__main__.TestGenesQueries)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/fadl2/cmapPy/cmapPy/clue_api_client/tests/test_genes_queries.py", line 22, in test_are_genes_in_api
self.assertEqual(2, len(r))
AssertionError: 2 != 0
----------------------------------------------------------------------
Ran 3 tests in 1.890s
FAILED (failures=1)
@in4matx He should be using the dev API, that is the correct thing to use when running the integration tests, we don't want them running against the production system.
Can you please change back to the dev api?
@FADHLyemen just a sanity check, you're not using "my user key" as your API key in the config file, and if you're not, you don't have it in quotes? (It should not be in quotes).
@FADHLyemen I made a mistake, the problem is that your user key will not work against our dev system. Can you please point the tests at the production system? Then, to resolve the error messages you saw above when you tried that, can you check that you have the latest code - in particular, can you check that on line 27 of gene_queries.py it says:
{"where":{"gene_symbol":{"inq":query_gene_symbols}}, "fields":{"gene_symbol":True}})
Yes, dllahr, Thank you. When I change the gene_queries.py inside the environment it works for only one time, then it gives the below error:
AssertionError: ClueApiClient request failed response.status_code: 500 response.reason: Internal Server Error
Thank you dllahr and int4max for your help, It works when I reset it, but my question is that why you delete the creating environment instructions from the readme file. Second, How could I use the API playground https://clue.io/api#playground with the API python package.
The only file that gives the below error is 'test_macchiato_queries.py' AssertionError: ClueApiClient request failed response.status_code: 500 response.reason: Internal Server Error
Those instructions were redundant with the main instructions, and I don't want us to try to maintain the same documentation / instructions in multiple locations - that will lead to errors. You can find the documentation here: http://cmappy.readthedocs.io/en/latest/clue_api_client.html
If you go to the README for all of cmapPy the first link is to the overall documentation.
You will not be able to use the macchiato api tests, since they test writing to the API, which is reserved for our internal systems.
I try to run 'test_genes_queries.py' but I got the below error:
NoSectionError Traceback (most recent call last) /home/fadl2/cmapPy/cmapPy/clue_api_client/tests/test_genes_queries.py in()
40 setup_logger.setup(verbose=True)
41
---> 42 cao = test_clue_api_client.build_clue_api_client_from_default_test_config()
43
44 unittest.main()
/home/fadl2/cmapPy/cmapPy/clue_api_client/tests/test_clue_api_client.py in build_clue_api_client_from_default_test_config() 125 #cao = clue_api_client.ClueApiClient(base_url=cfg.get(config_section, "clue_api_url"), 126 # user_key=cfg.get(config_section, "clue_api_user_key")) --> 127 cao = clue_api_client.ClueApiClient(base_url=cfg.get(config_section, " https://api.clue.io/api/genes"), 128 user_key=cfg.get(config_section, "87474c084256d13f140eaa3227ab48b2")) 129 return cao
/home/fadl2/anaconda3/envs/my_cmapPy_env2/lib/python2.7/ConfigParser.pyc in get(self, section, option) 328 if section not in self._sections: 329 if section != DEFAULTSECT: --> 330 raise NoSectionError(section) 331 if opt in self._defaults: 332 return self._defaults[opt]
NoSectionError: No section: 'test'
in file "clue_api_client.py" I use the two lines: