File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,14 +19,16 @@ jobs:
1919
2020 steps :
2121 - uses : actions/checkout@v4
22- - name : Set up Python 3.10
22+ - name : Set up Python 3.12
2323 uses : actions/setup-python@v3
2424 with :
25- python-version : " >=3.10 "
25+ python-version : " >=3.12 "
2626 - name : Install dependencies
2727 run : |
2828 python -m pip install --upgrade pip
2929 pip install numpy
30+ pip install scipy
31+ pip install pydantic
3032 pip install flake8 pytest
3133 if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
3234 - name : Lint with flake8
Original file line number Diff line number Diff line change 2626
2727
2828TOPLEVEL_DIR = pathlib .Path (__file__ ).parent .parent .absolute ()
29- ABOUT_FILE = TOPLEVEL_DIR / "pyAML " / "__init__.py"
29+ ABOUT_FILE = TOPLEVEL_DIR / "pyaml " / "__init__.py"
3030
3131if str (TOPLEVEL_DIR ) not in sys .path :
3232 sys .path .insert (0 , str (TOPLEVEL_DIR ))
Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ def set_root_folder(path: str | Path):
1111 """
1212 Set the root path for configuration files.
1313 """
14- #ROOT["path"] = Path(path).resolve()
1514 ROOT ["path" ] = Path (path )
1615
1716
@@ -21,13 +20,5 @@ def get_root_folder() -> Path:
2120 """
2221 return ROOT ["path" ]
2322
24-
25- def get_config_file_path (path : str | Path ) -> Path :
26- """Ensure the path is absolute and resolved."""
27- path = Path (path )
28- if not path .is_absolute ():
29- path = get_root_folder () / path
30- return path .resolve ()
31-
3223from .fileloader import load
3324from .factory import depthFirstBuild
Original file line number Diff line number Diff line change 55from pydantic import BaseModel ,ConfigDict
66from .instrument import Instrument
77from .configuration .factory import depthFirstBuild
8- from pyaml .configuration import load
8+ from pyaml .configuration import load ,set_root_folder
9+ import os
910
1011# Define the main class name for this module
1112PYAMLCLASS = "PyAML"
@@ -35,6 +36,10 @@ def pyaml(fileName:str) -> PyAML:
3536 """Load an accelerator middle layer"""
3637
3738 # Asume that all files are referenced from folder where main AML file is stored
38- aml_cfg = load (fileName )
39+ if not os .path .exists (fileName ):
40+ raise Exception (f"{ fileName } file nnot found" )
41+ rootfolder = os .path .abspath (os .path .dirname (fileName ))
42+ set_root_folder (rootfolder )
43+ aml_cfg = load (os .path .basename (fileName ))
3944 aml :PyAML = depthFirstBuild (aml_cfg )
4045 return aml
Original file line number Diff line number Diff line change 11from pyaml .pyaml import pyaml ,PyAML
22from pyaml .instrument import Instrument
3- from pyaml .configuration import set_root_folder
43import pyaml as pyaml_pkg
54from pyaml .lattice .element_holder import MagnetType
65from pyaml .magnet .model import MagnetModel
76import at
87
98#def test_aml(config_root_dir):
10- set_root_folder ("tests/config" )
119
12- ml :PyAML = pyaml ("sr.yaml" )
10+ ml :PyAML = pyaml ("tests/config/ sr.yaml" )
1311sr :Instrument = ml .get ('sr' )
1412sr .design .get_lattice ().disable_6d ()
1513sr .design .get_magnet (MagnetType .HCORRECTOR ,"SH1A-C01-H" ).strength .set (0.000010 )
Original file line number Diff line number Diff line change 11from pyaml .pyaml import pyaml ,PyAML
22from pyaml .instrument import Instrument
3- from pyaml .configuration import set_root_folder
43import pyaml as pyaml_pkg
54from pyaml .lattice .element_holder import MagnetType
65from pyaml .arrays .magnet_array import MagnetArray
76import numpy as np
87import at
98
109#def test_aml(config_root_dir):
11- set_root_folder ("tests/config" )
1210
13- ml :PyAML = pyaml ("EBSTune.yaml" )
11+ ml :PyAML = pyaml ("tests/config/ EBSTune.yaml" )
1412sr :Instrument = ml .get ('sr' )
1513sr .design .get_lattice ().disable_6d ()
1614
You can’t perform that action at this time.
0 commit comments