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

Some sections of cfg_dingo are not available after pickle re-import #171

Closed
gplssm opened this issue May 17, 2017 · 5 comments
Closed

Some sections of cfg_dingo are not available after pickle re-import #171

gplssm opened this issue May 17, 2017 · 5 comments
Assignees
Labels
bug Prio2 Priority Level 2

Comments

@gplssm
Copy link
Contributor

gplssm commented May 17, 2017

When re-importing NetworkDingo that was earlier pickled to a file, some sections of cfg_dingo aren't available anymore.

Add

import pickle
pickle.dump(nd,
            open("dingo_grids_{0}.pkl".format(mv_grid_districts[0]), "wb"))

then re-import this data with

import pickle

a = pickle.load(open('dingo_grids_3545.pkl', 'rb'))
a.to_dataframe()

a.to_dataframe() runs into to a KeyError because section 'geo' is not available in cfg_dingo.

@gplssm gplssm added the bug label May 17, 2017
@gplssm gplssm added this to the LV grids milestone May 17, 2017
@gplssm gplssm self-assigned this May 17, 2017
@gplssm gplssm modified the milestones: Release DINGO v0.1, LV grids May 17, 2017
@gplssm
Copy link
Contributor Author

gplssm commented May 17, 2017

The import of cfg_dingo takes place in the example.py script and not in the nd-object nor in its associated classes. Probably only the config file config_db_table.cfg is imported somewhere in nd. Thus, its sections are contained in cfg_dingo.

Potential solutions

  1. Replace cfg_dingo.get(...) by hard-coded values or values retrieved from other sources
  2. Move cfg_dingo imports to the beginning of nd

What do you think about option 2, @nesnoj ?

@nesnoj
Copy link
Member

nesnoj commented May 18, 2017

👍 Option 2 👍
U gonna do this?

@nesnoj
Copy link
Member

nesnoj commented May 19, 2017

"Some" measures were required to fix this one:

  1. Moved import of config to ND (90c0c1a)
  2. Moved import of ORM to ND (bf61b61)
  3. Introducing property decorator "network" to all classes for accessing config of ND (7ef7d77, 1e044f2)

So the config is now accessible at NetworkDingo.config, from classes class.network.config.

Within dingo, the access on config data via cfg_dingo.get() remains as it is, modifications for access via ND's config were implemented in an extra branch but too shabby to use it in dev (for now: we better keep it trapped there).

@nesnoj nesnoj closed this as completed May 19, 2017
@nesnoj
Copy link
Member

nesnoj commented Jan 9, 2019

Concerning the content in the mentioned branch feature/get_config_data_from_nd:
Instead of doing this by hook or by crook using a Network instance, this might be done using @classmethod decorator..

@nesnoj nesnoj reopened this Jan 9, 2019
@boltbeard boltbeard added the Prio2 Priority Level 2 label Jan 15, 2019
@piaulous
Copy link
Collaborator

Closed, handling of pickle option will be discussed in #386.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Prio2 Priority Level 2
Projects
None yet
Development

No branches or pull requests

4 participants