populationsim icon indicating copy to clipboard operation
populationsim copied to clipboard

Bug: populationsim.util does not exist

Open majthehero opened this issue 3 years ago • 3 comments

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.

majthehero avatar Aug 13 '21 12:08 majthehero

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.

bstabler avatar Aug 21 '21 00:08 bstabler

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

@majthehero solution worked here

friedtea15 avatar Jan 03 '23 09:01 friedtea15

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

bettinardi avatar Oct 06 '23 16:10 bettinardi