wsp-sag / Lasso

Python package of utilities for Network Wrangler
https://wsp-sag.github.io/Lasso/
Apache License 2.0
5 stars 3 forks source link

Import Project fails if not in Lasso directory #61

Open e-lo opened 4 years ago

e-lo commented 4 years ago
from lasso import Project

when executed from a directory one-above the Lasso directory yields:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-1-90cb97b4abc9> in <module>
----> 1 from lasso import Project

~/Documents/urbanlabs/MetCouncil/working/client_met_council_wrangler_utilities/lasso/__init__.py in <module>
      1 __version__ = "0.0.0"
      2 
----> 3 from .project import Project
      4 from .transit import CubeTransit, StandardTransit
      5 from .util import get_shared_streets_intersection_hash

~/Documents/urbanlabs/MetCouncil/working/client_met_council_wrangler_utilities/lasso/project.py in <module>
     10 from network_wrangler import RoadwayNetwork
     11 
---> 12 from .transit import CubeTransit, StandardTransit
     13 from .logger import WranglerLogger
     14 from .parameters import Parameters

~/Documents/urbanlabs/MetCouncil/working/client_met_council_wrangler_utilities/lasso/transit.py in <module>
     24 
     25 from .logger import WranglerLogger
---> 26 from .parameters import Parameters
     27 
     28 

~/Documents/urbanlabs/MetCouncil/working/client_met_council_wrangler_utilities/lasso/parameters.py in <module>
     15 
     16 
---> 17 class Parameters:
     18     """A class representing all the parameters defining the networks
     19     including time of day, categories, etc.

~/Documents/urbanlabs/MetCouncil/working/client_met_council_wrangler_utilities/lasso/parameters.py in Parameters()
    359     """
    360 
--> 361     BASE_DIR = get_base_dir()
    362     DATA_FILE_LOCATION = os.path.join(BASE_DIR,  "metcouncil_data")
    363 

~/Documents/urbanlabs/MetCouncil/working/client_met_council_wrangler_utilities/lasso/parameters.py in get_base_dir(init_d)
     12     msg = "Cannot find Lasso base directory from {}, please input using keyword in parameters: `lasso_dir =` ".format(init_d)
     13     WranglerLogger.error(msg)
---> 14     raise(ValueError(msg))
     15 
     16 

ValueError: Cannot find Lasso base directory from /Users/elizabeth/Documents/urbanlabs/MetCouncil/working, please input using keyword in parameters: `lasso_dir =` 
e-lo commented 4 years ago

Issue:

BASE_DIR = get_base_dir() in Parameters class should not throw an error when executed at the Class level; only when an instantiated.

Easy resolution (famous last words)...standby.

e-lo commented 4 years ago

Actually nmd...the problem is that __init__() is being run for CubeTransit when it is imported. Will look at this tomorrow.

@jhelsel11 - easiest work-around right now is just to store the notebook where you installed Lasso.

jhelsel11 commented 4 years ago

Will do. I'll have to move my data into subfolders of lasso as well, right?

e-lo commented 4 years ago

You shouldn't have to, no. You can specify where your data is stored when you instantiate a project

On Fri, Feb 14, 2020 at 8:24 AM John Helsel notifications@github.com wrote:

Will do. I'll have to move my data into subfolders of lasso as well, right?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/wsp-sag/Lasso/issues/61?email_source=notifications&email_token=AAGCBI7VVFE2CAS67CLO7ADRC3AU7A5CNFSM4KVBGDTKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELZSXKY#issuecomment-586361771, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGCBI6UDMMAQMBRKR6KW33RC3AU7ANCNFSM4KVBGDTA .

jhelsel11 commented 4 years ago

I'll try that.

e-lo commented 4 years ago

Problem was instantiating Parameters() from the parameters in a method. Fix pushed to develop and running thru tests now...