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

Using callback on adapt_fit yields TypeError: expected str, bytes or os.PathLike object, not NoneType #223

Open
2 tasks done
icarosadero opened this issue Feb 3, 2025 · 4 comments
Assignees

Comments

@icarosadero
Copy link
Contributor

icarosadero commented Feb 3, 2025

Is there an existing issue for this?

  • I have searched the existing issues

Bug description

If you define a function on the callback of the method adapt_fit along with a frequency, an error will show up mentioning that there is no logdir specified to save checkpoints on the save method of the solver.base. Example:

progress_bar = lambda num_steps, solver: print(f"Embedding... {num_steps}")
U = embedding.fit_transform(X, adapt=True, callback_frequency=100, callback=progress_bar)

Results in:

Traceback (most recent call last):
  File "/project/.venv/lib/python3.12/site-packages/streamlit/runtime/scriptrunner/exec_code.py", line 88, in exec_func_with_error_handling
    result = func()
             ^^^^^^
  File "/project/.venv/lib/python3.12/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 579, in code_to_exec
    exec(code, module.__dict__)
  File "/project/app.py", line 119, in <module>
    main()
  File "/project/app.py", line 78, in main
    U = embedding.fit_transform(X, adapt=True, callback_frequency=100, callback=progress_bar)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/project/.venv/lib/python3.12/site-packages/sklearn/utils/_set_output.py", line 157, in wrapped
    data_to_wrap = f(self, X, *args, **kwargs)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/project/.venv/lib/python3.12/site-packages/cebra/integrations/sklearn/cebra.py", line 1289, in fit_transform
    self.fit(X,
  File "/project/.venv/lib/python3.12/site-packages/cebra/integrations/sklearn/cebra.py", line 1188, in fit
    self._adapt_fit(X,
  File "/project/.venv/lib/python3.12/site-packages/cebra/integrations/sklearn/cebra.py", line 1127, in _adapt_fit
    self._partial_fit(*self.state_,
  File "/project/.venv/lib/python3.12/site-packages/cebra/integrations/sklearn/cebra.py", line 1036, in _partial_fit
    solver.fit(
  File "/project/.venv/lib/python3.12/site-packages/cebra/solver/base.py", line 214, in fit
    self.save(logdir, f"checkpoint_{num_steps:#07d}.pth")
  File "/project/.venv/lib/python3.12/site-packages/cebra/solver/base.py", line 346, in save
    if not os.path.exists(os.path.dirname(logdir)):
                          ^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen posixpath>", line 181, in dirname
TypeError: expected str, bytes or os.PathLike object, not NoneType

Following the error message, the call to solver.fit is setting logdir = None, which is then passed to base.save, which then tried to save in None.

Operating System

Kubuntu 24.04

CEBRA version

0.4.0

Device type

GPU

Code of Conduct

icarosadero added a commit to icarosadero/CEBRA that referenced this issue Feb 3, 2025
This is a lazy solution to AdaptiveMotorControlLab#223
@MMathisLab
Copy link
Member

Can you pip install 0.5.0rc1 and see if error persists?

@icarosadero
Copy link
Contributor Author

Can you pip install 0.5.0rc1 and see if error persists?

Just did, seems like it's the same error. Is cebra.__version__ supposed to be empty in this version?

@MMathisLab
Copy link
Member

hey @icarosadero

@icarosadero
Copy link
Contributor Author

hey @icarosadero

  • okay thanks for checking, we will address, thanks for PR Update base.py #224 !

  • version working for me; what the error?

      [CEBRA/cebra/__init__.py](https://github.com/AdaptiveMotorControlLab/CEBRA/blob/c32ed67ab8bc1ff1afa4e47e1d09bb26ce0a3270/cebra/__init__.py#L69)
    
    
         Line 69
      in
      [c32ed67](/AdaptiveMotorControlLab/CEBRA/commit/c32ed67ab8bc1ff1afa4e47e1d09bb26ce0a3270)
    
    
    
    
    
        
          
           __version__ = "0.5.0rc1"
    

Nevermind, I bet it is a problem with my REPL

MMathisLab pushed a commit that referenced this issue Feb 18, 2025
This is a lazy solution to #223
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

4 participants