Add proper __all__ in all scripts
See original GitHub issueWe 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__ = [
'SupportedDataset',
'TransformationDataset',
'TransformationSubset',
'TransformationConcatDataset',
'TransformationTensorDataset',
'concat_datasets_sequentially',
'as_transformation_dataset',
'train_test_transformation_datasets'
]
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:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I thinked about a possible organization of the whole import thing. As discussed before, the main problem with cascading
__init__.py
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 thatavalanche.benchmarks.datasets.that_dataset
may be a little too specific. Also, we shouln’t add symbols contained inthisdataset_data.py
to the module’s__init__.py
file.avalanche.benchmarks.generators
: it now has a single source filescenario_generators.py
containing all the definitions. We should probably split it to keep source code files simpler to navigate.avalanche.benchmarks.scenarios.new_classes
(without elements fromnc_utils.py
)avalanche.benchmarks.scenarios.new_instances
(without elements fromni_utils.py
)avalanche.benchmarks.scenarios.generic
(without elements fromgeneric_definitions.py
)utils
(but still put all non-private elements in__all__
, so that they can be used)Which means making the following changes:
avalanche.benchmarks.scenarios.generic
module containinggeneric_cl_scenario.py
andgeneric_scenario_creation.py
avalanche.benchmarks.__init__.py
, which now imports*
from “scenarios”, “classic” and “generators” (which is a little bit exaggerated).scenario_generators.py
(see above)TransformationDataset
-related elements to their own new package.__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?
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.