question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Consider refactoring example folder creation

See original GitHub issue

As discussed in review comments at https://github.com/pyvista/pyvista/pull/1794, the current strategy of creating example directories in pyvista/__init__.py is suboptimal. The issue is that choosing to raise when the example directories can’t be created for whatever reason is not an option with the current implementation, because this could affect many users who don’t use examples at all.

It seems reasonable from a design standpoint to refactor example directory creation to only happen when the directory would be first used. In that case we could raise when something’s off, and let the user try again in the correct directory or with the correct permissions. The drawback is that the implementation would probably be more complicated, with keeping track of whether the example directory has been initialised, and example calls having to check that each time.

cc. @MatthewFlamm

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
adeakcommented, Nov 12, 2021

Couldn’t we just keep it in the pyvista main namespace, initialise it to None and check for this in pyvista.examples?

1reaction
MatthewFlammcommented, Nov 12, 2021

I think there could be one helper function that is invoked at the beginning of each download function. This wouldn’t be too complex. It could also be a decorator to keep the syntax out of the function. EDIT: it could also go into _check_examples_path and the folders set up at that point. https://github.com/pyvista/pyvista/blob/d91b98ace4bea89412461d8bbe9eafa8192307ea/pyvista/examples/downloads.py#L27-L32

I’m also wondering if it can be done when doing: from pyvista import examples. When importing this, it is much more likely that a file will be downloaded.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Move to Folder refactoring | ReSharper Documentation
This refactoring helps you move one or several types or files to another project or folder anywhere in your solution.
Read more >
project structure - Is it simply Cleaning or Refactoring?
The refactorings Fowler describes are logical cleanups, where, for example, functions with more than one responsibility are reworked and divided ...
Read more >
Automatically refactoring namespaces when moving files ...
When writing JAVA code in an IDE like Eclipse the IDE automatically refactors the package name according to the folder structure.
Read more >
Refactoring some code and maybe working on a project
Going to try and refactor some code live if possible and work on any side projects------------ Patreon ...
Read more >
How to Speed Up Code Refactoring and Software Project ...
Get to know four simple steps to speed up code refactoring and improve ... application logic * Example folders, it's not necessary to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found