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

Use beta tag for Sirepo image #113

Merged
merged 20 commits into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
22 changes: 20 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
name: Documentation
name: Build Documentation

on:
push:
pull_request:
workflow_dispatch:

jobs:
build_docs:
# pull requests are a duplicate of a branch push if within the same repo.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository

name: Build documentation
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -34,7 +38,7 @@ jobs:
uses: supercharge/[email protected]

- name: Start Sirepo Docker container
uses: NSLS-II/start-sirepo-action@v1
uses: NSLS-II/start-sirepo-action@v2
with:
docker-binary: ${{ env.DOCKER_BINARY }}

Expand Down Expand Up @@ -80,3 +84,17 @@ jobs:
with:
name: ${{ env.REPOSITORY_NAME }}-docs
path: docs/build/html/

- name: Deploy documentation to nsls-ii.github.io
if: github.repository_owner == 'NSLS-II' && github.ref_name == 'main'
# We pin to the SHA, not the tag, for security reasons.
# https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
uses: peaceiris/actions-gh-pages@bbdfb200618d235585ad98e965f4aafc39b4c501 # v3.7.3
with:
deploy_key: ${{ secrets.ACTIONS_DOCUMENTATION_DEPLOY_KEY }}
external_repository: NSLS-II/NSLS-II.github.io
publish_branch: master # branch in the external repository
publish_dir: ./docs/build/html
destination_dir: ${{ env.REPOSITORY_NAME }} # just the repo name, without the "NSLS-II/"
keep_files: true # Keep old files.
force_orphan: false # Keep git history.
8 changes: 7 additions & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
name: pre-commit

on: [push, pull_request]
on:
push:
pull_request:
workflow_dispatch:

jobs:
lint:
# pull requests are a duplicate of a branch push if within the same repo.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository

name: Check code style
runs-on: ubuntu-latest
strategy:
Expand Down
97 changes: 0 additions & 97 deletions .github/workflows/publish-docs.yml

This file was deleted.

8 changes: 6 additions & 2 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ name: Tests
on:
push:
pull_request:
workflow_dispatch:
schedule:
- cron: '00 4 * * *' # daily at 4AM

jobs:
run_tests:
# pull requests are a duplicate of a branch push if within the same repo.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository

name: Test sirepo-bluesky with ${{ matrix.docker-binary }} and Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -36,7 +40,7 @@ jobs:
uses: supercharge/[email protected]

- name: Start Sirepo Docker container
uses: NSLS-II/start-sirepo-action@v1
uses: NSLS-II/start-sirepo-action@v2
with:
docker-binary: ${{ env.DOCKER_BINARY }}

Expand All @@ -59,7 +63,7 @@ jobs:
# line 1: GSETTINGS_SCHEMA_DIR_CONDA_BACKUP: unbound variable
set -vxeo pipefail
conda env list
mamba install -c conda-forge shadow3 srwpy
mamba install -c conda-forge shadow3 srwpy "urllib3<2.0" # Temp workaround with pinning urllib version to work with latest 'requests'
pip install --upgrade pip wheel
pip install -v .
pip install -r requirements-dev.txt
Expand Down
42 changes: 30 additions & 12 deletions scripts/start_sirepo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ else
fi

SIREPO_SRDB_HOST="${SIREPO_SRDB_HOST:-}"
SIREPO_SRDB_HOST_RO="${SIREPO_SRDB_HOST_RO:-}"
SIREPO_SRDB_GUEST="${SIREPO_SRDB_GUEST:-}"
SIREPO_SRDB_ROOT="${SIREPO_SRDB_ROOT:-'/sirepo'}"

unset cmd _cmd docker_image SIREPO_DOCKER_CONTAINER_ID

year=$(date +"%Y")
month=$(date +"%m")
day=$(date +"%d")
year=$(date +"%Y")

today="${HOME}/tmp/data/${year}/${month}/${day}"

Expand All @@ -40,32 +41,49 @@ else
mkdir -p "${today}"
fi

# docker_image="radiasoft/sirepo:beta"
docker_image="radiasoft/sirepo:20220806.215448"
docker_image_tag=${DOCKER_IMAGE_TAG:-'beta'} # '20220806.215448' for the older tag
docker_image="radiasoft/sirepo:${docker_image_tag}"
docker_binary=${DOCKER_BINARY:-"docker"}

${docker_binary} pull ${docker_image}

${docker_binary} images

in_docker_cmd="mkdir -v -p ${SIREPO_SRDB_ROOT} && \
if [ ! -f "${SIREPO_SRDB_ROOT}/auth.db" ]; then \
cp -Rv /SIREPO_SRDB_ROOT/* ${SIREPO_SRDB_ROOT}/; \
else \
echo 'The directory exists. Nothing to do'; \
fi && \
sirepo service http"
in_docker_cmd=$(cat <<EOF
mkdir -v -p ${SIREPO_SRDB_ROOT} && \
if [ ! -f "${SIREPO_SRDB_ROOT}/auth.db" ]; then \
cp -Rv /SIREPO_SRDB_ROOT/* ${SIREPO_SRDB_ROOT}/; \
else \
echo 'The directory exists. Nothing to do'; \
fi && \
sed -i -E \"s;export SIREPO_SRDB_ROOT=\"\(.*\)\";export SIREPO_SRDB_ROOT=\"$SIREPO_SRDB_ROOT\";g\" ~/.radia-run/start && \
cat ~/.radia-run/start && \
~/.radia-run/start
EOF
)

if [ -z "${SIREPO_SRDB_HOST_RO}" ]; then
if [ -d "$PWD/sirepo_bluesky/tests/SIREPO_SRDB_ROOT" ]; then
SIREPO_SRDB_HOST_RO="$PWD/sirepo_bluesky/tests/SIREPO_SRDB_ROOT"
else
echo "Cannot determine the location of the host SIREPO_SRDB_ROOT dir."
exit 1
fi
fi

echo "SIREPO_SRDB_HOST_RO=${SIREPO_SRDB_HOST_RO}"

cmd_start="${docker_binary} run ${arg} --init ${remove_container} --name sirepo \
-e SIREPO_AUTH_METHODS=bluesky:guest \
-e SIREPO_AUTH_BLUESKY_SECRET=bluesky \
-e SIREPO_SRDB_ROOT=${SIREPO_SRDB_ROOT} \
-e SIREPO_COOKIE_IS_SECURE=false \
-p 8000:8000 \
-v $PWD/sirepo_bluesky/tests/SIREPO_SRDB_ROOT:/SIREPO_SRDB_ROOT:ro,z "
-v $SIREPO_SRDB_HOST_RO:/SIREPO_SRDB_ROOT:ro,z "

cmd_extra=""
if [ ! -z "${SIREPO_SRDB_HOST}" -a ! -z "${SIREPO_SRDB_GUEST}" ]; then
cmd_extra="-v ${SIREPO_SRDB_HOST}:${SIREPO_SRDB_GUEST} "
cmd_extra="-v ${SIREPO_SRDB_HOST}:${SIREPO_SRDB_GUEST}:rw,z "
fi

cmd_end="${docker_image} bash -l -c \"${in_docker_cmd}\""
Expand Down
2 changes: 1 addition & 1 deletion sirepo_bluesky/sirepo_bluesky.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def auth(self, sim_type, sim_id):
req["authHash"] = "v1:" + base64.urlsafe_b64encode(h.digest()).decode()

self.cookies = None
res = self._post_json("bluesky-auth", req)
res = self._post_json("auth-bluesky-login", req)
if not ("state" in res and res["state"] == "ok"):
raise SirepoBlueskyClientException(f"bluesky_auth failed: {res}")
self.sim_type = sim_type
Expand Down
2 changes: 2 additions & 0 deletions sirepo_bluesky/tests/test_shadow_det.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ def test_shadow_detector_docker_beam_stats_report(RE, db, tmpdir):
"sigmaxz",
"sigmaz",
"x",
"xi_x",
"xi_z",
"xp",
"z",
"zp",
Expand Down
4 changes: 2 additions & 2 deletions sirepo_bluesky/tests/test_sirepo_flyer.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def _test_smoke_sirepo(sim_id, server_name):

@vcr.use_cassette(f"{cassette_location}/test_smoke_sirepo.yml")
def test_smoke_sirepo_vcr():
_test_smoke_sirepo(sim_id="87XJ4oEb", server_name="http://10.10.10.10:8000")
_test_smoke_sirepo(sim_id="00000000", server_name="http://localhost:8000")


@pytest.mark.docker
Expand Down Expand Up @@ -89,7 +89,7 @@ def _test_sirepo_flyer(RE_no_plot, db, tmpdir, sim_id, server_name):

@vcr.use_cassette(f"{cassette_location}/test_sirepo_flyer.yml")
def test_sirepo_flyer_vcr(RE_no_plot, db, tmpdir):
_test_sirepo_flyer(RE_no_plot, db, tmpdir, sim_id="87XJ4oEb", server_name="http://10.10.10.10:8000")
_test_sirepo_flyer(RE_no_plot, db, tmpdir, sim_id="00000000", server_name="http://localhost:8000")


@pytest.mark.docker
Expand Down
8 changes: 4 additions & 4 deletions sirepo_bluesky/tests/test_srw_det.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ def test_srw_detector_vcr(RE, db, tmpdir):
db,
tmpdir,
sim_type="srw",
sim_id="e75qHII6",
server_name="http://10.10.10.10:8000",
sim_id="00000001",
server_name="http://localhost:8000",
)


Expand Down Expand Up @@ -123,8 +123,8 @@ def test_srw_det_grid_scan_vcr(RE, db, tmpdir):
db,
tmpdir,
sim_type="srw",
sim_id="e75qHII6",
server_name="http://10.10.10.10:8000",
sim_id="00000001",
server_name="http://localhost:8000",
)


Expand Down
Loading