Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
bliss
bliss
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 530
    • Issues 530
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Jira
    • Jira
  • Merge Requests 136
    • Merge Requests 136
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Bliss
  • blissbliss
  • Issues
  • #1654

Closed
Open
Opened May 25, 2020 by Matias Guijarro@matias.guijarro
  • Report abuse
  • New issue
Report abuse New issue

"simple" config settings and "complex" default values

(following discussion with @berruyer )

When using simple settings that match Redis types (like SimpleSetting, HashSetting for example), we can give a default value that has a complexity beyond the Redis type. For example:

my_setting = HashSetting("toto", default_values={"a":{"tutu":5}, "b":3})

This creates a toto hash in Redis - so far so good. We can then do:

a_dict = my_setting["a"]
a_dict["tutu"] = 7
my_setting["a"] = a_dict # side note: this is also confusing, because the natural thing is to do
                         # my_setting["a"]["tutu"]=7` but this does not update the value in redis
                         # (but it is another, more difficult, "problem" ; maybe the easiest is
                         # just to not support __setitem__ and __getitem__ ?)

in order to update the value.

Except that this does not work as expected, because it is transformed into a string:

>>> my_setting
<HashSetting name=toto value={'a': "{'tutu': 7}", 'b': 3}>

This is because read_type_conversion only understand scalars, and write_type_conversion is str.

A solution is to use HashObjSetting for example => conversions are done with pickle.

The question is:

  • should we limit HashSetting and simple settings to only scalar values ?
  • how to make user experience better ?
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
1
Labels
help wanted
Assign labels
  • View project labels
Reference: bliss/bliss#1654