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

Unable to load swagger-client #2

Open
shenben opened this issue Jul 16, 2023 · 2 comments
Open

Unable to load swagger-client #2

shenben opened this issue Jul 16, 2023 · 2 comments

Comments

@shenben
Copy link

shenben commented Jul 16, 2023

Hello,

I am currently using the faasnap framework and encountered an issue with the swagger-client library. I have followed the python-client installation instructions provided (python setup.py install --user) and verified that the swagger-client package is installed .

$ pip list | grep swagger-client
swagger-client  1.0.0

However, when trying to import the swagger_client module in my Python code, I am receiving the error message

(py39) emc_admin@numasvr01:~/faasnap/python-client$ python 
Python 3.9.17 (main, Jul  5 2023, 20:41:20) 
[GCC 11.2.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import swagger_client
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/emc_admin/faasnap/python-client/swagger_client/__init__.py", line 19, in <module>
    from swagger_client.api.default_api import DefaultApi
  File "/home/emc_admin/faasnap/python-client/swagger_client/api/__init__.py", line 6, in <module>
    from swagger_client.api.default_api import DefaultApi
  File "/home/emc_admin/faasnap/python-client/swagger_client/api/default_api.py", line 21, in <module>
    from swagger_client.api_client import ApiClient
  File "/home/emc_admin/faasnap/python-client/swagger_client/api_client.py", line 27, in <module>
    import swagger_client.models
ModuleNotFoundError: No module named 'swagger_client.models'

I have located the problematic import statement in the api_client.py file where it tries to do import swagger_client.models. It seems like we can copy the models directory generated by the step Build the FaaSnap daemon, into faasnap/python-client/swagger_client directory.

emc_admin@numasvr01:~/faasnap$ ls models/
function.go  invocation.go  snapshot.go  vm.go

howerver, when I tried to copy them , the next errors occuried:

>>> import swagger_client
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/emc_admin/faasnap/python-client/swagger_client/__init__.py", line 25, in <module>
    from swagger_client.models.function import Function
ModuleNotFoundError: No module named 'swagger_client.models.function'

And I have located the problem in the init.py file:

# import models into sdk package
from swagger_client.models.function import Function
from swagger_client.models.invocation import Invocation
from swagger_client.models.snapshot import Snapshot
from swagger_client.models.vm import VM

It appears that the four lines you mentioned correspond to four separate files within the models/daemon module. However, I am facing difficulty in making them work together seamlessly.

I would greatly appreciate any guidance or assistance you could provide to help resolve this issue. Please let me know if there are any additional steps or dependencies required to use the faasnap framework correctly.

Thank you for your attention to this matter.

@catchabhisek
Copy link

Is there any solution to this problem?

@zxyy-bys
Copy link

zxyy-bys commented Sep 4, 2023

It seems the python-client/swagger_client/models directory is missing. And I tried to regenerate the python-client via swagger-codegen with api/swagger.yaml file. Then, it seems working.

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

No branches or pull requests

3 participants