-
Notifications
You must be signed in to change notification settings - Fork 20
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
Add Travis CI #5
base: master
Are you sure you want to change the base?
Conversation
2bbe6d5
to
2fe37d9
Compare
Contains #4, depends on that PR to be merged first. The commit there is included here so that Travis test can run. |
@rht Thanks for the PR. Couple of comments about the Travis script. Why only testing against Python 3.5 and Linux OS? Seems quite specific. Default Anaconda Python distributions are Python 3.6 and Python 2.7 (although I would not recommend supporting Python 2.7...but this is up to @x0range and @DavoudTaghawiNejad). I would also recommend testing for Linux and Mac OSX. I am configuring all ESL repos to run static analysis and testing using Codacy so no need to worry about flake8 and coveralls. Finally, can you explain the purpose of the test? In particular, why is it necessary to introduce the |
Noted. In this case, it was because the requirements.txt install process is I see, I didn't know that Codacy automatically does coverage and lint
The intent of the test is to make sure the main simulation and the model code, |
2f115df
to
9f565da
Compare
@davidrpugh I added 3.6 and macOS. |
@rht An alternative to using pip would be to add a I now understand the purpose of the |
Hmmm, years ago, I found |
start.py
Outdated
@@ -55,7 +56,17 @@ def main(simulation_parameters): | |||
allagents.do('filobl') | |||
insurancecustomers.do('check_risk') | |||
|
|||
simulation.graphs() | |||
if not isTravis: | |||
simulation.graphs() |
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.
Here is the line where the graphs are automatically produced and the web server launched. I'd recommend to having the data analysis residing in a Jupyter notebook actually. This offloads the graph-visualization-in-a-web-server development effort to another library.
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.
(e.g. https://github.com/EconomicSL/auctions-simulation-example/blob/master/periodic-double-auction-analytics.ipynb) Also, Jupyter notebooks, if versioned, can be cited from its hash while web server graphs can't. The @gui
will have its purpose for interactive exploration.
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.
Actually, the interact/manipulate GUI parameters can be further offloaded to Jupyter (ref: https://ipywidgets.readthedocs.io/en/latest/examples/Using%20Interact.html). So as to approach http://distill.pub/2017/momentum/.
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.
Maybe I am misunderstanding something. To me, it seems, this will fail with an error when not run by travis. Boolean isTravis is undeclared in that case. Maybe put this in a try/except clause. But this also seems to not be the proper way to do it.
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.
@x0range, Boolean isTravis
is wired from the parser.add_argument
with a default to be False
. I think in these cases, a default argument is cleaner to use than try-except. C struct and Protobuf have default values, for instance. Python dictionary has .get
method with default value.
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.
@rht I agree with @x0range this is not the proper way to handle this issue. It should be possible to run a simulation without a GUI using ABCE. If it is not possible, then this is an issue for @DavoudTaghawiNejad to fix upstream in ABCE. Until then we can focus on testing logic that does not require ABCE.
Come to think of it, @DavoudTaghawiNejad mentioned that he has tests running on Travis, how is he solving this problem?
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.
@davidrpugh It is possible to switch off the GUI. I am doing that in the branches I am developing in https://github.com/x0range/isle using a command line switch taken in with sys.argv
. But in my opinion it makes sense to have the GUI switched on by default, especially if we plan to at some point deploy this somewhere and make it available to non-programmers.
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.
@rht I still do not understand. If you run this from the terminal, it results in NameError: name 'isTravis' is not defined
. This would be expected, since isTravis is not declared. The only two solutions I can see are to put it in a try-except clause or to switch the GUI off by default (as suggested by @davidrpugh)
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.
@x0range Good to know about the command line switch. This should solve the problem for CI purposes as we should be able to pass the same parameter as part of the command line script on Travis. In general boolean arguments should default to False. This used to be part of the Google Python style guide but I can not find the link at present. Will try to find a reference for this.
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.
!!! Sorry, I was late to see the discussion. The test suites in ABCE are currently unittests[1] and have yet to cover for the GUI area of the code. The boolean in argparse
should have False
as a default as can be seen in:
parser.add_argument('--travis', dest='travis', action='store_true',
default=False,
help='Flag to disable gui when run in a Travis environment')
@x0range I wired it at main(simulation_parameters, args.travis)
; I tested on my machine (uname -o
: GNU/Linux
, Python 3.6.1
, this PR) and it launched the GUI. Unless there is an anomaly in the system you are running, it should have run. Yes, the main
function has isTravis
as a required argument.
For Protobuf, the default value for bools is false[2]. And yes, in general as well -- a switch is off/0 by default for safety purpose in EE, isn't it?
[1] https://github.com/AB-CE/abce/blob/c93db46ab313f54d6d626725952beac34504fa67/.travis.yml#L47
[2] https://developers.google.com/protocol-buffers/docs/proto
@rht For as long as I have been aware of I completely agree that data visualization and analytics should not be part of any core ABM simulation library; decisions about data analytics and visualization should be left up to the user or developed separately from the main simulation library. However these are questions/recommendations for @DavoudTaghawiNejad since ABCE is his project. Might consider opening issues on that repo? |
Note: I rebased and updated the travis.yml with the most recent version of Xcode on |
I think the switch for this repo has been disabled. |
No description provided.