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 pykanto from development mode #19

Open
gg4u opened this issue Feb 25, 2023 · 2 comments
Open

using pykanto from development mode #19

gg4u opened this issue Feb 25, 2023 · 2 comments
Assignees
Labels
priority: low type: docs type: question Further information is requested

Comments

@gg4u
Copy link

gg4u commented Feb 25, 2023

I am trying to circumvent the issue:
#18 (comment)

I reinstalled pykanto as shown here:

git clone https://github.com/nilomr/pykanto.git
cd pykanto
pip install -e '.[dev, test, doc]'

I can bypass the issue above in the calc_chunks() function, /utils/compute.py:

   if not n_workers:
        try:
            n_workers = len(psutil.Process().cpu_affinity())
        except:
            print('Mac OS does not support cpu_affinity() in psutil. Default to 4 workers')
            n_workers = 4

And will follow the basic workflow steps:

from pykanto.utils.paths import pykanto_data
from pykanto.dataset import KantoData
from pykanto.parameters import Parameters


DATASET_ID = "GREAT_TIT"
DIRS = pykanto_data(dataset=DATASET_ID)
# ---------
params = Parameters() # Using default parameters for simplicity, which you should't!
dataset = KantoData(DIRS, parameters=params, overwrite_dataset=True)
dataset.data.head(3)

but now FileNotFoundError is raised:

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
Cell In[122], line 2
      1 DATASET_ID = "GREAT_TIT"
----> 2 DIRS = pykanto_data(dataset=DATASET_ID)
      3 # ---------
      4 params = Parameters() # Using default parameters for simplicity, which you should't!

File ~/Sites/miniconda3/lib/python3.9/site-packages/pykanto/utils/paths.py:431, in pykanto_data(dataset)

File ~/Sites/miniconda3/lib/python3.9/site-packages/pykanto/utils/paths.py:89, in ProjDirs.__init__(self, PROJECT, RAW_DATA, DATASET_ID, mkdir)
     80 def __init__(
     81     self,
     82     PROJECT: Path,
   (...)
     87 
     88     # Type check input paths
---> 89     d = ValidDirs(PROJECT, RAW_DATA, DATASET_ID)
     91     # Define project directories
     92     self.PROJECT = d.PROJECT

File <attrs generated init pykanto.utils.types.ValidDirs>:6, in __init__(self, PROJECT, RAW_DATA, DATASET_ID)
      4 self.DATASET_ID = DATASET_ID
      5 if _config._run_validators is True:
----> 6     __attr_validator_PROJECT(self, __attr_PROJECT, self.PROJECT)
      7     __attr_validator_RAW_DATA(self, __attr_RAW_DATA, self.RAW_DATA)
      8     __attr_validator_DATASET_ID(self, __attr_DATASET_ID, self.DATASET_ID)

File ~/Sites/miniconda3/lib/python3.9/site-packages/attr/_make.py:2146, in _AndValidator.__call__(self, inst, attr, value)
   2144 def __call__(self, inst, attr, value):
   2145     for v in self._validators:
-> 2146         v(inst, attr, value)

File ~/Sites/miniconda3/lib/python3.9/site-packages/pykanto/utils/types.py:46, in f_exists(instance, attribute, f)
     42 """
     43 File exists validator for attr.s decorator.
     44 """
     45 if not f.exists():
---> 46     raise FileNotFoundError(f)

FileNotFoundError: /Users/gg4u/Sites/miniconda3/lib/python3.9/site-packages/pykanto

Does the above code automatically set the path and download the db ?
Or is me that have to set correct path in advance ?

It seems cannot find the PROJECT directory.|

Thanks for helping Nilo!!

@nilomr nilomr self-assigned this Feb 26, 2023
@nilomr nilomr added type: bug Something isn't working type: docs priority: high type: question Further information is requested and removed type: bug Something isn't working labels Feb 26, 2023
@nilomr
Copy link
Owner

nilomr commented Feb 27, 2023

Thanks for raising this. I can't seem to reproduce the error— @gg4u could you run the following and share the output?

import pkg_resources
from pathlib import Path
pydata = Path(pkg_resources.resource_filename("pykanto", "data"))
print(pydata, pydata.parent.exists())

For reference, within a conda environment (you seem to have installed pykanto on your base env), this is my output:

/home/nilomr/miniconda3/envs/pykanto-testing/lib/python3.9/site-packages/pykanto/data True

Thanks!

@gg4u
Copy link
Author

gg4u commented Feb 27, 2023

Hi! thanks for following up with me :)

I uninstalled pykanto that was installed via pip, so that I can edit and circumvent errors:
#18 (comment)

I installed pykanto by cloning your repo and installing it from there:
pip install -e '.[dev, test, doc]'

For testing, I am using a notebook in the /pykanto/ folder of the cloned git.

The above code yields:

/Users/[MYPATH]/Sites/pykanto/pykanto/data True

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: low type: docs type: question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants