Skip to content

Commit

Permalink
Merge pull request #127 from epics-containers/dev
Browse files Browse the repository at this point in the history
tidy up of naming conventions
  • Loading branch information
gilesknap authored Oct 30, 2023
2 parents 0c7f6b9 + 5a1ee02 commit 35142e0
Show file tree
Hide file tree
Showing 16 changed files with 70 additions and 34 deletions.
6 changes: 1 addition & 5 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
"upgradePackages": false
}
},
// Set *default* container specific settings.json values on container create.
"settings": {
"python.defaultInterpreterPath": "/venv/bin/python"
},
"customizations": {
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
Expand Down Expand Up @@ -51,4 +47,4 @@
"workspaceFolder": "${localWorkspaceFolder}",
// After the container is created, install the python project in editable form
"postCreateCommand": "pip install -e '.[dev]'"
}
}
10 changes: 5 additions & 5 deletions .github/pages/make_switcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ def get_versions(ref: str, add: Optional[str], remove: Optional[str]) -> List[st
# Get a sorted list of tags
tags = get_sorted_tags_list()

# Make the sorted versions list from change_linter_to_ruff branches and tags
# Make the sorted versions list from main branches and tags
versions: List[str] = []
for version in ["master", "change_linter_to_ruff"] + tags:
for version in ["master", "main"] + tags:
if version in builds:
versions.append(version)
builds.remove(version)
Expand All @@ -67,7 +67,7 @@ def write_json(path: Path, repository: str, versions: str):
path.write_text(text, encoding="utf-8")


def change_linter_to_ruff(args=None):
def main(args=None):
parser = ArgumentParser(
description="Make a versions.txt file from gh-pages directories"
)
Expand Down Expand Up @@ -95,5 +95,5 @@ def change_linter_to_ruff(args=None):
write_json(args.output, args.repository, versions)


if __name__ == "__change_linter_to_ruff__":
change_linter_to_ruff()
if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
logo=dict(
text=project,
),
navigation_with_keys=True,
use_edit_page_button=True,
github_url=f"https://github.com/{github_user}/{github_repo}",
icon_links=[
Expand Down
2 changes: 1 addition & 1 deletion src/ibek/gen_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def create_db_script(ioc_instance: IOC) -> str:
"""
Create make_db.sh script for expanding the database templates
"""
with open(TEMPLATES / "db.subst.jinja", "r") as f:
with open(TEMPLATES / "ioc.subst.jinja", "r") as f:
jinja_txt = f.read()

renderer = RenderDb(ioc_instance)
Expand Down
3 changes: 1 addition & 2 deletions src/ibek/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@

# Folder containing templates for IOC src etc.
TEMPLATES = Path(__file__).parent / "templates"
# Folder containing symlinks to useful files
SYMLINKS = EPICS_ROOT / "links"
IBEK_FILES = EPICS_ROOT / "ibek"

IOC_DBDS = SUPPORT / "configure/dbd_list"
IOC_LIBS = SUPPORT / "configure/lib_list"
Expand Down
4 changes: 2 additions & 2 deletions src/ibek/ioc_cmds/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import typer

from ibek.globals import EPICS_ROOT, IOC_FOLDER, SYMLINKS
from ibek.globals import EPICS_ROOT, IBEK_FILES, IOC_FOLDER


def get_ioc_source() -> Path:
Expand Down Expand Up @@ -69,7 +69,7 @@ def extract_assets(destination: Path, source: Path, extras: List[Path], defaults
default_assets = [
get_ioc_source() / "ibek-support",
source / "support" / "configure",
SYMLINKS,
IBEK_FILES,
IOC_FOLDER,
Path("/venv"),
]
Expand Down
2 changes: 1 addition & 1 deletion src/ibek/runtime_cmds/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def generate(
help="Path to output startup script",
),
db_out: Path = typer.Option(
default="config/db.subst",
default="config/ioc.subst",
help="Path to output database expansion shell script",
),
):
Expand Down
4 changes: 2 additions & 2 deletions src/ibek/support_cmds/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
from typing_extensions import Annotated

from ibek.globals import (
IBEK_FILES,
IOC_DBDS,
IOC_LIBS,
RELEASE,
RUNTIME_DEBS,
SUPPORT,
SYMLINKS,
NaturalOrderGroup,
)
from ibek.support import Support
Expand Down Expand Up @@ -256,7 +256,7 @@ def generate_links(

support_yaml = from_path.glob("*/*.ibek.support.yaml")

to_path = SYMLINKS / "ibek"
to_path = IBEK_FILES
to_path.mkdir(parents=True, exist_ok=True)
for yaml in support_yaml:
link_from = to_path / yaml.name
Expand Down
File renamed without changes.
8 changes: 6 additions & 2 deletions src/ibek/templates/ioc/config/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ Choices of contents of the config folder are:
- send a reboot command to the RTEMS crate
- start a telnet session to the RTEMS IOC console
'

'
# This is a placeholder script, but we still need keep the container running.
# Wait indefinitely so the container does not exit and restart continually.
while true; do
sleep 1
done
10 changes: 5 additions & 5 deletions src/ibek/templates/ioc/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ if [ -f ${ibek_src} ]; then
final_ioc_startup=/tmp/st.cmd

# get ibek the support yaml files this ioc's support modules
defs=/epics/links/ibek/*.ibek.support.yaml
defs=/epics/ibek/*.ibek.support.yaml
ibek runtime generate ${ibek_src} ${defs} --out ${final_ioc_startup} --db-out ${db_src}

# build expanded database using msi
Expand All @@ -83,13 +83,13 @@ if [ -f ${ibek_src} ]; then
bash -c "msi -o${epics_db} ${includes} -S${db_src}"
fi

# 2. st.cmd + ioc.substitutions ************************************************
# 2. st.cmd + ioc.subst ************************************************
elif [ -f ${ioc_startup} ] ; then

if [ -f ${CONFIG_DIR}/ioc.substitutions ]; then
# generate ioc.db from ioc.substitutions, including all templates from SUPPORT
if [ -f ${CONFIG_DIR}/ioc.subst ]; then
# generate ioc.db from ioc.subst, including all templates from SUPPORT
includes=$(for i in ${SUPPORT}/*/db; do echo -n "-I $i "; done)
msi ${includes} -S ${CONFIG_DIR}/ioc.substitutions -o ${epics_db}
msi ${includes} -S ${CONFIG_DIR}/ioc.subst -o ${epics_db}
fi
final_ioc_startup=${ioc_startup}

Expand Down
6 changes: 3 additions & 3 deletions tests/generate_samples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ echo making an ioc schema using multiple support yaml files
ibek ioc generate-schema yaml/objects.ibek.support.yaml yaml/all.ibek.support.yaml --output schemas/multiple.ibek.ioc.schema.json

echo making ioc based on objects support yaml
ibek runtime generate yaml/objects.ibek.ioc.yaml yaml/objects.ibek.support.yaml --out outputs/objects.st.cmd --db-out outputs/objects.db.subst
ibek runtime generate yaml/objects.ibek.ioc.yaml yaml/objects.ibek.support.yaml --out outputs/objects.st.cmd --db-out outputs/objects.ioc.subst

echo making ioc based on utils support yaml
ibek runtime generate yaml/utils.ibek.ioc.yaml yaml/utils.ibek.support.yaml --out outputs/utils.st.cmd --db-out outputs/utils.db.subst
ibek runtime generate yaml/utils.ibek.ioc.yaml yaml/utils.ibek.support.yaml --out outputs/utils.st.cmd --db-out outputs/utils.ioc.subst

echo making ioc based on mutiple support yaml
ibek runtime generate yaml/all.ibek.ioc.yaml yaml/objects.ibek.support.yaml yaml/all.ibek.support.yaml --out outputs/all.st.cmd --db-out outputs/all.db.subst
ibek runtime generate yaml/all.ibek.ioc.yaml yaml/objects.ibek.support.yaml yaml/all.ibek.support.yaml --out outputs/all.st.cmd --db-out outputs/all.ioc.subst
23 changes: 23 additions & 0 deletions tests/samples/outputs/all.ioc.subst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#############################################################################
# DB substitution file generated by http://github.com/epics-containers/ibek #
#############################################################################

file "another_test.db" {
pattern
{ "name", "my_int_enum", "clock_rate", "db_calculated", "calculated_one" }
{ "AllObject One", "2", "dummy", "HELLO AllObject One", "AllObject One.AllObject One String.1.1.0.True" }
{ "AllObject Two", "1", "1", "HELLO AllObject Two", "AllObject Two.AllObject Two String.1.1.0.True" }
}

file "yet_another.db" {
pattern
{ "name", "my_object", "my_float", "my_bool" }
{ "AllObject One", "Ref1", "1.0", "True" }
{ "AllObject Two", "Ref1", "1.0", "True" }
}

file "test.db" {
pattern
{ "name", "ip", "value" }
{ "Consumer Two With DB", "127.0.0.1", "Ref1.127.0.0.1" }
}
10 changes: 10 additions & 0 deletions tests/samples/outputs/objects.ioc.subst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#############################################################################
# DB substitution file generated by http://github.com/epics-containers/ibek #
#############################################################################

file "test.db" {
pattern
{ "name", "ip", "value" }
{ "Consumer of another port", "10.0.0.2", "AsynPort2.10.0.0.2" }
{ "Another Consumer of the 2nd port", "10.0.0.2", "AsynPort2.10.0.0.2" }
}
3 changes: 3 additions & 0 deletions tests/samples/outputs/utils.ioc.subst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#############################################################################
# DB substitution file generated by http://github.com/epics-containers/ibek #
#############################################################################
12 changes: 6 additions & 6 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def test_build_runtime_single(tmp_path: Path, samples: Path):
ioc_yaml = samples / "yaml" / "objects.ibek.ioc.yaml"
support_yaml = samples / "yaml" / "objects.ibek.support.yaml"
out_file = tmp_path / "new_dir" / "st.cmd"
out_db = tmp_path / "new_dir" / "objects.db.subst"
out_db = tmp_path / "new_dir" / "objects.ioc.subst"

run_cli(
"runtime",
Expand All @@ -92,7 +92,7 @@ def test_build_runtime_single(tmp_path: Path, samples: Path):
actual_boot = out_file.read_text()
assert example_boot == actual_boot

example_db = (samples / "outputs" / "objects.db.subst").read_text()
example_db = (samples / "outputs" / "objects.ioc.subst").read_text()
actual_db = out_db.read_text()
assert example_db == actual_db

Expand All @@ -110,7 +110,7 @@ def test_build_runtime_multiple(tmp_path: Path, samples: Path):
support_yaml = samples / "yaml" / "objects.ibek.support.yaml"
support_yaml2 = samples / "yaml" / "all.ibek.support.yaml"
out_file = tmp_path / "st.cmd"
out_db = tmp_path / "all.db.subst"
out_db = tmp_path / "all.ioc.subst"

run_cli(
"runtime",
Expand All @@ -128,7 +128,7 @@ def test_build_runtime_multiple(tmp_path: Path, samples: Path):
actual_boot = out_file.read_text()
assert example_boot == actual_boot

example_db = (samples / "outputs" / "all.db.subst").read_text()
example_db = (samples / "outputs" / "all.ioc.subst").read_text()
actual_db = out_db.read_text()
assert example_db == actual_db

Expand All @@ -141,7 +141,7 @@ def test_build_utils_features(tmp_path: Path, samples: Path):
ioc_yaml = samples / "yaml" / "utils.ibek.ioc.yaml"
support_yaml = samples / "yaml" / "utils.ibek.support.yaml"
out_file = tmp_path / "st.cmd"
out_db = tmp_path / "db.subst"
out_db = tmp_path / "ioc.subst"

run_cli(
"runtime",
Expand All @@ -158,6 +158,6 @@ def test_build_utils_features(tmp_path: Path, samples: Path):
actual_boot = out_file.read_text()
assert example_boot == actual_boot

example_db = (samples / "outputs" / "utils.db.subst").read_text()
example_db = (samples / "outputs" / "utils.ioc.subst").read_text()
actual_db = out_db.read_text()
assert example_db == actual_db

0 comments on commit 35142e0

Please sign in to comment.