-
Notifications
You must be signed in to change notification settings - Fork 33
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
Make full use of UseCase class #102
Conversation
483efd4
to
aeca596
Compare
@mohammadamint @FLomb, I edited the way the input files could be run, do you mind providing a WIP review before I go further into this direction? |
from ramp.core.core import UseCase | ||
|
||
uc = UseCase( | ||
users=User_list, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mohammadamint, @FLomb - here one can add date_start
and or date_end
to run simulations. test need to be written for the various possible case (no date_start
but date_end
and num_days
provided, etc..)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Bachibouzouk i am off grid with very poor internet connection! Sorry 😐
927a2e9
to
af24256
Compare
if self.usecase is None: | ||
# logging warning | ||
print( | ||
"You are generating ramp demand from a User not bounded to a UseCase instance, a default one has been created for you " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can provide a better warning here letting the ramp user know about the UseCase class
@@ -0,0 +1,28 @@ | |||
import os |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test help make sure the notebooks in the documentation are not broken. This is a smoke test, a single error raised upon execution of one cell in a notebook is enough to fail the test. Failed notebook are saved in the root of the repo for further inspection (to be deleted then)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like how the UseCase allows for the easy use of the old inputs. At first, I didn't get why all the operations on these inputs (plotting, etc.) were included in the input files, but now I get that this was the plan agreed in response to issue #83 as well as something allowing people to run via the command line. So that's good.
On the other hand, the fix to issue #83 does not seem to automatically solve also the very much related issue #81. I am now looking into that so that we may solve both at once with this PR.
else: | ||
raise TypeError("Only the .xlsx file format is supported for ramp command line") | ||
raise TypeError( | ||
"Only the .py and .xlsx file format are supported for ramp command line" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a bit confused by why here we say .py and .xlsx file formats are supported for ramp command line, while in the cli.py
file we say that only .xlsx is supported for ramp command line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is because it is a work in progress and I haven't edited things everywhere yet :)
I tested running the .py example files from the command line, and it works smoothly. Nice job! One minor comment: when the CLI prints the start and end times based on the given number of days, it includes decimal figures for the seconds, which are redundant. For example:
Can we get rid of the decimal figures for the seconds? |
So, it looks like the issue can still be easily fixed the way I suggested in issue #81. It's enough to just remove lines 84 and 85 that erroneously add the |
I also tested and I agree, I will remove two two lines :) Right now I am fixing the jupyter notebooks, this is interesting as it raises some questions about RAMP usage like "Should a RAMP user be able to just define an appliance and still generate a profile for this appliance without providing neither a User nor a Usecase", same question for User without Usecase. I think it should be possible and we should make it as intuitive as possible for the RAMP user to use RAMP, providing some default values when the RAMP user did not provide information. The best would be that I prepare a list of those questions for next RAMP dev meeting so we can all voice our opinion on those questions, what do you think @FLomb @mohammadamint ? |
Sounds good to discuss this in the next meeting. On the other hand, it would have been nice to wrap up this PR in such a way as to release v0.5.0 and be able to send the paper/code for review to JOSS before the next meeting. But, of course, if the notebooks need fixing anyway for working with the new UseCase, this is something to address before making a release. |
2f37750
to
1310fe5
Compare
590d6d0
to
27a6dd1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated, fixed (when needed) and refined all the Jupyter notebooks. The problem is that all the files in docs/source/examples/
, which are essentially an .rst
copy-paste of the notebooks, would also need equivalent updating (actually, even more updating because they are not even up to date with the state the notebooks wee before my changes).
I have already raised some time ago the issue that requiring this kind of double work any time we want to update the notebooks is very inefficient and tedious. Can we somehow automate the Jupyter-notebooks translation into .rst pages?
@@ -193,10 +203,10 @@ Building a model with a python script | |||
.. code-block:: python | |||
|
|||
# importing functions | |||
from ramp import User,calc_peak_time_range,yearly_pattern | |||
from ramp import UseCase, User |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A problem I see in the README.rst
file is that we import the UseCase
but never use it. We just run the profiles for one User
, which is not what one typically wants to do. We should show how to add Users
to a UseCase
and how to run via the UseCase
class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, I just translated the existing example but we should also showcase the UseCase
more
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The UseCase
class now has several new functionalities. Is the api_references.rst
document up to date with those? I don't think it is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And I also see that older functionalities are present in the docs, there should certainly be a command to automatize the building of API reference from source code. How did you build it inititally @mohammadamint ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I build them by manually adding the functions in the toctree. As there are some functions that are private, i think we should avoid including all of them, just put the one that the user might interact with
docs/notebooks/simple_bulb.ipynb
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the key example we provide, the one with the basic features. We import the UseCase
class and we show it allows to carry out a whole-year analysis, but we don't use it later on for non-whole-year profiles because we only carry out the exercise for one user type (household
). Should we add a second user type at the end and showcase how the UseCase
is also needed to simulate and aggregate multiple users, regardless of whether we want a whole-year simulation? Otherwise, it seems like UseCase
is only something needed to simulate a whole year.
Rather than implementing all the changes both in rst files and jupyter files, we can download the modified jupyter files as rst to replace the docs examples. But there is a way to automatize this. I will open an issue to work on it. |
@FLomb I could manage this issue with a script. I will create a PR on top of these changes |
2ae8dd2
to
b413b77
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Bachibouzouk I guess you updated these .rst files based on the script developed by @mohammadamint in PR #104, but without adding the script itself, which was yet to be merged?
I just merged PR #104 into development, so it should be ok to merge this into development, too.
Ok, so I see only two remaining open mini-issues with this PIR:
For the first point, I can take care of updating the |
@FLomb We just need to add the names of the functions we want to include in this file: I can take care of this, but I see some new functions also that dont have the docstrings yet. |
@FLomb I tried to automate the API doc inclusion in the doctree. This is making the docs a little bit messy. I still think just adding the names of the functions we want to include in the API docs, should be the cleanest way to do it. @Bachibouzouk What do you think? I am using autoclass to automatically include all the functions documented. |
Yes I agree with this, there is not many methods to document anyways, it is quite quick to do it manually :) |
The reason of the failure must be investigated in a dedicated issue #99
It was rST formating which was wrong
removing yearly_pattern from utils docs
f8965a2
to
db716e1
Compare
db716e1
to
240ce33
Compare
I recreated the plot_class rst file from the .ipynb by explicitely removing the cells with plotly figure because the size of the file was 10MB. I replaced them by the png I created manually. As the Plot_class.rst was already in git history I am not sure I changed much the size of the repo and we can also reverse to use directly the .rst with plotly figures embedded (this is heavy because all the data for the figures are present in the html as well as the plotly js code so that the figures are interactive. |
@FLomb @mohammadamint maybe you can have a look at my latest changes to the documentation and my addendum to the changelog, and also to this comment: #102 (comment) Then we can finally merge, what is not perfect can be corrected into subsequent PRs, I think this one is already big enough now ^^ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All seems to be in good order now, so I'll approve the PR
Fix #83
Fix #81
Closes #35
Closes #58
Started to identify where the code need to be changed and written TODOS
First rewrite how to run ramp, then incorporate @mohammadamint plotting scheme into the usecase, user and appliance classes, then modify cli for .xlsx users, then go through the docs and the jupyter notebook examples to adhere to the new unified way of running ramp