Closed dbkeator closed 4 years ago
I think it is because orthauth
was not installed, probably because the services features was not set during install. Can you run your equivalent of pip install --user ontquery[services]
and see if that fixes the problem?
Tried the suggestion. Still not able to connect. Here's output from pip command:
pip install --user ontquery[services] Requirement already satisfied: ontquery[services] in /Users/dbkeator/opt/anaconda3/lib/python3.7/site-packages/ontquery-0.2.1-py3.7.egg (0.2.1) Collecting orthauth>=0.0.3 (from ontquery[services]) Downloading https://files.pythonhosted.org/packages/50/d0/7c291e2dbc7a5b1e86319fc759c7327dc236cfc8bbf1390f70592f49b5c7/orthauth-0.0.6-py2.py3-none-any.whl Requirement already satisfied: rdflib in /Users/dbkeator/opt/anaconda3/lib/python3.7/site-packages (from ontquery[services]) (4.2.2) Requirement already satisfied: requests in /Users/dbkeator/opt/anaconda3/lib/python3.7/site-packages (from ontquery[services]) (2.22.0) Requirement already satisfied: pyparsing in /Users/dbkeator/opt/anaconda3/lib/python3.7/site-packages (from rdflib->ontquery[services]) (2.4.2) Requirement already satisfied: isodate in /Users/dbkeator/opt/anaconda3/lib/python3.7/site-packages (from rdflib->ontquery[services]) (0.6.0) Requirement already satisfied: certifi>=2017.4.17 in /Users/dbkeator/opt/anaconda3/lib/python3.7/site-packages (from requests->ontquery[services]) (2019.9.11) Requirement already satisfied: idna<2.9,>=2.5 in /Users/dbkeator/opt/anaconda3/lib/python3.7/site-packages (from requests->ontquery[services]) (2.8) Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /Users/dbkeator/opt/anaconda3/lib/python3.7/site-packages (from requests->ontquery[services]) (3.0.4) Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /Users/dbkeator/opt/anaconda3/lib/python3.7/site-packages (from requests->ontquery[services]) (1.24.2) Requirement already satisfied: six in /Users/dbkeator/opt/anaconda3/lib/python3.7/site-packages (from isodate->rdflib->ontquery[services]) (1.12.0) Installing collected packages: orthauth Successfully installed orthauth-0.0.6
Same error as before? (I hope not because that means something is very off).
Also watch out for that rdflib klobbering neurdflib when you get around to changing the dependencies.
Nope, new error with my next function call: ilx_cli = InterLexRemote(api_key=key, apiEndpoint=endpoint) Error is: {TypeError}init() got an unexpected keyword argument 'api_key'
Thanks
Ah yes. That is because I changed the function signature to not accept the api_key argument. You should be able to remove the api_key keyword argument to InterLexRemote and then set the API key in ~/Library/Application Support/ontquery/config.py
under the interlex-api-key
key.
Hi,
This is a bit confusing for me. Our NIDM tools are meant to be used by a general user base that will sign up for an scicrunch api key and then run the various tools, supplying their api-key on the command line (or eventually via an environment variable if they like...not implemented yet). How can I make my code use a user-supplied api-key and initialize a connection given your suggestion?
Thanks
It is already possible for you and/or users to pass the key using INTERLEX_API_KEY
https://github.com/tgbugs/ontquery/blob/ab50a7efb6dc637e855fcf41488b6577a3bd8727/ontquery/plugins/services/auth-config.py#L7. Alternately a user can put their key in ${user_config_dir}/ontquery/config.py
on their own system and ontquery will find it.
For more detail than you probably want see https://github.com/tgbugs/orthauth/blob/master/docs/guide.org.
If you really want to allow them to pass the api_key variable on the command line (I made the change to remove the api_key keyword argument to removed prevent passing from the command line because it is a bad security practice) you can manually set ilx_cli.api_key = key
on the next line (strongly discouraged for the record).
Ok (sorry if I'm slow), so I should change my function call to remove the api_key parameter and then change my instructions for my tools to tell users to store their api key in an environment variable INTERLEX_API_KEY and that's it, correct? :)
Yep!
Making some progress. After setting environment variable I get by the previous step (ilx_cli = InterLexRemote(apiEndpoint=endpoint)). The next thing my code does is run:
ilx_cli.setup()
which results in the following error (what's OntTerm?):
ilx_cli.setup()
File "/Users/dbkeator/opt/anaconda3/lib/python3.7/site-packages/ontquery-0.2.1-py3.7.egg/ontquery/plugins/services/interlex.py", line 61, in setup super().setup(**kwargs) File "/Users/dbkeator/opt/anaconda3/lib/python3.7/site-packages/ontquery-0.2.1-py3.7.egg/ontquery/services.py", line 28, in setup raise TypeError('OntTerm is a required argument!') # FIXME only require instrumented TypeError: OntTerm is a required argument!
You should be able to avoid that error by calling ilx_cli.setup(instrumented=oq.OntTerm)
(curse the **kwargs
inability to provide good documentation and convenience at the same time). I think for your use case you probably don't actually need the OntTerm functionality, but doing it this way make sure that all the internals that ontquery needs are in place in case you do call something that requires it. I also fixed the error message so that it actually lists the kwarg it is checking for.
Thanks...all is right with my world now!
Hi, I'm not sure if this is a problem with my system after having to upgrade to Catalina and re-install python or not. I'm using ontquery to connect to Interlex and getting an exception during initialization of the Interlex remote:
InterLexRemote = oq.plugin.get('InterLex')
Exception: