Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc: Add documentation for pyreisejl usage #88

Merged
merged 1 commit into from
Dec 15, 2020

Conversation

ahurli
Copy link
Contributor

@ahurli ahurli commented Dec 7, 2020

Purpose

Document how to use

What is the code doing

The README now includes documentation around how to use pyreisejl (i.e. all the different possible flags) as well as some additional detail about what additional functions these python scripts provide.

It assumes that the user already has the proper setup for Julia, Gurobi, and python.

Where to look

This is all in the README. No code has been touched.

Time estimate

10min

@ahurli ahurli self-assigned this Dec 7, 2020
README.md Outdated
@@ -46,6 +46,166 @@ REISE.run_scenario(;
inputfolder=pwd(), num_segments=3)
```

## Usage (Python)

The python scripts included in `pyreise` perform some additional input validation for the Julia engine before running the simulation and extract data from the resulting `.mat` files to `.pkl` files.
Copy link
Collaborator

Choose a reason for hiding this comment

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

pyreise --> pyreisejl

README.md Outdated
```
-h, --help show this help message and exit
```
Instead of calling `add PACKAGE`, it is also possible to call `dev PACKAGE`, which will always import the latest version of the code on your local machine. See the documentation for the Julia package manager for more information: https://julialang.github.io/Pkg.jl/v1/.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not sure the above paragraph should be in this Running Simulation section.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you! I don't think so either.

Copy link

@ToddG ToddG 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 great but with my newbie to REISE.jl lense, I feel this document needs:

  • dependencies section
  • high level walk through of the user interactions (scripts, etc.)

I definitely feel that since we are tightly coupled with Gurobi, there is going to be a significant barrier to adoption... case in point. Normally as part of a PR I would clone this repo, install the deps, run through the sample commands, ...basically try it out and kick the tires. But w/o said license, I'm just looking on from the sidelines.

@@ -16,7 +16,7 @@ pkg> activate .
Another way is to install the package using the list of dependencies specified in the `Project.toml` file, which will pull the most recent allowed version of the dependencies. Currently, this package is known to be compatible with JuMP v0.21.3; this is specified in the `Project.toml` file, but there may be other packages for which the latest version does not maintain backward-compatibility.

This package is not registered. Therefore, it must be added to a Julia environment either directly from GitHub:
Copy link

Choose a reason for hiding this comment

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

For line 6 above:

Note: If Gurobi.jl is not already installed

I don't think the If should be capitalized here.

For line 4 above:

It seems that the readme is missing a top level dependencies section? I'd expect to see that at the top, so I know where to go to get all the deps etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense! I'll add it in.

README.md Outdated
@@ -30,7 +30,7 @@ Instead of calling `add PACKAGE`, it is also possible to call `dev PACKAGE`, whi
The dependencies of the python scripts contained in `pyreisejl/` are not automatically installed. See `requirements.txt` for details.
Copy link

Choose a reason for hiding this comment

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

Why not add the command here to install the requirements? It's just simple

pip install -r requirements.txt

Or something similar...

@@ -30,7 +30,7 @@ Instead of calling `add PACKAGE`, it is also possible to call `dev PACKAGE`, whi
The dependencies of the python scripts contained in `pyreisejl/` are not automatically installed. See `requirements.txt` for details.


## Usage
## Usage (Julia)
Installation registers a package named `REISE`. Following Julia naming conventions, the `.jl` is dropped. The package can be imported using: `import REISE` to call `REISE.run_scenario()`, or `using REISE` to call `run_scenario()`.
Copy link

Choose a reason for hiding this comment

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

Why not include the import statement in the code snippet in line 38 below. This way a user can see a full working example and just copy and paste.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense! I'm planning on doing a followup PR to revise the Julia/Gurobi bits of the README, so I'll use this feedback for that PR.

@@ -30,7 +30,7 @@ Instead of calling `add PACKAGE`, it is also possible to call `dev PACKAGE`, whi
The dependencies of the python scripts contained in `pyreisejl/` are not automatically installed. See `requirements.txt` for details.


## Usage
## Usage (Julia)
Installation registers a package named `REISE`. Following Julia naming conventions, the `.jl` is dropped. The package can be imported using: `import REISE` to call `REISE.run_scenario()`, or `using REISE` to call `run_scenario()`.

To run a scenario which starts at the `1`st hour of the year, runs in `3` intervals of `24` hours each, loading input data from your present working directory (`pwd()`) and depositing results in the folder `output`, call:
Copy link

Choose a reason for hiding this comment

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

Lines 38-46 below... what are the expected generated output artifacts? What does the julia output log look like? This is where we can help guarantee users are seeing expected behaviour before they tackle more complicated use cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed! But as commented above, I'll use this feedback for the followup PR.

@@ -46,34 +46,195 @@ REISE.run_scenario(;
inputfolder=pwd(), num_segments=3)
```

