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

57 create cli wbaccinelli #58

Merged
merged 7 commits into from
Jul 5, 2024
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
36 changes: 31 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,35 @@ this software.

## Getting started

##### Install EIT Dashboard

The first time that the dashboard is used, the repository needs to be cloned and the package has to be
installed as follows:

- Create fresh environment
- Make sure you are in your base environment: `conda activate`
- Create a new environment: `conda create -n <envname> python=3.10`
- Activate new environment: `conda activate <envname>`
- Clone and install
- Clone the repository: `git clone [email protected]:EIT-ALIVE/eit_dash.git`
- Install:
- Run `pip install -e .`

### 2. Running EIT Dashboard

To run the installed dashboard the following command can be used:

```console
eit-dash run
wbaccinelli marked this conversation as resolved.
Show resolved Hide resolved
```
Open the resulting link in a browser (often something like `http://127.0.0.1:8050/`).
Note that while the dashboard should work on any browser, if you are experiencing issues we recommend switching to
Chrome or Firefox, as these are the browser where we do most of the testing.
Comment on lines +41 to +43
Copy link
Member

Choose a reason for hiding this comment

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

Add a comment that while it's running in a browser, it is still local and not connected to the internet, and data used never goes online?

I thought we had that somewhere, but not sure where.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is in the user manual. I will add the sentence here as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I just realized that it is already here in the README.md.


Please see our [user manual](docs/user_manual.md) for instructions on how to use the dashboard.

## For developers

### 1. Installation

##### Install Poetry
Expand Down Expand Up @@ -67,13 +96,10 @@ git pull
poetry install
```

Please see our [user manual](docs/user_manual.md) for instructions on how to use the dashboard.

##### Run dashboard

Run the command below and and open the resulting link in a browser (often something like `http://127.0.0.1:8050/`).
Note that while the dashboard should work on any browser, if you are experiencing issues we recommend switching to
Chrome or Firefox, as these are the browser where we do most of the testing.
Run the command below to run the dashboard with the latest change made in the code,
and follow the link displayed.

```console
poetry run python eit_dash/main.py
Expand Down
Empty file added cli/__init__.py
Empty file.
21 changes: 21 additions & 0 deletions cli/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import click

from eit_dash.main import app


@click.group(invoke_without_command=True)
@click.pass_context
def cli(ctx):
"""Default prompt. It shows the help command."""
if ctx.invoked_subcommand is None:
click.echo(ctx.get_help())


@cli.command(name="run", help="Start the dashboard.")
def run():
"""Start the dashboard."""
app.run_server(debug=True)


if __name__ == "__main__":
cli()
45 changes: 17 additions & 28 deletions eit_dash/callbacks/preprocessing_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,7 @@ def open_synch_modal(open_click, confirm_click) -> bool:
"""open/close modal dialog for data synchronization."""
trigger = ctx.triggered_id

if trigger == ids.OPEN_SYNCH_BUTTON:
return True

return False
return trigger == ids.OPEN_SYNCH_BUTTON


@callback(
Expand All @@ -203,10 +200,7 @@ def open_periods_modal(open_click, confirm_click) -> bool:
"""open/close modal dialog for periods selection."""
trigger = ctx.triggered_id

if trigger == ids.OPEN_SELECT_PERIODS_BUTTON:
return True

return False
return trigger == ids.OPEN_SELECT_PERIODS_BUTTON


@callback(
Expand Down Expand Up @@ -247,10 +241,7 @@ def populate_periods_selection_modal(method):
)
def show_selection_div(signals):
"""Make visible the div containing the graphs and the buttons."""
if signals:
return False

return True
return not signals


@callback(
Expand Down Expand Up @@ -471,9 +462,7 @@ def remove_period(n_clicks, container, figure):
)
def enable_filter_button(results):
"""Enable the button for opening the filter modal."""
if results:
return False
return True
return not results


@callback(
Expand Down Expand Up @@ -558,20 +547,20 @@ def enable_apply_button(
if not filter_selected:
return True

if (
(int(filter_selected) == FilterTypes.lowpass.value and co_high and co_high > 0)
or (int(filter_selected) == FilterTypes.highpass.value and co_low and co_low > 0)
or (
int(filter_selected) in [FilterTypes.bandpass.value, FilterTypes.bandstop.value]
and co_low
and co_low > 0
and co_high
and co_high > 0
return (
not (
(int(filter_selected) == FilterTypes.lowpass.value and co_high and co_high > 0)
or (int(filter_selected) == FilterTypes.highpass.value and co_low and co_low > 0)
or (
int(filter_selected) in [FilterTypes.bandpass.value, FilterTypes.bandstop.value]
and co_low
and co_low > 0
and co_high
and co_high > 0
)
)
) and order:
return False

return True
and order
)


@callback(
Expand Down
6 changes: 2 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ classifiers = [
"Programming Language :: Python :: 3.10",
]
keywords = ["EIT - Electrical Impedance Tomography", "GUI"]
packages = [{ include = "eit_dash" }]
packages = [
{ include = "eit_dash"},
{ include = "cli"},
]

[tool.poetry.scripts]
eit-dash = "cli.cli:cli"

[tool.poetry.urls]
repository = "[email protected]:EIT-ALIVE/eit_dash"
Expand All @@ -28,6 +34,7 @@ eitprocessing = "^1.0.2"
numpy = "^1.25.2"
pandas = "^2.0.3"
ruff = "^0.4.9"
click = "^8.1.7"

[tool.poetry.group.test.dependencies]
pytest = "^7.4.0"
Expand Down
Loading