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.

Add proper __all__ in all scripts

See original GitHub issue

We should add a proper __all__ definition in all scripts. This will prevent strange import behaviors.

I propose to use the following format:

# Example of the proposed __all__ format
__all__ = [

which means:

  • One definition per line, which will make it easier to analyze diff in commits in which something has been added/removed to/from __all__.
  • The first definition starts in the line after __all__ = [
  • Each definition is “tabbed” by just one level
  • The final ] should be in its on line
  • Order of elements should follow the order in which things are defined in the script (that is, the order obtained by looking at the “Structure” tab of PyCharm).

What do you think?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

lrzpellegrinicommented, Feb 20, 2021

I thinked about a possible organization of the whole import thing. As discussed before, the main problem with cascading is that it every sub-package symbol may get into the root namespace of each major module if we don’t define a proper module structure. Having many symbols in the namespace may be an undesirable source of confusion and will also tamper with IDEs hinting capabilities.

We should focus on keeping self-explanatory import paths based on common usage patterns + the degree of “standalone”-ness of that particular sub-module.

This is my idea for the “import paths” of the benchmark module:

  • avalanche.benchmarks.classic: in this way users may import classic benchmarks the way Jeremy suggested.
  • avalanche.benchmarks.datasets: i think that avalanche.benchmarks.datasets.that_dataset may be a little too specific. Also, we shouln’t add symbols contained in to the module’s file.
  • avalanche.benchmarks.generators: it now has a single source file containing all the definitions. We should probably split it to keep source code files simpler to navigate.
  • avalanche.benchmarks.scenarios.new_classes (without elements from
  • avalanche.benchmarks.scenarios.new_instances (without elements from
  • avalanche.benchmarks.scenarios.generic (without elements from
  • Do not let anything flow upward from utils (but still put all non-private elements in __all__, so that they can be used)

Which means making the following changes:

  • Creating the avalanche.benchmarks.scenarios.generic module containing and
  • Remove the imports from, which now imports * from “scenarios”, “classic” and “generators” (which is a little bit exaggerated).
  • Split (see above)
  • Maybe consider moving TransformationDataset-related elements to their own new package.
  • Remove any private symbol from __all__ (example: the _get_cifar10_dataset method Martin pointed out)!

This applies to the benchmarks module, but I feel we should define a structure also for other major modules, too.

What do you think? Does this make sense to you?

jeremyforestcommented, Feb 18, 2021

I think making it so this from avalanche.benchmarks.classic import SplitCifar10 is the standard would be a good idea. IMO it is the cleanest and easiest way for people not familiar with the code base to know where is what and not spend 10min tracking the dependencies.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Adding arguments and options to your Bash scripts - Red Hat
The getops command reads any and all options specified at the command line and creates a list of those options. The while command...
Read more >
Add Right Click => Find All References option in Script Editor
Ctrl + Shift + F is OK, but is only doing a string find. In this case, it finds lots of other stuff...
Read more >
Adding Your Custom Scripts Using Script Manager
Adding Scripts · Click on Settings in the left menu. · Select Script Manager. · Click the Add a Script button at the...
Read more >
Introduction to Office Scripts in Excel - Microsoft Support
Run an Office Script · All the scripts you and your workbook have access to are found under Automate > All scripts. The...
Read more >
Where should I put <script> tags in HTML markup?
Any script can insert its own HTML via document.write() or other DOM ... After all, the script could have inserted its own HTML...
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 Post

No results found

github_iconTop Related Hashnode Post

No results found