Skip to content
/ ptyweb Public

Interacting with ptychography recons through a browser

License

Notifications You must be signed in to change notification settings

ptycho/ptyweb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PtyWeb - a web based viewer for ptychography

Overview

PtyWeb is a collection of tools for visualizing ptychography data. It is made up of three parts:

  • @ptyweb/lib - a set of components (most of which are built on top of @h5web/lib) for visualizing ptychography data. This is a standalone package so that it can be used in any React app.
  • @ptyweb/app - a React app that uses the components from @ptyweb/lib to provide a web-based viewer for PtyPy ptychography data.
  • @ptyweb/backend - a Python package coded using FastAPI that provides a REST API for fetching data from PtyPy. This is used by @ptyweb/app to fetch data.

We are using pnpm instead of vanilla npm to manage the dependencies of this project. This is because we encountered this issue when using npm.

Installation

There are 2 installation methods, however the steps below are required for both.

  1. Clone the repository:
git clone https://github.com/ptycho/ptyweb.git

You now have some options on how to install the PtyWeb backend

  1. Installing the frontend dependencies:
cd ptyweb/packages/app/frontend
pnpm install

Installing @ptyweb/lib (for @ptyweb/lib development only)

The following steps are only required if you want to develop the @ptyweb/lib package. You can skip these steps if you only want to use the PtyWeb frontend (@ptyweb/app).

cd ptyweb/packages/lib
pnpm install

Installing PtyWeb backend into the PtyPy environment (recommended)

To complete these steps, please ensure that you have installed PtyPy and created an environment for it (see PtyPy's installation instructions)

  1. Activate the PtyPy environment (see PtyPy's installation instructions)
  2. Install the PtyWeb backend into the PtyPy environment:
cd ptyweb/packages/app/backend
conda env update --name your_ptypy_env --file environment.yml
  1. You should now be good to go 🎉, try following the Usage instructions below.

Installing PtyWeb backend into a separate environment (development)

  1. Create new environment and install dependencies:
cd ptyweb/packages/app/backend
conda env create -f environment.yml
conda activate ptyweb
  1. Install PtyPy and its dependencies into the ptyweb environment (see PtyPy's installation instructions)

When installing PtyPy, make sure to install the conda dependencies into the ptyweb environment, instead of creating a new environment

Example:

cd ptypy
conda activate ptyweb # If not already activated
conda env update --name ptyweb --file your_ptypy_env.yml
pip install .
  1. You should now be good to go 🎉, try following the Usage instructions below.

Building

Building @ptyweb/lib (for @ptyweb/lib development only)

The following steps are only required if you want to develop the @ptyweb/lib package. You can skip these steps if you only want to use the PtyWeb frontend (@ptyweb/app).

Once you are happy with your changes and want to test them in @ptyweb/app, you will need to build the @ptyweb/lib package:

cd ptyweb/packages/lib
pnpm run build
pnpm pack
mv <package_name>.tgz release

Now we have packaged our build, we can install it into @ptyweb/app

cd ptyweb/packages/app/frontend
pnpm uninstall @ptyweb/lib
cp ../../lib/release/<package_name>.tgz lib/
pnpm lib/<package_name>.tgz

Usage

Frontend

  1. Start the development server:
cd ptyweb/packages/app/frontend
pnpm run start
  1. Open the app in your browser at http://localhost:3000.

Backend

  1. Make sure that the correct environment is activated (see Installation)
  2. Start the development server:
cd ptyweb/packages/app/backend
uvicorn app:app --reload