[Q] Pyinstaller not fetching wandb_gql

I’m checking if pyinstaller package works to binarize a project and to test it, and I’m currently using pieces of code that contain the main functionality and package dependencies to the main project.

To decode into binary through pyinstaller I’m running:

pyinstaller pyinst_test.py

And to execute the generated binary:

$ ./dist/pyinst_test/pyinst_test 

The output of the binary is the following execution error:

Traceback (most recent call last):
  File "pyinst_test.py", line 3, in <module>
    import wandb
  File "PyInstaller/loader/pyimod02_importers.py", line 499, in exec_module
  File "wandb/__init__.py", line 26, in <module>
  File "PyInstaller/loader/pyimod02_importers.py", line 499, in exec_module
  File "wandb/sdk/__init__.py", line 7, in <module>
  File "PyInstaller/loader/pyimod02_importers.py", line 499, in exec_module
  File "wandb/sdk/wandb_artifacts.py", line 30, in <module>
  File "PyInstaller/loader/pyimod02_importers.py", line 499, in exec_module
  File "wandb/apis/__init__.py", line 31, in <module>
  File "PyInstaller/loader/pyimod02_importers.py", line 499, in exec_module
  File "wandb/apis/internal.py", line 1, in <module>
  File "PyInstaller/loader/pyimod02_importers.py", line 499, in exec_module
  File "wandb/sdk/internal/internal_api.py", line 1, in <module>
ModuleNotFoundError: No module named 'wandb_gql'

Is there anyway to use pyinstaller and wandb? Or is recommended another solution to encode wandb code dependencies as binary?


Issue description and steps:

tensorflow==2.10.0
wandb==0.12.20

The baseline code (pyinst_test.py):

import os
from tempfile import mkdtemp
import wandb
import tensorflow as tf

class Test:
    def __init__(self) -> None:
        wandb_secret_key = "<wandb_secret_key>"
        wandb_entity = "<wandb_entity>"
        wandb_project = "<wandb_project>"
        artifact_name = "<artifact_name>"
        artifact_version = "<artifact_version>"

        model_full_path = self._download_artifact(
            wandb_secret_key = wandb_secret_key,
            wandb_entity = wandb_entity,
            wandb_project = wandb_project,
            artifact_name = artifact_name,
            artifact_version = artifact_version    
        )
        print(f"[INFO] Model Artifact Directory: {model_full_path}")
        model = self._load_tf_model(model_full_path)
        self._print_model_summary(model)

    def _download_artifact(
        self,
        wandb_entity: str,
        wandb_project: str,
        artifact_name: str,
        artifact_version: str):

        api = wandb.Api()
        artifact = api.artifact(f"{wandb_entity}/{wandb_project}/{artifact_name}:{artifact_version}")
        local_download_folder = mkdtemp()

        artifact_dir = artifact.download(local_download_folder)
        model_full_path = os.path.join(local_download_folder, artifact_dir)
        return model_full_path

    
    def _load_tf_model(self, model_path: str):
        model = tf.keras.models.load_model(model_path)
        return model

    def _print_model_summary(self, model: tf.keras.models.Model):
        model.summary()

if __name__ == "__main__":
    test = Test()

Hey Wilson,

Using pip is the recommended way to install wandb. Is there anything that is blocking you from using pip in this situation?

Hi Wilson,

We wanted to follow up with you regarding your support request as we have not heard back from you. Please let us know if we can be of further assistance or if your issue has been resolved.

Best,
Weights and Biases

Hi Wilson, Since we have not heard back from you, we are closing this support request. If you would like to re-open this request, please reply to this thread!