Skip to content

Commit

Permalink
Merge branch 'master' into parse_data_d_array_bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherMayes committed Jun 25, 2024
2 parents c5b4efe + 5e9f02f commit 592ee4c
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 62 deletions.
70 changes: 32 additions & 38 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,64 +4,58 @@ on:
push:
pull_request:
schedule:
- cron: '0 0 * * *' # every day at midnight
- cron: "0 0 * * *" # every day at midnight

jobs:
build:
name: ${{ matrix.os }} Python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
run:
shell: bash
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: [3.7]
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v2

- name: Install System Dependencies
run: |
sudo apt-get install build-essential curl wget cmake gfortran automake \
autoconf libtool m4 libgomp1 libreadline-dev libncurses-dev pkg-config \
libcairo2-dev libpango1.0-dev libxt-dev libx11-dev -y
- name: Check Latest Bmad Release
run: |
echo "Latest release is: $(curl https://www.classe.cornell.edu/~cesrulib/downloads/latest_distribution_file_prefix)"
# Set Environment variable for further steps
echo "BMADDIST=$(curl https://www.classe.cornell.edu/~cesrulib/downloads/latest_distribution_file_prefix)" >> $GITHUB_ENV
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
- uses: actions/checkout@v4
with:
python-version: ${{ matrix.python-version }}
fetch-depth: 1

- uses: actions/cache@v2
id: cache
- uses: actions/checkout@v4
with:
path: ~/bmad
key: ${{ runner.os }}-${{ env.BMADDIST }}
repository: bmad-sim/bmad-ecosystem
fetch-depth: 1
path: bmad

- name: Install Bmad - ${{ env.BMADDIST }}
if: steps.cache.outputs.cache-hit != 'true'
run: .github/scripts/install_bmad.sh
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}
mamba-version: "*"
channels: conda-forge
activate-environment: pytao-dev
environment-file: dev-environment.yml

- name: Setup Bmad
run: |
echo "ACC_ROOT_DIR=/home/runner/bmad/bmad_dist" >> $GITHUB_ENV
echo "ACC_EXE=/home/runner/bmad/bmad_dist/production/bin" >> $GITHUB_ENV
echo "TAO_DIR=/home/runner/bmad/bmad_dist/tao" >> $GITHUB_ENV
echo "/home/runner/bmad/bmad_dist/production/bin/" >> $GITHUB_PATH
PYTAO_ROOT=/home/runner/work/pytao/pytao
echo "ACC_ROOT_DIR=$PYTAO_ROOT/bmad" >> $GITHUB_ENV
- name: Install Python Dependencies
- name: Show conda environment packages
shell: bash -l {0}
run: |
pip install -r requirements.txt
pip install -r test-requirements.txt
conda list
- name: Install PyTao
- name: Ensure importability
shell: bash -l {0}
run: |
pip install .
cd /
python -c "import pytao"
- name: Run Tests
shell: bash -l {0}
run: |
python run_tests.py
echo -e '## Test results\n\n```' >> "$GITHUB_STEP_SUMMARY"
pytest -v --cov=pytao/ pytao/tests 2>&1 | tee -a "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
21 changes: 14 additions & 7 deletions dev-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,27 @@ name: pytao-dev
channels:
- conda-forge
dependencies:
- python==3.12
# Developer
- python >=3.9
- openPMD-beamphysics
- numpydoc
- bmad
- bokeh
- pytest
- pytest-cov
- jupyterlab>3
- ipywidgets
- matplotlib
- numpy
- h5py
- pexpect
# Developer
- pygments
- mkdocs==1.5.2
- pytest
- pytest-cov
- mkdocs
- mkdocstrings
- mkdocs-material
- mkdocs-jupyter==0.24.6
- mkdocs-jupyter
- mkdocstrings-python

- pip
- pip:
# Install pytao from here.
- .
16 changes: 9 additions & 7 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# conda env create -f environment.yml
name: pytao-dev
name: pytao
channels:
- conda-forge
dependencies:
- python >= 3.9
- python >=3.9
- ipykernel
- ipywidgets
- jupyterlab
- bmad
- openPMD-beamphysics
# PyTao release:
- pytao
# or PytTao Developer:
# - pip:
# - git+git://github.com/bmad-sim/pytao
- numpy
- h5py
- pexpect
- pip
- pip:
# Install pytao from here.
- .
20 changes: 13 additions & 7 deletions pytao/interface_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# AUTOGENERATED FILE - DO NOT MODIFY
# This file was generated by the script `generate_interface_commands.py`.
# Any modifications may be overwritten.
# Generated on: 2024-06-04 10:44:04
# Generated on: 2024-06-24 14:25:18
# ==============================================================================