## Usage (Python)

The python scripts included in `pyreisejl` perform some additional input validation for the Julia engine before running the simulation and extract data from the resulting `.mat` files to `.pkl` files.
Copy link

Choose a reason for hiding this comment

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

I'd suggest a line length limit not to exceed 80 characters. It seems this document is not being linted with that sort of check...

Copy link
Collaborator

Choose a reason for hiding this comment

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

What linter would you use for Markdown documents @ToddG?

README.md Outdated

The python scripts included in `pyreisejl` perform some additional input validation for the Julia engine before running the simulation and extract data from the resulting `.mat` files to `.pkl` files.

For example, a simulation with automatic extraction can be run as follows:
Copy link

Choose a reason for hiding this comment

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

What is automatic extraction?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call. I think I might just take that out here because it's not a required input, and it's addressed later on.


To run the `REISE.jl` simulation from python, run `call.py` with the following required options:
```bash
-s, --start-date START_DATE
Copy link

Choose a reason for hiding this comment

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

What's the story w/respect to Time Zones? This start/end date format does not contain Time Zone Designators (https://en.wikipedia.org/wiki/ISO_8601). Is it assumed to be UTC? If so perhaps that should be stated...

Copy link
Contributor

Choose a reason for hiding this comment

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

We assume that the time zones of the start date & end date match the time zone of the demand/hydro/solar/wind profiles (UTC).

specify the execute directory:
```bash
-x EXECUTE_DIR, --execute-dir EXECUTE_DIR
The directory to store the results. This is optional
Copy link

Choose a reason for hiding this comment

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

