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

Pr240 fixing static directory creation issue #242

Conversation

sahilshekhawat
Copy link
Member

  • There are no merge conflicts.
  • If there is a related issue, a reference to that issue is in the
    commit message.
  • Unit tests have been added for the bug. (Please reference the issue #
    in the unit test.)
  • The tests pass both locally (run nosetests) and on Travis CI.
  • The code follows PEP8 guidelines. (use a linter, e.g.
    pylint, to check your code)
  • The bug fix is documented in the Release
    Notes
    .
  • The code is backwards compatible. (All public methods/classes must
    follow deprecation cycles.)
  • All reviewer comments have been addressed.

@sahilshekhawat
Copy link
Member Author

Please review #241 first so that I can merge it with new server and test it before merging.

@sahilshekhawat
Copy link
Member Author

There is one issue now that we are not keeping previous scene files. When we run all cells again in Ipython notebook, it checks that the code has not been edited and thus, does not rerun it, as a result no new json file is generated while the old one has been deleted. This causes scene.display_ipython() to raise error.

@system.setter
def system(self, new_system):

if new_system is not None and not isinstance(new_system, System):
Copy link
Contributor

Choose a reason for hiding this comment

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

only need to check isinstance

Copy link
Member Author

Choose a reason for hiding this comment

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

Acknowledged.

Copy link
Member

Choose a reason for hiding this comment

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

I had it that way at first and the tests errored. On construction of the instance system maybe be set to None, so this will error for no reason. Passing in None or a valid System are the two valid options.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have changed it back to this as test with system=None were failing.


Notes
=====
The user is allow to supply either system or time, constants,
Copy link
Member

Choose a reason for hiding this comment

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

allow > allowed

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

@sahilshekhawat
Copy link
Member Author

Yes, that fixed the issue with ipython. Now it is working fine. A directory pydy-resources is created in current directory which consists of json files and static data.

@moorepants
Copy link
Member

Do you think this would work for cross platform hidden directories:

http://stackoverflow.com/questions/25432139/python-cross-platform-hidden-file

self.create_static_html()
server = Server(scene_file=self._scene_json_file)
self._generate_json()
server = Server(scene_file=self._scene_json_file, directory=self._static_url)
Copy link
Member

Choose a reason for hiding this comment

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

It isn't clear to me when self._static_url is created.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Found it in __init__, see my note there.

Copy link
Member

Choose a reason for hiding this comment

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

And why is this called a url?

@sahilshekhawat
Copy link
Member Author

Normal visualizations can work for cross-platform hidden directories but again Ipython notebook will not work.

for k, v in default_kwargs.items():
setattr(self, k, v)

self._static_url = os.path.join(os.getcwd(), "pydy-resources")
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure that this is the best place to create the path to this dir. The user coudl theorectically change directory in between the calls to __init__() and display().

I would make a class level attribute called pydy_dir or something. And then in the display() methods you should do this os.path.join.

@@ -462,8 +605,8 @@ def remove_static_html(self, force=False):

def display(self):
"""Displays the scene in the default webbrowser."""
self.create_static_html()
server = Server(scene_file=self._scene_json_file)
self._generate_json()
Copy link
Member

Choose a reason for hiding this comment

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

Don't you have to supply the directory kwarg here, other wise the json files will not be copied into the _static_url directory.

@moorepants
Copy link
Member

Normal visualizations can work for cross-platform hidden directories but again Ipython notebook will not work.

Got it. Thanks.

@oliverlee
Copy link
Contributor

Your patch fails linting requirements. Check the Travis build log for details.

@moorepants
Copy link
Member

Closing in favor of #245.

@moorepants moorepants closed this Jun 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants