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

Switch to pnpm #1071

Merged
merged 5 commits into from
Sep 28, 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
25 changes: 18 additions & 7 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,43 +31,54 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Add conda to system path
run: |
# $CONDA is an environment variable pointing to the root of the miniconda directory
echo $CONDA/bin >> $GITHUB_PATH

- name: Install ldap dependencies
run: sudo apt-get -y install libsasl2-dev libldap2-dev libssl-dev

- name: Install dependencies
run: |
conda install -c conda-forge mamba
mamba env update --file conda-environment.yml --name base
pip install -e .

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8.x

Comment on lines +54 to +58
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've replicated the set-up of other front-end projects, but maybe there's a better way to install it in MXCuBE. 🤷

- name: Cache UI dependencies
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
~/setup-pnpm/node_modules/.bin/store
~/.cache/Cypress
ui/node_modules
key: cache-${{ runner.os }}-${{ hashFiles('ui/package-lock.json') }}
key: cache-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-

- name: Install UI dependencies
run: npm install --prefix ./ui --legacy-peer-deps
run: pnpm --prefix ui install

- name: Build UI
run: npm run --prefix ./ui build
run: pnpm --prefix ui build
env:
DISABLE_ESLINT_PLUGIN: true

- name: Run MXCuBE backend
- name: Start MXCuBE server
run: mxcubeweb-server -r ./test/HardwareObjectsMockup.xml/ --static-folder $(pwd)/ui/build/ -L debug &

- name: Run Cypress
run: npm run --prefix ./ui e2e
run: pnpm --prefix ui e2e

- uses: actions/upload-artifact@v3
if: failure()
Expand Down
48 changes: 38 additions & 10 deletions .github/workflows/format_and_lint_ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,28 @@ jobs:
run: |
conda install -c conda-forge mamba
mamba env update --file conda-environment.yml --name base

- name: Install dependencies
run: |
pip install -e .
npm install --prefix ./ui --legacy-peer-deps

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8.x

- name: Cache UI dependencies
uses: actions/cache@v3
with:
path: |
~/setup-pnpm/node_modules/.bin/store
~/.cache/Cypress
key: cache-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-

- name: Install UI dependencies
run: pnpm --prefix ui install

- name: Check formatting
run: npm run --prefix ./ui prettier
run: pnpm --prefix ui prettier

lint:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -80,11 +94,25 @@ jobs:
run: |
conda install -c conda-forge mamba
mamba env update --file conda-environment.yml --name base

- name: Install dependencies
run: |
pip install -e .
npm install --prefix ./ui --legacy-peer-deps

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8.x

- name: Cache UI dependencies
uses: actions/cache@v3
with:
path: |
~/setup-pnpm/node_modules/.bin/store
~/.cache/Cypress
key: cache-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-

- name: Install UI dependencies
run: pnpm --prefix ui install

- name: Lint
run: npm run --prefix ./ui eslint
run: pnpm --prefix ui eslint
84 changes: 41 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<p align="center"><img src="http://mxcube.github.io/mxcube/img/mxcube_logo20.png" width="125"/></p>

# MXCuBE-Web

MXCuBE-Web is the latest generation of the data acquisition software MXCuBE (Macromolecular Xtallography Customized Beamline Environment). The project started in 2005 at [ESRF](http://www.esrf.eu), and has since then been adopted by other institutes in Europe. In 2010, a collaboration agreement has been signed for the development of MXCuBE with the following partners:

- ESRF
Expand All @@ -26,12 +27,10 @@ MXCuBE-Web is developed as a web application and runs in any recent browser. The

The underlaying beamline control layer is implemented using the library [**mxcubecore**](https://github.com/mxcube/mxcubecore) previously known as [HardwareRepository](https://github.com/mxcube/HardwareRepository). The **mxcubecore** module is compatable with both MXCuBE-Web and the [MXCuBE-Qt application](https://github.com/mxcube/mxcubeqt).


| Data collection | Sample grid |
| :-------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------: |
| ![datacollection-view](https://user-images.githubusercontent.com/4331447/42496925-d983bf3e-8427-11e8-890e-898dda649101.png) | ![samplegrid-view](https://user-images.githubusercontent.com/4331447/42496937-e8547b34-8427-11e8-9447-645e6d7f1dc5.png) |


Latest information about the MXCuBE project can be found on the
[project webpage](http://mxcube.github.io/mxcube/).

Expand Down Expand Up @@ -62,6 +61,7 @@ Gabadinho, J. et al. (2010). MxCuBE: a synchrotron beamline control environment
We recommend using conda to create an isolated environment, conda can be downloaded [here](https://docs.conda.io/en/latest/miniconda.html#linux-installers).

### 1. Create a folder that will contain both `mxcubeweb` and `mxcubecore`

```
mkdir mxcube
cd mxcube
Expand All @@ -75,6 +75,7 @@ git clone https://github.com/mxcube/mxcubecore.git
```

### 3. Create Conda environment `mxcubeweb`

We recommend using conda a convenience and create a seperate environemnt for libraries and python version. This, though, is not compulsory and one can use any other tool or configuration for installing the application and the necessary third party libraries.

Create Conda environment `mxcubeweb` using the conda environment file in mxcubeweb. The installation of the dependencies in the environment takes a few minutes.
Expand All @@ -98,45 +99,45 @@ conda activate mxcubeweb

```
poetry install
npm install --global pnpm@8
```

### 6. Install front-end dependencies and build the UI

```
npm install --legacy-peer-deps
# (NB --legacy-peer-deps is for the moment needed for the testing library Cypress)
npm run build
pnpm --prefix ui install
pnpm --prefix ui build
```

### 7. Running the application (server)
### 7. Starting the MXCuBE server

```
# Start redis-server (if not already running)
# Open a new terminal:
# Activate the conda environement and start the Redis server (if not already running)
conda activate mxcubeweb
redis-server

# In the previous terminal:
# The paths passed below needs to be the full path (thats why there is an extra `$(pwd)` in the command below)
# to the HardwareObjectsMockup.xml and build directories.
mxcubeweb-server -r $(pwd)/mxcubeweb/test/HardwareObjectsMockup.xml/ --static-folder $(pwd)/mxcubeweb/ui/build/ -L debug
# In a separate terminal, start the MXCuBE server (note the use of `$(pwd)` to specify absolute paths):
mxcubeweb-server -r $(pwd)/test/HardwareObjectsMockup.xml/ --static-folder $(pwd)/ui/build/ -L debug
```

_Running the above should give something similar to_
![mxcube-backend](https://github.com/mxcube/mxcubeweb/assets/4331447/33c01fd3-14fe-4437-a2d2-6525e739f9b3)

### 8. Running the MXCuBE-WEB front-end
### 8. Serving the MXCuBE-Web front-end application

All that is needed to run the application is to start the server and point your browser to http://localhost:8081, which will serve the prebuilt client (if any).
All that is needed to run the application is to start the server and point your browser to http://localhost:8081, which will serve the prebuilt client (if any).

_The test username is `idtest0` and the password can be any string (except `wrong` and `ispybDown`, those are used to emulate different behaviors), you can use `test` as a password for example:_
![mxcube-login](https://github.com/mxcube/mxcubeweb/assets/4331447/a29f9c55-a4e1-474e-89cc-854f1c3c24d8)

The client is not built if nothing appears or you get a "404 page not found" error when browsing localhost:8081. Follow the instructions in step 6 "Install front-end dependencies and build the UI" to build a client .

### 9. Installing MXCUBE-WEB for development
### 9. Installing MXCUBE-Web for development

Please read the [contributing guidelines](https://github.com/mxcube/mxcubeweb/blob/develop/CONTRIBUTING.md) before getting started with the development.

The additional tools for development are in the conda-environment-dev.yml file, the environment created above needs to be updated with this.

```
# Make sure the environment created above is activated
conda activate mxcubeweb
Expand All @@ -145,7 +146,7 @@ conda activate mxcubeweb
conda env update --file conda-environment-dev.yml
```

Its recommended to install mxcubeweb and mxcubecore as links to be able to add breakpoints and debug the application easier.
It's recommended to install mxcubeweb and mxcubecore as links to be able to add breakpoints and debug the application more easily.
This can be done with `pip`.

```
Expand All @@ -156,55 +157,52 @@ pip install -e .
pip install -e .
```

The above makes it possible to add break points directly in the "checked out code".
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Repeats what is said before the commands block.


Before running any test, make sure that the local *Redis* server is running. For example with the `mxcubeweb` *conda* environment activated in a terminal, run the `redis-server` command.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved to next section.


#### 9.1 Running tests
#### 9.1 Running the back-end tests

The tests are located in the test folder and are executed with `pytest`
The tests are located in the test folder and are executed with `pytest`.

```
# Run pytest In the root of the mxcubeweb directory
cd mxcubeweb
# Make sure that the conda environment is activated and that the local Redis server is running:
conda activate mxcubeweb
redis-server

# In a separate terminal, activate the environment again and run pytest from the project root of mxcubeweb:
conda activate mxcubeweb
pytest
```

_The output should look something like the following:_
![image](https://github.com/mxcube/mxcubeweb/assets/4331447/379fa92e-566b-47e5-8522-cacfa9f8de2d)

#### 9.2 Running the front-end development server
The front end development server, webpack development server, listens to changes on the filesystem and builds (re-builds) the UI when a change are made. This makes it very easy and fast to see how a change effects the UI and makes debugging alot easier. The developmen server listens on port **3000**
#### 9.2 Starting the front-end development server

```
# The front-end needs the backend to run so before starting the
# development server open a new terminal and run (as in step 7):
The front-end development server listens to changes on the file system and re-builds the UI when changes are made. This makes it very easy and fast to see how changes affect the UI. The development server listens on port **3000**.

```
# Activate the Conda environment and start the MXCuBE server (cf. step 7)
conda activate mxcubeweb
mxcubeweb-server -r $(pwd)/mxcubeweb/test/HardwareObjectsMockup.xml/ --static-folder $(pwd)/mxcubeweb/ui/build/ -L debug
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

At this point, we're already in the mxcubeweb folder (there's a cd mxcubeweb somewhere above).

mxcubeweb-server -r $(pwd)/test/HardwareObjectsMockup.xml/ --static-folder $(pwd)/ui/build/ -L debug

# Enter the `ui` folder and issue:
npm run start
# Enter the `ui` folder and start the front-end developement server:
cd ui
pnpm start

# Note that you can also run any pnpm script from the root folder with:
pnpm --prefix ui <script>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thought it'd be a good place to explain this.

```

The above will automatically open a browser with the URL: http://localhost:3000
Your default browser will open automatically at http://localhost:3000.

#### 9.4 Running the end to end (e2e) tests
#### 9.4 Running the end-to-end tests (E2E)

```
# Keep the backend running, and issue in the mxcubeweb root:
npm run --prefix ./ui e2e

# With the MXCuBE server still running, run:
pnpm e2e
```

_This should give a result looking something like:_
![image](https://github.com/mxcube/mxcubeweb/assets/4331447/e3d0eda7-caa1-44c2-9791-05ef482b81ad)


#### 9.5 Ready to develop
Use your favorite editor to start working with the code. Read the [contributing guidelines](https://github.com/mxcube/mxcubeweb/blob/develop/CONTRIBUTING.md) and check that linting tools are setup correctly. There are settings [files](https://github.com/mxcube/mxcubeweb/tree/develop/.vscode) for visual studio code in the repository.





Use your favorite editor to start working with the code. Read the [contributing guidelines](https://github.com/mxcube/mxcubeweb/blob/develop/CONTRIBUTING.md) and check that linting tools are setup correctly. There are settings [files](https://github.com/mxcube/mxcubeweb/tree/develop/.vscode) for visual studio code in the repository.
10 changes: 5 additions & 5 deletions conda-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ mxcube_download() {
}

init_conda() {
command conda create --name mxcube-web
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

for consistency with the docs

command conda env update --name mxcube-web --file conda-environment.yml
command conda activate mxcube-web
command conda create --name mxcubeweb
command conda env update --name mxcubeweb --file conda-environment.yml
command conda activate mxcubeweb
}


install_node() {
command conda install nodejs
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Isn't nodejs already installed by this point?

command npm install
command npm install --global pnpm@8
command pnpm --prefix ui install
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 think we're still at the root of the project directory at this point so I'm adding --prefix ui (same problem in multiple files below).

}

mxcube_download
Expand Down
3 changes: 2 additions & 1 deletion debian-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ install_node() {
source "$NVM_DIR/nvm.sh"
source "$NVM_DIR/bash_completion"
command nvm install --lts
command npm install
command npm install --global pnpm
command pnpm --prefix ui install
}

mxcube_download
Expand Down
5 changes: 3 additions & 2 deletions docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ vncserver :1 -geometry 1680x1050 -depth 24 &

cd /opt/mxcube3

npm install --legacy-peer-deps
npm start &
npm install --global pnpm@8
pnpm --prefix ui install
pnpm --prefix ui start &

redis-server &

Expand Down
2 changes: 1 addition & 1 deletion docker/mxcube
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ source "$NVM_DIR/bash_completion"

redis-server&
python mxcube3-server -r test/HardwareObjectsMockup.xml --log-file mxcube.log&
npm start&
pnpm --prefix ui start &
25 changes: 7 additions & 18 deletions ui/.gitignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
/node_modules/

# testing
/coverage
/cypress/debug
/coverage/
/cypress/debug/

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
/build/

npm-debug.log*
yarn-debug.log*
yarn-error.log*
# environment
/.env.local
/.env.*.local
3 changes: 3 additions & 0 deletions ui/.npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# Enforce Node and pnpm versions as specified in `package.json`
engine-strict=true

# Save exact dependency versions in `package.json`
save-prefix=""
Loading
Loading