what happens if either the output directory (execute directory...boy that's a wonky name) exist already? Are the outputs overwritten or is the computation aborted?

Copy link
Contributor

Choose a reason for hiding this comment

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

Currently, outputs are overwritten.

README.md Outdated
simulation run:
```bash
-t THREADS, --threads THREADS
The number of threads to run the simulation with.
Copy link

Choose a reason for hiding this comment

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

a) indentation

b) what happens if you specify zero threads? what's the max number? what if you exceed the max number?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question. Zero threads defaults to auto, though the invocation of this script from powersimdata requires that it be greater than 0. Negative values do error out eventually, and that's a good call-out for validation that should be added, but I think that might be outside the scope of this PR.

The max number seems to be a little trickier, since I think that gets passed to Gurobi, so that changes depending on what kind of Gurobi license you're using. If you exceed the max number, though, it seems like it'll still run, but just give you a warning:

Thread count: 8 physical cores, 16 logical processors, using up to 200 threads

Warning: Thread count (200) is larger than processor count (16)
         Reduce the value of the Threads parameter to improve performance


# Extracting Simulation Results

The script `extract_data.py` extracts the following Pandas DataFrames from the
Copy link

Choose a reason for hiding this comment

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

How many scripts are there? What's the high level user interaction with this system? It would be nice to have a section at the beginning that outlines how the user interacts with this system, what the different scripts are, etc. Just a high level sort of lay-of-the-land. Then you can dive into each of these commands/scripts/interactions in the guts of the readme. Right now I'm left with the feeling of wading through a mish-mash of scripts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are only two different python scripts which can be combined (i.e. have the second run automatically after the first, decoupled for memory constraint reasons). I'll add some additional notes at the top of the Usage (Python) section, but I definitely think a high-level blurb at the very top would be useful.

@danielolsen
Copy link
Contributor

@ToddG we have a shared Gurobi cloud license that you can use for testing, stored on the Compute server. Do you have access?

@danielolsen
Copy link
Contributor

The commit history will need to be cleaned up here. If I set up the branch rule properly, even with an approval on the PR Github should not allow such a 'non-linear' history to be merged.

@rouille
Copy link
Collaborator

rouille commented Dec 14, 2020

The commit history will need to be cleaned up here. If I set up the branch rule properly, even with an approval on the PR Github should not allow such a 'non-linear' history to be merged.

I agree. Since it is only about documentation, I would do an interactive rebase where all the commits are combined in one, i.e., all the commits under the first one are set to fix and reword the the only commit left to something like docs: write documentation for pyreisejl.

@ahurli ahurli force-pushed the anna/pyreise-documentation branch 2 times, most recently from 9ae4141 to fab4643 Compare December 15, 2020 00:14
README.md Outdated
@@ -46,6 +64,187 @@ REISE.run_scenario(;
inputfolder=pwd(), num_segments=3)
```

## Usage (Python)

<<<<<<< HEAD
Copy link
Contributor

Choose a reason for hiding this comment

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

Something has gone wrong in this rebase/merge.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, I don't see the changes you previously made in call.py anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I was struggling with the merge conflicts in the README. I'll need to go through this a couple more times/more thoroughly to get it updated.

@ahurli ahurli force-pushed the anna/pyreise-documentation branch from fab4643 to 5d5b66f Compare December 15, 2020 00:18
README.md Outdated
[Gurobi Installation Guide]: https://www.gurobi.com/documentation/quickstart.html
[Julia]: https://julialang.org/
[Download Julia]: https://julialang.org/downloads/
[Zenodo]: https://zenodo.org/record/3905429
Copy link
Contributor

Choose a reason for hiding this comment

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

Please update this link to https://zenodo.org/record/3530898. This is the URL that will always resolve to the latest version of our dataset on Zenodo (which happens to be 3905429 at the moment but will change as we upload new versions).

README.md Outdated
Comment on lines 203 to 205
-f [FREQUENCY], --frequency [FREQUENCY]
The frequency of data points in the original profile
csvs. This is optional and defaults to an hour.
Copy link
Contributor

Choose a reason for hiding this comment

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

What type of input are we expecting here? E.g. if I want to specify a 4-hour frequency, do I need to add -f 4 or -f 4H (a guess here, based on creating scenarios with PowerSimData).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question. It's a Pandas frequency string as defined for pandas.date_range which I'm not entirely clear the extent of, but eventually this input is something I would want to save in a Manifest or something similar (i.e. inspired by @ToddG 's work for CERF) since it's automatically calculated in call.py.

@ahurli ahurli force-pushed the anna/pyreise-documentation branch from 5d5b66f to dfca3c6 Compare December 15, 2020 01:11
Comment on lines 410 to 411
help="The frequency of data points in the original profile csvs as a"
"Pandas frequency string ."
Copy link
Contributor

Choose a reason for hiding this comment

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

Spacing is off here:

  -f [FREQUENCY], --frequency [FREQUENCY]
                        The frequency of data points in the original profile
                        csvs as aPandas frequency string .This is optional and
                        defaults to an hour.

Copy link
Contributor

@danielolsen danielolsen left a comment

Choose a reason for hiding this comment

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

Thanks, this looks good.

@ahurli ahurli force-pushed the anna/pyreise-documentation branch from b0f0593 to 2034a9f Compare December 15, 2020 18:02
@ahurli ahurli merged commit 1db611d into develop Dec 15, 2020
@ahurli ahurli linked an issue Dec 15, 2020 that may be closed by this pull request
@ahurli ahurli deleted the anna/pyreise-documentation branch January 27, 2021 22:09
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.

Improve documentation of pyreisejl
5 participants