Skip to content

Implement lazy Session objects #727

Open

Description

@alixdamman

@gdementen almost all our users define their arrays in some params.py module as "zeros" arrays and fill them with proper data later (by reading data from CSV, Excel or HDF files). They have a lot of arrays but they often use only some of them when they run a part of their model.

We need to find a way to spare memory and to use memory only when it's needed.
What's your opinion on that?

Activity

  1. added this to the 0.30 milestone on Nov 28, 2018
  2. gdementen commented on Nov 28, 2018

    @gdementen
    Contributor

    I have some working proof-of-concept code for lazy Session objects in my experiments folder. It assumes you declare your sessions and arrays like this:

    class Demo(StaticSession):
        hh = ArrayDef()
        pop = ArrayDef("a=a0..a3")

    instead of creating arrays filled with zeros. This also gets you completion for session arrays. Arrays are then loaded when first used. FWIW, in the example above "hh" is lazy but can have any shape/axes while "pop" is checked that it contains an a axis with those labels. I don't remember how much work is still needed for this to be actually usable, but I think it was significant. Anyway, I think 0.30 is way too early for that feature (at least if I have to do it).

    I think we could also support some form of LazyArray outside of a session but that probably needs even more work (if at all possible) and I am unsure it is worth it. I would have to think about that. It's hard to say before hand.

  3. changed the title [-]Implement lazy LArray objects[/-] [+]Implement lazy Session objects[/+] on Nov 28, 2018
  4. alixdamman commented on Nov 28, 2018

    @alixdamman
    CollaboratorAuthor

    I don't think having LazyArray outside of a session is needed. IMO, implementing StaticSession would be enough. Users should NOT declare variables as global.

    I wonder if after implementing StaticSession we should not make global_arrays and arrays private functions and use them internally only when calling view() or edit() without argument?

  5. modified the milestones: 0.30, 0.31 on Nov 28, 2018
  6. gdementen commented on Nov 28, 2018

    @gdementen
    Contributor

    I wonder if after implementing StaticSession we should not make global_arrays and arrays private functions and use them internally only when calling view() or edit() without argument?

    I don't think so. There are cases where global_arrays()/arrays() will still be more practical than creating a Session explicitly. It's ugly but practical... Time will tell...

  7. removed this from the 0.31 milestone on Aug 1, 2019
  8. 1 remaining item

  9. removed their assignment
    on Oct 1, 2019
  10. gdementen commented on Oct 7, 2019

    @gdementen
    Contributor

    I don't think I will have time to finish a clean version of this in time for the release.

  11. removed this from the 0.32 milestone on Oct 7, 2019
  12. added this to the nice_to_have milestone on Oct 10, 2019
  13. modified the milestones: nice_to_have, 0.33 on Dec 19, 2019
  14. modified the milestones: 0.33, 0.34 on Jul 29, 2021
  15. modified the milestones: 0.34, 0.35 on Sep 13, 2022
  16. modified the milestones: 0.35, 0.36 on Sep 11, 2023
  17. modified the milestones: 0.36, 0.37 on Oct 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions