Skip to content

Commit 50ad6bd

Browse files
Merge master
2 parents ab2c171 + ca668e3 commit 50ad6bd

File tree

166 files changed

+4285
-556
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+4285
-556
lines changed

README.md

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,17 @@ In this workshop, we will learn to embed scientific tools into a robust
99
scientific application that can scale from a tiny UI to a large platform. As an
1010
example, attendees will build an image browser application (including
1111
face-detection capabilities), allowing users to search through their pictures,
12-
based on various criteria. We will start from a simple jupyter notebook and
12+
based on various criteria. We will start from a simple python script and
1313
progressively turn it into a complete application using Matplotlib and several
1414
packages from the Enthought Tool Suite such as Traits, TraitsUI and Pyface. In
1515
the process, attendees will learn how to design clean, maintainable and
16-
scalable applications, and package them into an installer.
16+
scalable applications, and discuss sharing your tool with your users.
17+
18+
Ultimately, we will be building fairly sofisticated application that allows
19+
users to explore images on their machines and detect faces in them:
20+
21+
![full app screenshot](pycasa_final.png)
22+
1723

1824
## Set up instructions
1925
First step to set yourself up is to clone this repository
@@ -33,21 +39,38 @@ git clone [email protected]:jonathanrocher/ets_tutorial.git
3339

3440
### EDM users (recommended)
3541
First, download and install EDM from https://www.enthought.com/edm/. Then,
36-
open a `Terminal`/`Powershell`/`Cmd Prompt`/ and navigate to the folder
37-
where the repo was cloned. Enter the following command to create a
38-
dedicated Python environment and install all dependencies in it:
42+
open a `Terminal`/`Powershell`/`Cmd Prompt`/ and create a lighweight bootstrap environment to run the installation commands.
3943
```commandline
40-
python ci build
44+
edm envs create bootstrap
45+
edm install --environment bootstrap click
46+
```
47+
Next, enter the following commands to create a
48+
dedicated Python environment called `ets_tutorial` and install all dependencies in it:
49+
```commandline
50+
edm run -e bootstrap -- python ci build --environment ets_tutorial
51+
```
52+
All application related `python` commands are assumed to run in this
53+
environment. You can activate the environment with:
54+
```commandline
55+
edm shell -e ets_tutorial
4156
```
4257

4358
### Conda users
44-
[TODO]
59+
Create a new conda environment called `ets_tutorial` and install local
60+
dependencies with the following commands:
61+
```commandline
62+
conda create -n ets_tutorial python=3.6 pandas matplotlib traits traitsui scikit-image pillow pyqt ipython importlib_resources importlib_metadata
63+
conda activate ets_tutorial
64+
python setup.py install
65+
```
66+
Activate the new environment with `conda activate ets_tutorial`.
4567

4668
### pip users
4769
Assuming a Python environment is created and activated on your machine, for
4870
example from https://www.python.org/,
4971
```commandline
5072
pip install pandas matplotlib traits traitsui scikits-image pillow pyqt5 ipython
73+
python setup.py install
5174
```
5275

5376
## Getting help
@@ -78,37 +101,37 @@ are able to reach the end goal.
78101
- step 3: GUI: first traitsUI views
79102
- step 4: pyface application: tree navigator and double-click on an image to
80103
display the traitsUI view of the image.
104+
- INTERLUDE: code structure for scalability
81105
- step 5: Fuller pyface application:
82106
- add folder editor to display a table of metadata for all images inside
83107
- add button to launch the face detection on all images
84108
- add widgets to filter images
85-
- INTERLUDE: code structure for scalability
86109
- step 6: pyface application: adding menu and branding
87110
- step 7: pyface application: advanced features [OPTIONAL]
88-
- step 8: 1-click installer
111+
- step 8: Packaging and sharing
89112

90113

91114
## Contributing
92-
### Code structure
93-
[TODO]
94115

95116
### Rules for contributing to the repository
96117
Contributing to this repository requires:
97-
1. to make a Pull Request
98-
2. all code contributed must be pep8 compliant
99-
3. all unit tests must pass
118+
1. to fork the repository, branch off of master, create a branch with changes,
119+
and make a Pull Request
120+
2. All code contributed must be `flake8` compliant.
121+
3. All unit tests must pass.
100122

101123

102-
# Instructor notes: tutorial flow
124+
# Tutorial flow
103125

104-
1. Introduction 20 mins
126+
1. Introduction (20 mins)
105127
- Review development environment setup
106128
- Purpose and goals of the tutorial
107-
- What is ETS? Why pick it to build tools? When to pick it to build tools?
129+
- What is ETS? What type of products is it for?
108130
2. Starting script (10 min)
109131
3. Traits (30 mins)
110-
-
111-
- Simple exercise (10 mins)
132+
- Introduction to Traits: OOP with traits, trait types, and listening to
133+
changes.
134+
- Exercise (10 mins)
112135
4. Basic TraitsUI (35 mins)
113136
- Introduction to TraitsUI views
114137
- The MVC paradigm

docs/ets_tutorial_prabhu.pdf

-1.22 MB
Binary file not shown.

docs/ets_tutorial_slides.pdf

567 KB
Binary file not shown.

