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

fix circular import in gaze_dataframe.py #559

Open
dkrako opened this issue Sep 15, 2023 · 2 comments
Open

fix circular import in gaze_dataframe.py #559

dkrako opened this issue Sep 15, 2023 · 2 comments
Labels
bug Something isn't working essential important

Comments

@dkrako
Copy link
Contributor

dkrako commented Sep 15, 2023

          This PR includes an EventsDataFrame in a GazeDataFrame, which leads to circular dependencies when importing both.

Doing something like

from pymovements.gaze.gaze_dataframe import GazeDataFrame

results in a hard python circular import error.

I have found a workaround by importing the pymovements top-level package, but then pylint is not happy with me again.

Right now I just can't find a way to untie this knot. As this is just a linting issue, I would like to create a follow-up issue on how to solve this problem and leave it like this for this PR.

Originally posted by @dkrako in #553 (comment)

@dkrako dkrako added the bug Something isn't working label Sep 15, 2023
@romajaku
Copy link
Collaborator

Hi all, when trying to import pymovements within a jupyter notebook created in the tutorials directory (both old and newly created) i get the following error.

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[9], [line 2](vscode-notebook-cell:?execution_count=9&line=2)
      [1](vscode-notebook-cell:?execution_count=9&line=1) data_path = Path("../../../tests/files/eyelink_monocular_example.asc")
