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.
There are 2 installation methods, however the steps below are required for both.
- Clone the repository:
git clone https://github.com/ptycho/ptyweb.git
You now have some options on how to install the PtyWeb backend
- Installing the frontend dependencies:
cd ptyweb/packages/app/frontend
pnpm install
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
To complete these steps, please ensure that you have installed PtyPy and created an environment for it (see PtyPy's installation instructions)
- Activate the PtyPy environment (see PtyPy's installation instructions)
- Install the PtyWeb backend into the PtyPy environment:
cd ptyweb/packages/app/backend
conda env update --name your_ptypy_env --file environment.yml
- You should now be good to go 🎉, try following the Usage instructions below.
- Create new environment and install dependencies:
cd ptyweb/packages/app/backend
conda env create -f environment.yml
conda activate ptyweb
- 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 .
- You should now be good to go 🎉, try following the Usage instructions below.
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
- Start the development server:
cd ptyweb/packages/app/frontend
pnpm run start
- Open the app in your browser at http://localhost:3000.
- Make sure that the correct environment is activated (see Installation)
- Start the development server:
cd ptyweb/packages/app/backend
uvicorn app:app --reload