dmwm / DBSClient

Apache License 2.0
3 stars 8 forks source link

problem importing DbsApi in 4.0.0 #48

Closed belforte closed 3 years ago

belforte commented 3 years ago

Hi @vkuznet (I can't assing issue to you). Maybe I am doing something wrong, but it seems that simply importing DbsApi makes it to be also executed, and hence fail[1] since no url is defined yet. Is thi because I do not have DBS/PycurlClient/.../RestClient in the PYTHONPATH ? Where should I take it from ? By the way, in a less clean/clear environment, i.e. adding tne DBS to PYTHONPATH before the "usual" stuff, the old RestCLient is found, but import of dbsClient fails same way [2]

I am not sure how to use this at this point, sorry.

belforte@lxplus751/~> cd /tmp/belforte/
belforte@lxplus751/belforte> git clone  https://github.com/dmwm/DBSClient
Cloning into 'DBSClient'...
git remote: Enumerating objects: 590, done.
remote: Counting objects: 100% (590/590), done.
remote: Compressing objects: 100% (355/355), done.
remote: Total 590 (delta 227), reused 485 (delta 170), pack-reused 0
Receiving objects: 100% (590/590), 437.20 KiB | 0 bytes/s, done.
Resolving deltas: 100% (227/227), done.
belforte@lxplus751/belforte> cd DBSClient/
belforte@lxplus751/DBSClient> git checkout 4.0.0
Note: checking out '4.0.0'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

HEAD is now at 05ec989... Merge pull request #46 from vkuznet/main
belforte@lxplus751/DBSClient> cd src/python/
belforte@lxplus751/python> python
Python 2.7.5 (default, Nov 16 2020, 22:23:17) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from dbs.apis.dbsClient import DbsApi
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "dbs/apis/dbsClient.py", line 413
    print("The server output is not a valid json, most probably you have a typo in the url.\n%s.\n" % self.url, file=sys.stderr)
                                                                                                                    ^
SyntaxError: invalid syntax
>>> 

[2]

Python 2.7.13+ (default, Jan 22 2021, 17:43:09) 
[GCC 6.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import RestClient
>>> RestClient.__file__
'/data/srv/TaskManager/v3.210920/slc7_amd64_gcc630/cms/dbs3-pycurl-client/3.16.0-comp/lib/python2.7/site-packages/RestClient/__init__.pyc'
>>> import dbs.apis.dbsClient
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/data/repos/DBSClient/src/python/dbs/apis/dbsClient.py", line 413
    print("The server output is not a valid json, most probably you have a typo in the url.\n%s.\n" % self.url, file=sys.stderr)                                         
belforte commented 3 years ago

or maybe this line really has a syntax error, at least in python2 ? https://github.com/dmwm/DBSClient/blob/05ec989f1ab2143160653cffce0ae02b9444e588/src/python/dbs/apis/dbsClient.py#L413

maybe as simple as " this only works in python3" ??

vkuznet commented 3 years ago

@belforte , two things:

So, you should try the following:

  1. get your py3 environment somehow (use CMSSW, conda, etc.)
  2. either do git clone https://github.com/dmwm/DBSClient or download tar ball from pypi (https://files.pythonhosted.org/packages/2a/cd/afbd8393b7c932be89ec7c687aa69614055d0e7b6e0267669c77d8ac41a6/dbs3-client-4.0.0.tar.gz)
  3. Setup PYTHONPATH to point to DBClient and its dependencies first, like
    export DBS3_CLIENT_ROOT=/data/users/vk/dbs/DBS/DBSClient
    export PYTHONPATH=$DBS3_CLIENT_ROOT/src/python:$DBS3_CLIENT_ROOT/dbs3-pycurl-3.17.4/src/python

    then you can proceed

belforte commented 3 years ago

OK. got it to run with a bunch of yum install and pip3 install. I was not sure that python3 was needed. Please close.