Skip to content

Unable to load swagger-client #2

@shenben

Description

@shenben

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions