Page MenuHomePhabricator

Extend `SimplexEnv.build_configuration_stack()`
ClosedPublic

Authored by chris on Jul 28 2019, 1:30 PM.

Details

Summary

This adds functionality to the build_configuration_stack method in SimplexEnv such that we can read in multiple configuration sources while preserving precedence among them. (Database configs outrank local configs outrank default configs)

Test Plan

code review

Diff Detail

Repository
rSIM Simplex
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

chris requested review of this revision.Jul 28 2019, 1:30 PM
chris created this revision.
chris updated this revision to Diff 47.Jul 28 2019, 1:38 PM

Fix an import issue

chris updated this revision to Diff 48.Jul 28 2019, 3:17 PM

Correct a bunch of silly class stuff

brooke added inline comments.Jul 28 2019, 8:06 PM
simplex/infrastructure/config.py
5

so APP_ROOT = /simplex ?

simplex/infrastructure/env/config_source.py
3

I get confused. I thought APP_ROOT is under simplex/infrastructure/config?
Does this work?

56

line 56, 60, 64, return nothing? What is the intent?

67

if can_write is always True, why do we need to define it?

simplex/infrastructure/env/simplex_env.py
59

what is the functionality of **?

chris added inline comments.Jul 28 2019, 8:22 PM
simplex/infrastructure/config.py
5

The absolute path, whatever that is. For example, on my local machine it's /Users/chris/Documents/simplex/simplex

simplex/infrastructure/env/config_source.py
3

It does work, yes! That's because in simplex/__init__.py I also added the import:

from simplex.infrastructure.config import APP_ROOT
56

Functions should always explicitly return. In this case, there's just not any specific value that we want to return.

67

Because it's False by default: we need to override the default configuration specified in the SimplexConfigSource class above.

simplex/infrastructure/env/simplex_env.py
59

Basically says "Take Dictionary A and Dictionary B and combine them together." In the case where both dictionaries have the same key(s), Dictionary B's key takes precedence. E.g.,

>>> a = {'a':1, 'b': 2}
>>> b = {'b': 9, 'c': 3}
>>> {**a, **b}
{'a': 1, 'b': 9, 'c': 3}
brooke accepted this revision.Aug 4 2019, 1:35 PM
This revision is now accepted and ready to land.Aug 4 2019, 1:35 PM
This revision was automatically updated to reflect the committed changes.