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 import pysyft: AttributeError: 'Globals' object has no attribute 'pandas' #457

Open
Benjamintdk opened this issue Jun 3, 2024 · 0 comments
Labels
Type: Bug 🐛 Some functionality not working in the codebase as intended

Comments

@Benjamintdk
Copy link

Description

I followed the instructions to the Federated Learning exercise in the Foundations of Private Computation course. I tried setting up the conda environment to run the tutorial code, following issues such as #423. However, I am still unable to import the syft library.

How to Reproduce

  1. Followed instructions according to this site. Installation using conda and the conda environment.yml file provided.
  2. Run
import syft as sy
  1. Error
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[2], line 1
----> 1 import syft as sy

File ~/miniconda3/envs/openmined-courses/lib/python3.9/site-packages/syft/__init__.py:59
     57 from syft.core.node.vm.vm import VirtualMachineClient  # noqa: F401
     58 from syft.core.plan.plan import Plan  # noqa: F401
---> 59 from syft.core.plan.plan_builder import make_plan  # noqa: F401
     60 from syft.experimental_flags import flags  # noqa: F401
     61 from syft.grid.client.client import login  # noqa: F401

File ~/miniconda3/envs/openmined-courses/lib/python3.9/site-packages/syft/core/plan/plan_builder.py:15
     12 from .plan import Plan
     14 PLAN_BUILDER_VM: PlanVirtualMachine = PlanVirtualMachine(name="plan_vm")
---> 15 ROOT_CLIENT: Client = PLAN_BUILDER_VM.get_root_client()
     18 def build_plan_inputs(forward_func: Callable) -> Dict[str, Pointer]:
     19     signature = inspect.signature(forward_func)

File ~/miniconda3/envs/openmined-courses/lib/python3.9/site-packages/syft/core/node/common/node.py:289, in Node.get_root_client(self, routes)
    288 def get_root_client(self, routes: Optional[List[Route]] = None) -> ClientT:
--> 289     client: ClientT = self.get_client(routes=routes)
    290     self.root_verify_key = client.verify_key
    291     return client

File ~/miniconda3/envs/openmined-courses/lib/python3.9/site-packages/syft/core/node/common/node.py:277, in Node.get_client(self, routes)
    274     setattr(solo, "name", f"Route ({self.name} <-> {self.name} Client)")
    275     routes = [solo]
--> 277 return self.client_type(  # type: ignore
    278     name=self.name,
    279     routes=routes,
    280     network=self.network,
    281     domain=self.domain,
    282     device=self.device,
    283     vm=self.vm,
    284     signing_key=None,  # DO NOT PASS IN A SIGNING KEY!!! The client generates one.
    285     verify_key=None,  # DO NOT PASS IN A VERIFY KEY!!! The client generates one.
    286 )

File ~/miniconda3/envs/openmined-courses/lib/python3.9/site-packages/syft/core/node/vm/client.py:34, in VirtualMachineClient.__init__(self, name, routes, vm, network, domain, device, signing_key, verify_key)
     23 def __init__(
     24     self,
     25     name: Optional[str],
   (...)
     32     verify_key: Optional[VerifyKey] = None,
     33 ):
---> 34     super().__init__(
     35         name=name,
     36         routes=routes,
     37         network=network,
     38         domain=domain,
     39         device=device,
     40         vm=vm,
     41         signing_key=signing_key,
     42         verify_key=verify_key,
     43     )
     45     self.post_init()

File ~/miniconda3/envs/openmined-courses/lib/python3.9/site-packages/syft/core/node/common/client.py:91, in Client.__init__(self, name, routes, network, domain, device, vm, signing_key, verify_key)
     88 else:
     89     self.verify_key = verify_key
---> 91 self.install_supported_frameworks()
     93 self.store = StoreClient(client=self)

File ~/miniconda3/envs/openmined-courses/lib/python3.9/site-packages/syft/core/node/common/client.py:124, in Client.install_supported_frameworks(self)
    123 def install_supported_frameworks(self) -> None:
--> 124     self.lib_ast = create_lib_ast(client=self)
    126     # first time we want to register for future updates
    127     self.lib_ast.register_updates(self)

File ~/miniconda3/envs/openmined-courses/lib/python3.9/site-packages/syft/lib/__init__.py:244, in create_lib_ast(client)
    238 lib_ast.syft.core.add_attr(
    239     "remote_dataloader", remote_dataloader_ast.syft.core.remote_dataloader
    240 )
    242 # let the misc creation be always the last, as it needs the full ast solved
    243 # to properly generated unions
--> 244 union_misc_ast = getattr(getattr(create_union_ast(lib_ast, client), "syft"), "lib")
    245 lib_ast.syft.lib.add_attr(attr_name="misc", attr=union_misc_ast.attrs["misc"])
    247 return lib_ast

File ~/miniconda3/envs/openmined-courses/lib/python3.9/site-packages/syft/lib/misc/__init__.py:92, in create_union_ast(lib_ast, client)
     84 classes.append(
     85     (
     86         f"syft.lib.misc.union.{klass.__name__}",
   (...)
     89     )
     90 )
     91 union_types = lazy_pairing[klass]
---> 92 allowed_functions = get_allowed_functions(lib_ast, union_types)
     93 for target_method, allowed in allowed_functions.items():
     94     if not allowed:

File ~/miniconda3/envs/openmined-courses/lib/python3.9/site-packages/syft/lib/misc/__init__.py:67, in get_allowed_functions(lib_ast, union_types)
     65 for union_type in union_types:
     66     real_type_function_set = solve_real_type_functions(union_type)
---> 67     ast_type_function_set = solve_ast_type_functions(union_type, lib_ast)
     68     rejected_function_set = real_type_function_set - ast_type_function_set
     69     for accepted_function in ast_type_function_set:

File ~/miniconda3/envs/openmined-courses/lib/python3.9/site-packages/cachetools/__init__.py:737, in cached.<locals>.decorator.<locals>.wrapper(*args, **kwargs)
    735 except KeyError:
    736     pass  # key not found
--> 737 v = func(*args, **kwargs)
    738 try:
    739     cache[k] = v

File ~/miniconda3/envs/openmined-courses/lib/python3.9/site-packages/syft/lib/misc/__init__.py:28, in solve_ast_type_functions(path, lib_ast)
     26 root = lib_ast
     27 for path_element in path.split("."):
---> 28     root = getattr(root, path_element)
     29 return root.attrs.keys()

File ~/miniconda3/envs/openmined-courses/lib/python3.9/site-packages/syft/ast/module.py:256, in Module.__getattribute__(self, item)
    247 def __getattribute__(self, item: str) -> Any:
    248     """Get Attribute of a `module`.
    249 
    250     Args:
   (...)
    254         The value of the attribute.
    255     """
--> 256     target_object = super().__getattribute__(item)
    257     if isinstance(target_object, ast.static_attr.StaticAttribute):
    258         return target_object.get_remote_value()

AttributeError: 'Globals' object has no attribute 'pandas'

Expected Behavior

syft library to be imported without errors

Screenshots

If applicable, add screenshots to help explain your problem.

System Information

  • OS: WSL2
  • OS Version: Ubuntu 20.04.6 LTS
  • Language Version: Python 3.9.19
  • Package Manager Version: conda 24.4.0
  • Browser (if applicable): Google Chrome
  • Browser Version (if applicable): 125.0.6422.114

Additional Context

Add any other context about the problem here.

@Benjamintdk Benjamintdk added the Type: Bug 🐛 Some functionality not working in the codebase as intended label Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug 🐛 Some functionality not working in the codebase as intended
Projects
None yet
Development

No branches or pull requests

1 participant