from pytao.tao_ctypes.util import parse_tao_python_data
Expand Down Expand Up @@ -62,14 +62,15 @@ def __execute(tao, cmd, as_dict=True, raises=True, method_name=None, cmd_type="s
return ret


def beam(tao, *, ix_uni='', verbose=False, as_dict=True, raises=True):
def beam(tao, ix_branch, *, ix_uni='', verbose=False, as_dict=True, raises=True):
"""
Output beam parameters that are not in the beam_init structure.
Parameters
----------
ix_uni : optional
ix_branch : ""
Returns
-------
Expand All @@ -78,10 +79,11 @@ def beam(tao, *, ix_uni='', verbose=False, as_dict=True, raises=True):
Notes
-----
Command syntax:
python beam {ix_uni}
python beam {ix_uni}@{ix_branch}
Where:
{ix_uni} is a universe index. Defaults to s%global%default_universe.
{ix_branch} is a lattice branch index. Defaults to s%global%default_branch.
Note: To set beam_init parameters use the "set beam" command.
Expand All @@ -91,21 +93,23 @@ def beam(tao, *, ix_uni='', verbose=False, as_dict=True, raises=True):
init: -init $ACC_ROOT_DIR/regression_tests/python_test/csr_beam_tracking/tao.init
args:
ix_uni: 1
ix_branch: 0
"""
cmd = f'python beam {ix_uni}'
cmd = f'python beam {ix_uni}@{ix_branch}'
if verbose: print(cmd)
return __execute(tao, cmd, as_dict, raises, method_name='beam', cmd_type='string_list')


def beam_init(tao, *, ix_uni='', verbose=False, as_dict=True, raises=True):
def beam_init(tao, ix_branch, *, ix_uni='', verbose=False, as_dict=True, raises=True):
"""
Output beam_init parameters.
Parameters
----------
ix_uni : optional
ix_branch : ""
Returns
-------
Expand All @@ -114,10 +118,11 @@ def beam_init(tao, *, ix_uni='', verbose=False, as_dict=True, raises=True):
Notes
-----
Command syntax:
python beam_init {ix_uni}
python beam_init {ix_uni}@{ix_branch}
Where:
{ix_uni} is a universe index. Defaults to s%global%default_universe.
{ix_branch} is a lattice branch index. Defaults to s%global%default_branch.
Note: To set beam_init parameters use the "set beam_init" command
Expand All @@ -127,9 +132,10 @@ def beam_init(tao, *, ix_uni='', verbose=False, as_dict=True, raises=True):
init: -init $ACC_ROOT_DIR/regression_tests/python_test/csr_beam_tracking/tao.init
args:
ix_uni: 1
ix_branch: 0
"""
cmd = f'python beam_init {ix_uni}'
cmd = f'python beam_init {ix_uni}@{ix_branch}'
if verbose: print(cmd)
return __execute(tao, cmd, as_dict, raises, method_name='beam_init', cmd_type='string_list')

Expand Down
6 changes: 3 additions & 3 deletions pytao/tests/test_interface_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# AUTOGENERATED FILE - DO NOT MODIFY
# This file was generated by the script `generate_interface_commands.py`.
# Any modifications may be overwritten.
# Generated on: 2024-06-04 10:44:04
# Generated on: 2024-06-24 14:25:18
# ==============================================================================

import os
Expand All @@ -13,13 +13,13 @@
def test_beam_1():

tao = Tao(os.path.expandvars('-init $ACC_ROOT_DIR/regression_tests/python_test/csr_beam_tracking/tao.init -noplot'))
ret = interface_commands.beam(tao, ix_uni='1')
ret = interface_commands.beam(tao, ix_uni='1', ix_branch='0')


def test_beam_init_1():

tao = Tao(os.path.expandvars('-init $ACC_ROOT_DIR/regression_tests/python_test/csr_beam_tracking/tao.init -noplot'))
ret = interface_commands.beam_init(tao, ix_uni='1')
ret = interface_commands.beam_init(tao, ix_uni='1', ix_branch='0')


def test_bmad_com_1():
Expand Down

0 comments on commit 592ee4c

Please sign in to comment.