----> [2](vscode-notebook-cell:?execution_count=9&line=2) data, metadata = pm.gaze.from_asc(
      [3](vscode-notebook-cell:?execution_count=9&line=3)     data_path,
      [4](vscode-notebook-cell:?execution_count=9&line=4)     patterns=[
      [5](vscode-notebook-cell:?execution_count=9&line=5)         # TODO: Update patterns (https://github.com/theDebbister/multipleye-preprocessing/issues/5#issuecomment-2230701372)
      [6](vscode-notebook-cell:?execution_count=9&line=6)         r"start_recording_(?P<trial>(?:PRACTICE_)?trial_\d+)_(?P<screen>.+)",
      [7](vscode-notebook-cell:?execution_count=9&line=7)         {"pattern": r"stop_recording_", "column": "trial", "value": None},
      [8](vscode-notebook-cell:?execution_count=9&line=8)         {"pattern": r"stop_recording_", "column": "screen", "value": None},
      [9](vscode-notebook-cell:?execution_count=9&line=9)         {
     [10](vscode-notebook-cell:?execution_count=9&line=10)             "pattern": r"start_recording_(?:PRACTICE_)?trial_\d+_page_\d+",
     [11](vscode-notebook-cell:?execution_count=9&line=11)             "column": "activity",
     [12](vscode-notebook-cell:?execution_count=9&line=12)             "value": "reading",
     [13](vscode-notebook-cell:?execution_count=9&line=13)         },
     [14](vscode-notebook-cell:?execution_count=9&line=14)         {
     [15](vscode-notebook-cell:?execution_count=9&line=15)             "pattern": r"start_recording_(?:PRACTICE_)?trial_\d+_question_\d+",
     [16](vscode-notebook-cell:?execution_count=9&line=16)             "column": "activity",
     [17](vscode-notebook-cell:?execution_count=9&line=17)             "value": "question",
     [18](vscode-notebook-cell:?execution_count=9&line=18)         },
     [19](vscode-notebook-cell:?execution_count=9&line=19)         {
     [20](vscode-notebook-cell:?execution_count=9&line=20)             "pattern": r"start_recording_(?:PRACTICE_)?trial_\d+_(familiarity_rating_screen_\d+|subject_difficulty_screen)",
     [21](vscode-notebook-cell:?execution_count=9&line=21)             "column": "activity",
     [22](vscode-notebook-cell:?execution_count=9&line=22)             "value": "rating",
...
     [36](vscode-notebook-cell:?execution_count=9&line=36)     ],
     [37](vscode-notebook-cell:?execution_count=9&line=37) )
     [38](vscode-notebook-cell:?execution_count=9&line=38) print(data.frame)

NameError: name 'pm' is not defined
Output is truncated. View as a [scrollable element](command:cellOutput.enableScrolling?5bb46a26-e9ce-452d-9f52-66969865f05e) or open in a [text editor](command:workbench.action.openLargeOutput?5bb46a26-e9ce-452d-9f52-66969865f05e). Adjust cell output [settings](command:workbench.action.openSettings?%5B%22%40tag%3AnotebookOutputLayout%22%5D)...
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[15], [line 3](vscode-notebook-cell:?execution_count=15&line=3)
      [1](vscode-notebook-cell:?execution_count=15&line=1) import polars as pl
      [2](vscode-notebook-cell:?execution_count=15&line=2) from pathlib import Path
----> [3](vscode-notebook-cell:?execution_count=15&line=3) import pymovements as pm

File ~\Desktop\pymovements\pymovements\src\pymovements\__init__.py:26
     [24](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/kubar/Desktop/pymovements/pymovements/docs/source/tutorials/~/Desktop/pymovements/pymovements/src/pymovements/__init__.py:24) from pymovements import exceptions
     [25](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/kubar/Desktop/pymovements/pymovements/docs/source/tutorials/~/Desktop/pymovements/pymovements/src/pymovements/__init__.py:25) from pymovements import gaze
---> [26](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/kubar/Desktop/pymovements/pymovements/docs/source/tutorials/~/Desktop/pymovements/pymovements/src/pymovements/__init__.py:26) from pymovements import measure
     [27](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/kubar/Desktop/pymovements/pymovements/docs/source/tutorials/~/Desktop/pymovements/pymovements/src/pymovements/__init__.py:27) from pymovements import plotting
     [28](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/kubar/Desktop/pymovements/pymovements/docs/source/tutorials/~/Desktop/pymovements/pymovements/src/pymovements/__init__.py:28) from pymovements import reading_measures

File ~\Desktop\pymovements\pymovements\src\pymovements\measure\__init__.py:23
     [21](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/kubar/Desktop/pymovements/pymovements/docs/source/tutorials/~/Desktop/pymovements/pymovements/src/pymovements/measure/__init__.py:21) from pymovements.measure.library import register_sample_measure
     [22](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/kubar/Desktop/pymovements/pymovements/docs/source/tutorials/~/Desktop/pymovements/pymovements/src/pymovements/measure/__init__.py:22) from pymovements.measure.library import SampleMeasureLibrary
---> [23](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/kubar/Desktop/pymovements/pymovements/docs/source/tutorials/~/Desktop/pymovements/pymovements/src/pymovements/measure/__init__.py:23) from pymovements.measure.measures import null_ratio
     [25](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/kubar/Desktop/pymovements/pymovements/docs/source/tutorials/~/Desktop/pymovements/pymovements/src/pymovements/measure/__init__.py:25) __all__ = [
     [26](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/kubar/Desktop/pymovements/pymovements/docs/source/tutorials/~/Desktop/pymovements/pymovements/src/pymovements/measure/__init__.py:26)     'SampleMeasureLibrary',
     [27](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/kubar/Desktop/pymovements/pymovements/docs/source/tutorials/~/Desktop/pymovements/pymovements/src/pymovements/measure/__init__.py:27)     'register_sample_measure',
     [28](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/kubar/Desktop/pymovements/pymovements/docs/source/tutorials/~/Desktop/pymovements/pymovements/src/pymovements/measure/__init__.py:28) 
     [29](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/kubar/Desktop/pymovements/pymovements/docs/source/tutorials/~/Desktop/pymovements/pymovements/src/pymovements/measure/__init__.py:29)     'null_ratio',
     [30](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/kubar/Desktop/pymovements/pymovements/docs/source/tutorials/~/Desktop/pymovements/pymovements/src/pymovements/measure/__init__.py:30) ]
...
    [280](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/kubar/Desktop/pymovements/pymovements/docs/source/tutorials/~/Desktop/pymovements/pymovements/src/pymovements/gaze/gaze_dataframe.py:280)             ),
    [281](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/kubar/Desktop/pymovements/pymovements/docs/source/tutorials/~/Desktop/pymovements/pymovements/src/pymovements/gaze/gaze_dataframe.py:281)             trial_columns=self.trial_columns,
    [282](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/kubar/Desktop/pymovements/pymovements/docs/source/tutorials/~/Desktop/pymovements/pymovements/src/pymovements/gaze/gaze_dataframe.py:282)         )

AttributeError: module 'pymovements' has no attribute 'EventDataFrame'
Output is truncated. View as a [scrollable element](command:cellOutput.enableScrolling?a8edb431-d883-4150-a841-54209e39cec1) or open in a [text editor](command:workbench.action.openLargeOutput?a8edb431-d883-4150-a841-54209e39cec1). Adjust cell output [settings](command:workbench.action.openSettings?%5B%22%40tag%3AnotebookOutputLayout%22%5D)...

@SiQube
Copy link
Member

SiQube commented Oct 25, 2024

it is hard to judge your problem @romajaku but it is unrelated to the original issue.

it seems like you have a notebook within a cloned pymovements repository, created in src/pymovements/.... (I conclude this from this line: data_path = Path("../../../tests/files/eyelink_monocular_example.asc"))

if you move your notebook to the root of the repository your error should disappear

@dkrako dkrako added the essential important label Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working essential important
Projects
None yet
Development

No branches or pull requests

3 participants