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

Temporary fix of User Interaction data passing #120

Merged
merged 3 commits into from
Dec 8, 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
2 changes: 1 addition & 1 deletion docs/source/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Clone repository

To get started with development, clone the VAI-lab repository and change directory
```bash,
```bash
git clone https://github.com/AaltoPML/VAI-lab.git && cd VAI-lab
```

Expand Down
1 change: 0 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Contents
Installation <installation>
User Guide <user_guide>
Development <development>
Documentation <documentation>
Contributing <contributing>


4 changes: 2 additions & 2 deletions docs/source/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Requirements

- Python 3.10+
- Python 3.11+

## Install from PyPi

Expand All @@ -18,7 +18,7 @@ conda env create --name vai-lab python=3.10 pip && conda activate vai-lab && pyt
## Install from source

Clone this repository and change directory
```bash,
```bash
git clone https://github.com/AaltoPML/VAI-lab.git && cd VAI-lab
```
Install into a [virtual environment](https://docs.python.org/3/library/venv.html)
Expand Down
4 changes: 2 additions & 2 deletions docs/source/user_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Pre-made `examples <https://github.com/AaltoPML/VAI-lab/tree/main/src/vai_lab/ex
Some basic use-cases are provided among many others:
- `user_feedback_demo.xml <https://github.com/AaltoPML/VAI-lab/tree/main/src/vai_lab/examples/xml_files/user_feedback_demo.xml>`_ Demonstrates manual image classification of chest X-rays
- `canvas_demo.xml <https://github.com/AaltoPML/VAI-lab/tree/main/src/vai_lab/examples/xml_files/canvas_demo.xml>`_ Launches the canvas state-action pair visualiser and editor
- `regression_demo.xml <https://github.com/AaltoPML/VAI-lab/tree/main/src/vai_lab/examples/xml_files/regression_demo.xml>`_ Demonstrates simple linear regression on a small set of sample data
- `regression_demo.xml <https://github.com/AaltoPML/VAI-lab/tree/main/src/vai_lab/examples/xml_files/ridge_regression_demo.xml>`_ Demonstrates simple linear regression on a small set of sample data

Launching examples:
^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -197,7 +197,7 @@ Loops

Loop tags are used to iterate over a given set of modules until a condition is met. Loops can be nested and named.

See `basic_operation.xml <https://github.com/AaltoPML/VAI-lab/tree/main/src/vai_lab/examples/xml_files/basic_operation.xml>`_ for full example.
See `loop_demo.xml <https://github.com/AaltoPML/VAI-lab/tree/main/src/vai_lab/examples/xml_files/loop_demo.xml>`_ for full example.
Current options:

- ``type``: what variety of loop will this be: ``for``, ``while``, ``manual`` (user defined stopping condition on-the-fly)
Expand Down
7 changes: 5 additions & 2 deletions src/vai_lab/Core/vai_lab_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def _execute_module(self, specs):
self._load_data(specs, specs["name"])
mod.set_options(specs)
if specs["name"] == 'User Interaction':
mod._load_plugin(specs["plugin"]["plugin_name"])
mod.set_data_in(self.data[specs["name"]])
else:
mod._load_plugin(self.data[specs["name"]])
Expand All @@ -79,7 +78,11 @@ def _execute_module(self, specs):
+ "processing..."
)
mod.launch()
self.data[specs["name"]] = mod.get_result()

if type(mod.get_result()) is Data:
self.data[specs["name"]] = mod.get_result()
else:
self.data[specs["name"]].import_existing_data(specs["name"], self.data)

def _execute_loop(self, specs):
if hasattr(self,"_execute_{}_loop".format(specs["type"])):
Expand Down
3 changes: 2 additions & 1 deletion src/vai_lab/GUI/GUI_core.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from vai_lab.Data.xml_handler import XML_handler
from vai_lab._import_helper import import_plugin_absolute
from vai_lab._types import DataInterface, PluginSpecsInterface, DictT
from vai_lab.Data.Data_core import Data

from typing import Any
import tkinter as tk
Expand Down Expand Up @@ -165,4 +166,4 @@ def get_result(self):
This is due to the way this module is constructed, it cycles through plugins,
which is useful for the startpage, but complicates things when running
UserInterface plugins"""
return self.output_data
return self.output_data[-1] #self.output_data[-1][0]
58 changes: 58 additions & 0 deletions src/vai_lab/examples/xml_files/loop_demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<pipeline>
<Initialiser name="Initialiser">
<relationships>
<child name="User Interaction" />
</relationships>
<coordinates>
[(350.0, 50), 0, {}]
</coordinates>
<inputdata>
<X file="./examples/state-action/X_data.csv" />
</inputdata>
</Initialiser>
<loop type="For" condition="2" name="loop0">
<relationships>
<child name="User Interaction" />
</relationships>
<coordinates>
(129.0, 193.0, 547.0, 514.0)
</coordinates>
<UserInteraction name="User Interaction">
<inputdata>
<X module="Initialiser" />
</inputdata>
<relationships>
<parent name="Initialiser" />
<parent name="loop0" />
<child name="Output" />
</relationships>
<coordinates>
[(350.0, 350.0), 2, {0: 'd0-u2'}]
</coordinates>
<plugin type="CanvasInput">
<options />
</plugin>
</UserInteraction>
</loop>
<Output name="Output">
<inputdata>
<X module="User Interaction" />
</inputdata>
<relationships>
<parent name="User Interaction" />
</relationships>
<coordinates>
[(350.0, 650), 1, {2: 'd2-u1'}]
</coordinates>
<plugin type="Output">
<options>
<outdata>
User Interaction
</outdata>
<outpath>
.\examples\results\output.pkl
</outpath>
</options>
</plugin>
</Output>
</pipeline>
76 changes: 76 additions & 0 deletions src/vai_lab/examples/xml_files/ridge_regression_demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<pipeline>
<Initialiser name="Initialiser">
<relationships>
<child name="Modelling" />
</relationships>
<coordinates>
[(350.0, 50), 0, {}]
</coordinates>
<inputdata>
<X file="./examples/supervised_regression/X_tr.csv" />
<Y file="./examples/supervised_regression/Y_tr.csv" />
<X_test file="./examples/supervised_regression/X_tst.csv" />
<Y_test file="./examples/supervised_regression/Y_tst.csv" />
</inputdata>
</Initialiser>
<Modelling name="Modelling">
<inputdata>
<X module="Initialiser" />
</inputdata>
<relationships>
<parent name="Initialiser" />
<child name="Output" />
</relationships>
<coordinates>
[(350.0, 350.0), 2, {0: 'd0-u2'}]
</coordinates>
<plugin type="RidgeRegression">
<options>
<alpha>
0.02
</alpha>
</options>
<method type="fit">
<options>
<X>
X
</X>
<y>
Y
</y>
</options>
</method>
<method type="score">
<options>
<X>
X_test
</X>
<y>
Y_test
</y>
</options>
</method>
</plugin>
</Modelling>
<Output name="Output">
<inputdata>
<X module="Modelling" />
</inputdata>
<relationships>
<parent name="Modelling" />
</relationships>
<coordinates>
[(350.0, 650), 1, {2: 'd2-u1'}]
</coordinates>
<plugin type="Output">
<options>
<outdata>
Modelling
</outdata>
<outpath>
.\examples\results\output.pkl
</outpath>
</options>
</plugin>
</Output>
</pipeline>
Loading