Skip to content
This repository has been archived by the owner on Feb 27, 2019. It is now read-only.

Features/cli app #1

Open
wants to merge 84 commits into
base: master
Choose a base branch
from
Open

Features/cli app #1

wants to merge 84 commits into from

Conversation

simnh
Copy link
Contributor

@simnh simnh commented Dec 20, 2018

No description provided.

Copy link

@gnn gnn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what I found so far. Only minor things, nothing big.
A few more general notes:

  • Maybe we can drop download_rawdata.py and move the single function call to the cli?
  • scripts is a rather general name that doesn't convey any meaning. How about moving the modules below it to the top or find places for them with more speaking names.
  • Is there a way to merge the two configuration files? Maybe by having a scenario section?

But bus.py, capacity_factors.py, compute.py, electricity.py and grid.py are rather long and not exactly easy to figure out. So I'll have to spend more time reading them to figure out whether there's a necessity to refactor them.

src/fuchur/__init__.py Outdated Show resolved Hide resolved
src/fuchur/cli.py Outdated Show resolved Hide resolved
directories=["data", "resources"]
)

datapackage.building.initialize_datapackage(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All those calls having nearly the same signature could potentially be written shorter. But they also hint at a refactoring potential. Don't know whether any of this would really be an improvement though. The first option would be shorter, but harder to read. For refactoring I would have to check out the functions in question.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont know what you mean...

src/fuchur/cli.py Outdated Show resolved Hide resolved
@click.pass_context
def construct(ctx, config):
config = datapackage.building.read_build_config(config)
_construct(config, ctx)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd avoid those underscore methods. If you don't want to clutter the fuchur.cli with these long functions, put them in another module.
Also, you don't have to import as _compute to avoid the name clash. If you just do import fuchur.scripts.compute, the module will only be available under its fully qualified name. ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can change this if you like

src/fuchur/scripts/electricity.py Outdated Show resolved Hide resolved
src/fuchur/scripts/electricity.py Outdated Show resolved Hide resolved
src/fuchur/scripts/electricity.py Show resolved Hide resolved
src/fuchur/scripts/electricity.py Outdated Show resolved Hide resolved
src/fuchur/scripts/electricity.py Outdated Show resolved Hide resolved
gnn and others added 30 commits January 16, 2019 17:02
I saw the `allow_failures` key was on the same level as `matrix`,
instead of being subordinate to it.
The way it is now should replicate the example. Hope it works.
Two is the number of empty lines you should put after your imports and
the number of empty lines you should put after your imports is two.
Otherwise you will never defeat the Killer Rabbit of Caerbannog. ;)
Now you can specify built in scenarios by their `name` when running
`fuchur construct`.
This is done by implementing the `Scenario` class, which has the
following features:

  * It encapsulates loading scenario from a path via the `from_path`
    class method and
  * it looks for a `parents` key in the loaded scenario, which enables
    copying other scenarios into this one.

The `from_path` method does everything that is necessary to load a
scenario from a file. This currently entails:

  * using a special function from `oemof.tabular` instead of just using
    `toml.load` and
  * registering the loaded scenario as known under `fuchur.scenarios`
    under its name and its path.

A scenario's `parents` can be specified as a list of strings, which will
be looked up in `fuchur`'s known scenarios. If they string is not found,
it is tried to be loaded via `Scenario.from_path`.
You can now specify builtin scenarios simply by their `name` when
calling `fuchur construct` and you can copy other scenarios into a
scenario by referring to the former via a `parents` entry in the latter.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants