the anomalous diffusion challenge Forum

Go back to competition Back to thread list Post in this thread

> Installation issues

Dear Organizers! Many thanks for setting up the challenge. However, I would like to point out an issue in the ANDI package:
1. If you download the package and just run the examples_andi.ipynb via jupyter in the package directory, you get the "ImportError: attempted relative import with no known parent package".
2. Moving the examples_andi.ipynb file outside the package directory and running again gives the "ModuleNotFoundError: No module named 'andi.utils_andi'".
3. I got the same error while running my own demo script with an import from andi package.
3. In order to have it running, I had to change all ".utils_andi" mentions in the package code into just ".utils".
I'm asking myself if it was indeed an error in the package or a misconfiguration of my system?

Best regards,
Janusz

Posted by: szwabin @ March 12, 2020, 10:32 a.m.

Sorry, but there is another problem - running the following code

from andi import ANDI
andi = ANDI()
X1, X2, X3, Y1, Y2, Y3 = andi.andi_dataset(N=10, save_dataset = True)

produces the error:

Traceback (most recent call last):
File "generate_challenge_dataset.py", line 4, in <module>
X1, X2, X3, Y1, Y2, Y3 = andi.andi_dataset(N=10, save_dataset=True)
File "/home/szwabin/PWr/Projekty/SPT/ANDI_CHALLENGE/andi/andi.py", line 747, in andi_dataset
self.save_row(np.append(dim, traj_cut), task1)
TypeError: save_row() takes 2 positional arguments but 3 were given

Best regards,
Janusz

Posted by: szwabin @ March 12, 2020, 10:38 a.m.

Dear Janusz, thanks a lot for your comments. The problems have been solved, if you download the last version available on github everything should be smooth. If you encounter other problems or have any comment, they are more than welcome.

Posted by: gorka.munoz @ March 12, 2020, 10:55 a.m.

Hi!
Thanks for the quick reply, but the "ModuleNotFoundError: No module named 'utils_andi'" error is still there.

Regards,
Janusz

Posted by: szwabin @ March 12, 2020, 11:57 a.m.

Hi, I am not able not reproduce the error. Are you running the example notebook? I guess the error rises when running cell #2? Could you try to run in a different cell ' from utils_andi import normalize '? Thanks!

Gorka

Posted by: gorka.munoz @ March 12, 2020, 1:23 p.m.

Dear Gorka,
yes, I was running the example notebook. Finally, I was able to run the code and save the data to a file after the following steps:
1. Extract the zip file from github to 'andi' folder.
2. Within the folder:
- replace all 'utils_andi' entries by '.utils'.
- replace all 'andi' entries by '.andi'
- replace all 'difussion_models' entries by '.diffusion_models
3. Move examples_andi.ipynb file to the parent folder of 'andi'.
Thus, I've actually restored the relative imports But there is also another possibility. If I unpack the zip from github, remove the __init__.py file and rename utils.py into utils_andi.py, then I can indeed run both the example notebook as well as my own code from within that directory.

Anyway, the issue with saving the data is solved :)

Best regards,
Janusz

Posted by: szwabin @ March 12, 2020, 4:18 p.m.

Removing the __init__.py turned out to be not necessary for the second solution. However, in this case the whole package is not treated as a single module. Thus, running the code is possible only from the directory containing the files andi.py, utils_andi.py and diffusion_models.py.

Janusz

Posted by: szwabin @ March 12, 2020, 4:35 p.m.

Hi Janusz, thanks a lot for the detailed description of the problems. There was indeed an error in the name of the utils.py file. I uploaded a new version to the github with the correct name (utils_andi.py).

If you want to access the ANDI class and other functions from outside the folder, you can add the following to your script:

import sys
sys.path.append('your_path/ANDI_datasets/')
from andi import ANDI
from utils_andi import normalize

Thanks again,

Gorka

Posted by: gorka.munoz @ March 13, 2020, 8:34 a.m.

Hi again,

all the dataset generation is now available as a python package! You just need to do 'pip install andi-datasets' and you will get all the available functions. In the example notebook in github (https://github.com/AnDiChallenge/ANDI_datasets/blob/master/examples_andi.ipynb) you can find all the details on how to import the different functions.

Best,

Gorka

Posted by: gorka.munoz @ March 16, 2020, 2:44 p.m.

Dear Gorka,
many thanks.

Janusz

Posted by: szwabin @ March 16, 2020, 3:51 p.m.

Dear Gorka!
Sorry for bothering you, but after installation of andi as a python package, I got something like this in the examples_andi notebook:

In [1]: import andi
In [2]: AD = andi.andi_datasets()
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-5-df7e29cb55cc> in <module>
----> 1 AD = andi.andi()

This was a clean installation, all other instances of the package have been removed before.

Best regards,
Janusz
TypeError: 'module' object is not callable

Posted by: szwabin @ April 1, 2020, 9:50 a.m.

I pasted the wrong error message (I played with the code a little bit). So here it is once again:

In [1]: import andi
In [2]: AD = andi.andi_datasets()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-6-319e50d1b868> in <module>
----> 1 AD = andi.andi_datasets()

AttributeError: module 'andi' has no attribute 'andi_datasets'

Janusz

Posted by: szwabin @ April 1, 2020, 9:54 a.m.

Dear Janusz,

sorry but I am unable to reproduce the error. The package seems to work fine for me. From your previous message, I understand that andi.andi() works? This may be caused because you are running the notebook in the old version of the repo, and the 'import andi' command is importing the old andi.py file, where andi_datasets was not defined?

Could you run the commands ''import andi; ad = andi.andi_datasets()'' outside that folder? Also the command e.g. df = andi.diffusion_models() should work.

Hope it helps,

Gorka

Posted by: gorka.munoz @ April 1, 2020, 10:04 a.m.

Dear Gorka,
no, andi.andi() does not work. And, as I already mentioned before, there is no old repo on my computer. I just downloaded the file examples_andi.ipynb from github and installed the rest via pip.

To give you more information, I'm using Python 3.7.3 on Ubuntu 19.04.

If you cannot reproduce it, don't worry - I'm still able to run the code from the github repo (with some small changes in the file imports). However, I will have a look at the code at leisure to understand the issue. I will drop a line if I find the problem.

Best regards,
Janusz

Posted by: szwabin @ April 1, 2020, 10:47 a.m.

Dear Janusz,

I checked with a 'third party' that the python package was indeed working as stated in the notebook. Two things you could check: first, that you have the right version of the pip packahge, which should be 0.0.1; second, that you are importing the correct repo, which is now here: https://github.com/AnDiChallenge/ANDI_datasets . Before it was in my personal github account and that may have cause problems.

Nevertheless, if the problem persists, you can contact me by mail (gorka.munoz@icfo.eu) so we can figure out what is happening.

Thanks again,

Gorka

Posted by: gorka.munoz @ April 1, 2020, 3:11 p.m.
Post in this thread