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

Added a bit of clarification of how important classes attribute is to the tool doc #2231

Merged
merged 3 commits into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/ctapipe_api/tools/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ To create a new command-line Tool, follow the following procedure:

1. make a subclass of `ctapipe.core.Tool`
2. define any user-configurable parameters of the tool
3. register any configurable `ctapipe.core.Component` lasses
that you will use with the Tool via its ``classes`` attribute
3. register *all* configurable `ctapipe.core.Component` classes
that you want to be configured via the Tool via its ``classes`` attribute
4. use the ``aliases`` attribute to promote any parameters from one of
the sub-Components to a high-level a command-line parameter (they
can still be specified using the advanced command-line command
Expand Down
52 changes: 37 additions & 15 deletions docs/examples/Tools.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"from ctapipe.core import Tool, Component, TelescopeComponent\n",
Expand Down Expand Up @@ -59,7 +61,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"class MyComponent(Component):\n",
Expand All @@ -73,6 +77,8 @@
"\n",
"# in order to have 2 of the same components at once\n",
"class SecondaryMyComponent(MyComponent):\n",
" \"\"\"A second component\"\"\"\n",
"\n",
" pass\n",
"\n",
"\n",
Expand Down Expand Up @@ -112,7 +118,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"MyComponent()"
Expand Down Expand Up @@ -178,7 +186,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Now create an executable Tool that contains the Components"
"## Now create an executable Tool that contains the Components\n",
"Note that all the components we wish to be configured via the tool must be added to the `classes` attribute."
]
},
{
Expand Down Expand Up @@ -242,7 +251,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"tool = MyTool()\n",
Expand All @@ -269,7 +280,8 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
"scrolled": true,
"tags": []
},
"outputs": [],
"source": [
Expand All @@ -296,7 +308,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
"tags": []
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -373,7 +385,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true
"tags": []
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -450,7 +462,8 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true
"scrolled": true,
"tags": []
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -535,7 +548,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"tool.setup()\n",
Expand All @@ -545,7 +560,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"tool.comp2"
Expand Down Expand Up @@ -587,13 +604,18 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"print(tool.generate_config_file())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -612,7 +634,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.13"
"version": "3.9.15"
}
},
"nbformat": 4,
Expand Down