ets_tutorial/util/mpl_figure_editor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ def update_editor(self):
3030
def _do_layout(self):
3131
"""Creates sub-widgets and does layout.
3232
"""
33+
if not self.value:
34+
return
3335
canvas = FigureCanvasQTAgg(figure=self.value)
3436
# Allow the figure canvas to expand and shrink with the main widget.
3537
canvas.setSizePolicy(

pycasa_final.png

460 KB
Loading

sample_images/20220121_080128.jpg

2.07 MB
Loading
2.3 MB
Loading

slides/01_intro.md

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
---
2+
jupyter:
3+
jupytext:
4+
text_representation:
5+
extension: .md
6+
format_name: markdown
7+
format_version: '1.3'
8+
jupytext_version: 1.13.7
9+
kernelspec:
10+
display_name: Python 3
11+
language: python
12+
name: python3
13+
---
14+
15+
<!-- #region slideshow={"slide_type": "slide"} -->
16+
## Sharing scientific tools: script to desktop application
17+
18+
**Jonathan Rocher, Siddhant Wahal, Jason Chambless, Corran Webster, Prabhu Ramachandran**
19+
20+
**SciPy 2022**
21+
22+
<!-- #endregion -->
23+
24+
<!-- #region slideshow={"slide_type": "slide"} -->
25+
## Preliminaries
26+
27+
If you haven't already:
28+
- Clone the repository: https://github.com/jonathanrocher/ets_tutorial
29+
- Install packages:
30+
- Using Enthought Deployment Manager (recommended)
31+
(https://www.enthought.com/edm):
32+
33+
```bash
34+
edm envs create bootstrap
35+
edm install --environment bootstrap click
36+
edm run -e bootstrap -- python ci build --environment ets_tutorial
37+
```
38+
- `ets_tutorial` will be our working Python environment. To activate:
39+
```bash
40+
edm shell -e ets_tutorial
41+
```
42+
- Follow instructions in README for conda and pip
43+
<!-- #endregion -->
44+
45+
46+
<!-- #region slideshow={"slide_type": "slide"} -->
47+
## Motivation
48+
49+
- Some tasks are easier with a GUI
50+
- Seeing a lot of information in one shot
51+
- Easier for non-programmers
52+
- Easier to share
53+
54+
<!-- #endregion -->
55+
56+
<!-- #region slideshow={"slide_type": "slide"} -->
57+
## Why ETS? When ETS?
58+
59+
- Open-source
60+
- Mature
61+
- Easy to start, easy to grow
62+
- Tools promotes reusable code and good design patterns
63+
- Largely declarative UI
64+
- Backend-agnostic: avoid having to update when PyQt, wxPython, ... update!
65+
- Limitless around data tools, in particular plotting!
66+
- Reduced development costs (single programming language)
67+
- No architecture mind shift necessary (client-server) and no exposure to
68+
server hacking.
69+
70+
Limitations:
71+
- Limited by back-end when it comes to widgets compared to Javascript
72+
- Desktop application isn't a solution for all needs
73+
74+
<!-- #endregion -->
75+
76+
<!-- #region slideshow={"slide_type": "slide"} -->
77+
## What is ETS?
78+
79+
- Enthought Tool Suite: https://docs.enthought.com/ets
80+
- Open Source
81+
- Packages
82+
- Traits: Python object attributes on steroids
83+
- TraitsUI: Easy GUI-building
84+
- PyFace: Low-level GUI components
85+
- Envisage: plug-in application framework
86+
- Chaco: interactive plotting library
87+
- Mayavi: 3D plotting
88+
- traits_futures: running tasks in parallel/background
89+
- And many others...
90+
91+
<!-- #endregion -->
92+
93+
<!-- #region slideshow={"slide_type": "slide"} -->
94+
## Layered package design
95+
96+
<center>
97+
<img src="images/application_layers.png" height="90%" align="center"/>
98+
</center>
99+
100+
<!-- #endregion -->
101+
102+
103+
<!-- #region slideshow={"slide_type": "slide"} -->
104+
## Sample screenshots
105+
106+
- Can make quite sophisticated UIs
107+
- Much less code
108+
- Easy to write
109+
110+
<!-- #endregion -->
111+
112+
<!-- #region slideshow={"slide_type": "slide"} -->
113+
## A Mayavi-based dialog
114+
115+
<center>
116+
<img src="images/lorenz_ui.png" height="90%" align="center"/>
117+
</center>
118+
119+
<!-- #endregion -->
120+
121+
<!-- #region slideshow={"slide_type": "slide"} -->
122+
## A customized viewer
123+
124+
<center>
125+
<img src="images/pysph_viewer.png" height="90%" align="center"/>
126+
</center>
127+
128+
<!-- #endregion -->
129+
130+
131+
<!-- #region slideshow={"slide_type": "slide"} -->
132+
## Goals
133+
134+
- Start with simple Python script
135+
- Detect faces
136+
- Extract Image metadata
137+
138+
- Build a full-fledged desktop application
139+
- Easy to use UI
140+
- Learn a little MVC
141+
- Design application to scale
142+
143+
- Share the application with others
144+
145+
<!-- #endregion -->
146+
147+
<!-- #region slideshow={"slide_type": "slide"} -->
148+
## Result
149+
150+
Final application we will be building in this tutorial:
151+
152+
<img src="../pycasa_final.png" height="90%" width="90%" align="center"/>
153+
154+
<!-- #endregion -->
155+
156+
<!-- #region slideshow={"slide_type": "slide"} -->
157+
## Schedule
158+
159+
- Step 1: Python script
160+
- Step 2: Using Traits.
161+
- Step 3: Basic GUI using TraitsUI
162+
- Step 4: PyFace application: tree navigator
163+
- Step 5: More features
164+
- Step 6: Menus and branding
165+
- Step 7: [OPTIONAL] Advanced features
166+
- Step 8: [OPTIONAL] Packaging and sharing
167+
168+
169+
<!-- #endregion -->
170+
171+
<!-- #region slideshow={"slide_type": "slide"} -->
172+
## Basic Python script
173+
174+
- Uses: `PIL`, `skimage`, and `matplotlib`
175+
- Detects faces in a given image
176+
- Look inside ...
177+
178+
<!-- #endregion -->
179+
180+
<!-- #region slideshow={"slide_type": "slide"} -->
181+
## Next steps
182+
183+
- Learn more about traits
184+
- Build a clean model for our task with traits
185+
- Learn why models are useful
186+
187+
<!-- #endregion -->

0 commit comments

Comments
 (0)