Skip to content

config: generate sample-config files containing all and only classes relevant to configurable traits#289

Merged
minrk merged 4 commits intoipython:masterfrom
ankostis:sample_conf_with_inheritance
Aug 26, 2016
Merged

config: generate sample-config files containing all and only classes relevant to configurable traits#289
minrk merged 4 commits intoipython:masterfrom
ankostis:sample_conf_with_inheritance

Conversation

@ankostis
Copy link
Copy Markdown
Contributor

The motivation is the user to know the relationships between the classes
in the generated sample configuration-file, so that he can choose at
which inheritance-level to override some trait value.

@ankostis ankostis force-pushed the sample_conf_with_inheritance branch from 3883c49 to 4ed2009 Compare August 24, 2016 14:42
@ankostis
Copy link
Copy Markdown
Contributor Author

Rational: This PR ensures that the sample-config file will describe to the user AND contain all the classes on which a trait-value may be overridden:

  • either on the class owning the trait,
  • or on its subclasses, even if those subclasses do not define any traits themselves.

@ankostis ankostis changed the title config: print also parent-classnames when generating configs. config: generate sample-config files containing all and only classes relevant to configurable traits Aug 24, 2016
@minrk minrk added this to the 5.0 milestone Aug 24, 2016
@ankostis
Copy link
Copy Markdown
Contributor Author

ankostis commented Aug 24, 2016

Attaching generated configs to facilitate review.

The differences between the 2 listings are the following:

  1. The NoTraits class is included in the sample config-file (at the bottom),
    although it has not traits of its own. That way, the user may add overriding values for traits present in its parent configurables (Foo and `Bar).
  2. The parent configurables of each class are listed in the parenthesis after its name.
  3. The identation of the property-description is different from the value-overriding python-statement, visualized best in the Foo.i property which has a long help-text.

With this PR:

#------------------------------------------------------------------------------
# Application(SingletonConfigurable) configuration
#------------------------------------------------------------------------------

# This is an application.

## The date format used by logging formatters for %(asctime)s
#c.Application.log_datefmt = '%Y-%m-%d %H:%M:%S'

## The Logging format template
#c.Application.log_format = '[%(name)s]%(highlevel)s %(message)s'

## Set the log level by value or name.
#c.Application.log_level = 30

#------------------------------------------------------------------------------
# MyApp(Application) configuration
#------------------------------------------------------------------------------

# This is an application.

## Load this config file
#c.MyApp.config_file = ''

## Is the app running?
#c.MyApp.running = False

## Should print a warning if `MyApp.warn-typo=...` command is passed
#c.MyApp.warn_tpyo = 'yes the name is wrong on purpose'

#------------------------------------------------------------------------------
# Bar(Configurable) configuration
#------------------------------------------------------------------------------

## The integer b.
#c.Bar.b = 0

## Enable bar.
#c.Bar.enabled = True

#------------------------------------------------------------------------------
# Foo(Configurable) configuration
#------------------------------------------------------------------------------

## Some long running text: Lorem ipsum dolor sit amet, consectetur adipiscing
#  elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
#  enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
#  aliquip ex ea commodo consequat.
#c.Foo.i = 0

## The integer j.
#c.Foo.j = 1

## First name.
#c.Foo.name = 'Brian'

#------------------------------------------------------------------------------
# NoTraits(Foo,Bar) configuration
#------------------------------------------------------------------------------

Without this PR:

#------------------------------------------------------------------------------
# Application configuration
#------------------------------------------------------------------------------

# This is an application.

# The date format used by logging formatters for %(asctime)s
# c.Application.log_datefmt = '%Y-%m-%d %H:%M:%S'

# The Logging format template
# c.Application.log_format = '[%(name)s]%(highlevel)s %(message)s'

# Set the log level by value or name.
# c.Application.log_level = 30

#------------------------------------------------------------------------------
# MyApp configuration
#------------------------------------------------------------------------------

# This is an application.

# Load this config file
# c.MyApp.config_file = ''

# Is the app running?
# c.MyApp.running = False

# Should print a warning if `MyApp.warn-typo=...` command is passed
# c.MyApp.warn_tpyo = 'yes the name is wrong on purpose'

#------------------------------------------------------------------------------
# Bar configuration
#------------------------------------------------------------------------------

# The integer b.
# c.Bar.b = 0

# Enable bar.
# c.Bar.enabled = True

#------------------------------------------------------------------------------
# Foo configuration
#------------------------------------------------------------------------------

# Some long running text: Lorem ipsum dolor sit amet, consectetur adipiscing
# elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
# enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
# aliquip ex ea commodo consequat.
# c.Foo.i = 0

# The integer j.
# c.Foo.j = 1

# First name.
# c.Foo.name = 'Brian'

@ankostis
Copy link
Copy Markdown
Contributor Author

Updated the sample above to compare the new "demarcation" commit.

@ankostis ankostis force-pushed the sample_conf_with_inheritance branch from c9c75c9 to fcb4716 Compare August 25, 2016 10:41
ankostis added a commit to ankostis/traitlets that referenced this pull request Aug 25, 2016
… configs.

The motivation is the user to know the relationships between the classes
in the generated sample configuration-file, so that he can choose at
which inheritance-level to override some trait value.
ankostis added a commit to ankostis/traitlets that referenced this pull request Aug 25, 2016
…ir subclasses.

Rational: This commit, along with the previous for printing also all
configurable class-parents, ensures that the sample-config file will
contain all classes on which a
trait-value may be overridden:
- either on the class owning the trait,
- or on its subclasses, even if those subclasses do not define any
traits themselves.
ankostis added a commit to ankostis/traitlets that referenced this pull request Aug 25, 2016
ankostis added a commit to ankostis/traitlets that referenced this pull request Aug 25, 2016
… configs.

The motivation is the user to know the relationships between the classes
in the generated sample configuration-file, so that he can choose at
which inheritance-level to override some trait value.
…ir subclasses.

Rational: This commit, along with the previous for printing also all
configurable class-parents, ensures that the sample-config file will
contain all classes on which a
trait-value may be overridden:
- either on the class owning the trait,
- or on its subclasses, even if those subclasses do not define any
traits themselves.
@ankostis ankostis force-pushed the sample_conf_with_inheritance branch from fcb4716 to 9a2079d Compare August 25, 2016 10:45
@minrk minrk modified the milestones: 4.3, 5.0 Aug 26, 2016
@minrk
Copy link
Copy Markdown
Member

minrk commented Aug 26, 2016

Makes sense, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants