Skip to content

Commit

Permalink
Merge branch 'master' into step0-ZTP
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhaoTianPu committed May 2, 2024
2 parents 6322598 + c3eeb08 commit 48d7c35
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 79 deletions.
108 changes: 64 additions & 44 deletions .github/workflows/publish_to_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all tags and branches
- name: Set up Python
uses: actions/setup-python@v4
with:
Expand All @@ -27,6 +29,7 @@ jobs:
name: python-package-distributions
path: dist/


test-installation:
runs-on: ${{ matrix.os }}
strategy:
Expand All @@ -37,28 +40,44 @@ jobs:
steps:
- uses: actions/checkout@v2
name: Checkout the repository

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

- name: Install Linux System Dependencies
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo apt-get update
sudo apt-get install -y libegl1-mesa # missing libEGL.so.1
sudo apt-get install -y xvfb # GUI backend for matplotlib (Ubuntu doesn't have a display)
- name: Install dependencies and QFit
run: |
pip install --upgrade pip
pip install .
- name: Test installation
- name: Test installation on Linux
if: startsWith(matrix.os, 'ubuntu')
run: |
python -c "from qfit import Fit; print('Installation successful')"
xvfb-run --auto-servernum python -c "from qfit import Fit; print('Installation successful')"
- name: Test installation on macOS and Windows
if: startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'windows')
run: python -c "from qfit import Fit; print('Installation successful')"


publish-to-pypi:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
Publish to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/qfit
url: https://pypi.org/p/qfit
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

Expand All @@ -74,10 +93,10 @@ jobs:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}


github-release:
name: >-
Sign the Python 🐍 distribution 📦 with Sigstore
and upload them to GitHub Release
Sign with Sigstore and upload them to GitHub Release
needs:
- publish-to-pypi
runs-on: ubuntu-latest
Expand Down Expand Up @@ -117,48 +136,49 @@ jobs:
'${{ github.ref_name }}' dist/**
--repo '${{ github.repository }}'
publish-to-testpypi: # always publish to TestPyPI even on non-tag pushes
name: Publish Python 🐍 distribution 📦 to TestPyPI
publish-to-testpypi:
name: Publish to TestPyPI
needs:
- build
- build
runs-on: ubuntu-latest

environment:
name: testpypi
url: https://test.pypi.org/p/qfit

permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

contents: write # Typical permission needed for operations affecting repository contents
steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/

- name: Extract version from distribution 📦 file
# assuming the version is in the format `<qfit>-<version>-<other>.whl`
id: get_version
run: |
FILENAME=$(ls dist/*.whl | head -n 1)
VERSION=$(echo $FILENAME | sed -n 's/^[^0-9]*-\([^-]*\)-.*/\1/p')
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "::set-output name=package_version::$VERSION"
- name: Check if version exists on TestPyPI
run: |
RESPONSE=$(curl -s https://test.pypi.org/pypi/qfit/json)
if echo "$RESPONSE" | grep -q "\"${{ env.VERSION }}\""; then
echo "VERSION_EXISTS=true" >> $GITHUB_ENV
else
echo "VERSION_EXISTS=false" >> $GITHUB_ENV
fi
- name: Publish distribution 📦 to TestPyPI
if: env.VERSION_EXISTS == 'false'
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Extract version from distribution 📦 file
# assuming the version is in the format `<qfit>-<version>-<other>.whl`
id: get_version
run: |
FILENAME=$(ls dist/*.whl | head -n 1)
VERSION=$(echo $FILENAME | sed -n 's/^[^0-9]*-\([^-]*\)-.*/\1/p')
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "::set-output name=package_version::$VERSION"
- name: Check if version exists on TestPyPI
run: |
RESPONSE=$(curl -s https://test.pypi.org/pypi/qfit/json)
if echo "$RESPONSE" | grep -q "\"${{ env.VERSION }}\""; then
echo "VERSION_EXISTS=true" >> $GITHUB_ENV
else
echo "VERSION_EXISTS=false" >> $GITHUB_ENV
fi
- name: Publish distribution 📦 to TestPyPI
if: env.VERSION_EXISTS == 'false'
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
28 changes: 7 additions & 21 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,28 +1,16 @@
/scratch/
/docs/build/
/dist/
/qfit/.idea/
/.idea/inspectionProfiles/Project_Default.xml
/.idea/qfit.iml
/.idea/vcs.xml
/.idea/workspace.xml
/qfit/.ipynb_checkpoints/
*.pyc
**/.idea
**/.ipynb_checkpoints/
/qfit.egg-info/
/qfit/version.py
resources/resources_rc.py
dist
build
qfit.egg-info

# Danyang's unwanted files
.DS_Store
*.pyc
/danyang_tests
resources/resources_rc.py
qfit.egg-info
qfit/controllers/test.ipynb
test.ipynb
qfit/controllers/.jupyter_ystore.db
qfit/controllers/.ipynb_checkpoints/test-checkpoint.ipynb
build
dist/qfit-0.1.0-py3.9.egg
dist/qfit-0.1.0-py3.11.egg

# Tianpu's unwanted files
example_data/test.qfit
Expand All @@ -38,7 +26,6 @@ gif_raw_source/.$calibration_new.drawio.bkp
gif_raw_source/calibration_new.drawio
gif_raw_source/.$calibration_new.drawio.dtmp
qfit_test.zip
.ipynb_checkpoints/QFit_Quick_Start-checkpoint.ipynb
media_raw_source/.$calibration_new.drawio.bkp
media_raw_source/.$calibration_notebook_ver.drawio.bkp
media_raw_source/.$calibration_with_step_notebook_ver.drawio.bkp
Expand All @@ -55,7 +42,6 @@ media_raw_source/calibration.svg
media_raw_source/Backup_of_tag-question.cdr
media_raw_source/Backup_of_tag.cdr
.gitignore
.gitignore
media_raw_source/tag.cdr
media_raw_source/tag-question.cdr
plot_data.ipynb
Expand Down
18 changes: 4 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,14 @@ Installation and Usage

Follow these steps to install `QFit`:

1a. Download source code from GitHub (through `Code` button on the top right), unzip the source code folder in a `<directory>`.

OR

1b. Open a terminal, `cd <directory>` to the directory where you would like to store the source code of `QFit`, then
```
git clone https://github.com/scqubits/qfit
```
2. (Optional but highly Recommended) Create a virtual environment with python (python 3.10 is recommended for satisfying the version requirement for both scqubits and QFit), e.g. run on terminal
1. (Optional but highly Recommended) Create a virtual environment with python (version > 3.10). If you are using conda, run on terminal
```
conda create -n <env name> python=3.10
conda activate <env name>
```
3. On terminal, install `QFit` by
2. On terminal, install `QFit` by
```
cd <directory>/qfit
conda install --file requirements.txt --yes -c conda-forge
pip install .
pip install qfit
```
Once done, the application can be launched in a jupyter notebook session via
```
Expand All @@ -54,7 +44,7 @@ Once done, the application can be launched in a jupyter notebook session via
```
where `<HilbertSpace>` is a `scqubits.HilbertSpace` object, the circuit model you want to fit against.

Check out the notebook [QFit_Quick_Start.ipynb](./QFit_Quick_Start.ipynb) for a quick intro tutorial.
Check out the notebook [QFit_Quick_Start.ipynb](./QFit_Quick_Start.ipynb) for a quick intro tutorial, and [QFit_Advanced_Tips.ipynb](./QFit_Advanced_Tips.ipynb) for further information.

License
-------
Expand Down
Binary file removed Screen Shot 2024-05-01 at 5.01.33 PM.png
Binary file not shown.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pyside6
h5py>=2.7.1
scikit-image
scqubits>=3.0.0
qutip<5.0.0
matplotlib-label-lines
ipykernel
jupyter
Expand Down

0 comments on commit 48d7c35

Please sign in to comment.