ActivitySim / populationsim

An Open Platform for Population Synthesis
https://activitysim.github.io/populationsim
Other
52 stars 38 forks source link

Bug: populationsim.util does not exist #138

Open majthehero opened 2 years ago

majthehero commented 2 years ago

I tried to run the examples according to the online documentation. Currently, the examples do not work:

Traceback (most recent call last):
  File ".\run_populationsim.py", line 15, in <module>
    from populationsim.util import setting
ModuleNotFoundError: No module named 'populationsim.util'

I have checked what the problem is and implemented the function setting(attribute_name) that should be in the util module. I have successfully managed to run the examples by replacing the import from populationsim.util import setting with a function pasted below:

import yaml

def setting(attribute_name):
  # read settings.yaml located in ./configs/
  with open("./configs/settings.yaml", 'r') as stream:
    try:
      settingsObj = yaml.safe_load(stream)
    except yaml.YAMLError as exc:
      print("oh no, no settings.yaml file in ./configs")
      print(exc)

  try:
    return settingsObj[attribute_name]
  except:
    print("oh not, attribute " + attribute_name + " does not exist in settings.yaml")

I suspect that the util module is deprecated and the examples need to be updated.

bstabler commented 2 years ago

Hi. I cannot recreate this issue. What version of populationsim and activitysim do you have installed? And what command are you using to run the example? Thanks.

friedtea15 commented 1 year ago

I had the same issue, following the installation guide here: https://activitysim.github.io/populationsim/getting_started.html#installation#150

@majthehero solution worked here

bettinardi commented 9 months ago

I wonder if updating the example #90 - will resolve this issue by making it obsolete