Skip to content

Commit

Permalink
Merge pull request #209 from epics-containers/tetramm
Browse files Browse the repository at this point in the history
builder2ibek.support fixes for tetramm
  • Loading branch information
gilesknap authored Apr 23, 2024
2 parents 67e023b + 4d6075b commit b6c1248
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ repos:
name: Run ruff
stages: [commit]
language: system
entry: ruff
entry: ruff check
types: [python]
3 changes: 2 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"program": "builder2ibek.support.py",
"console": "integratedTerminal",
"args": [
"/dls_sw/prod/R3.14.12.7/support/devIocStats/3-1-14dls3-3"
"/dls_sw/prod/R3.14.12.7/support/quadEM/9-4dls1",
"../quadEM.ibek.support.yaml"
],
"justMyCode": false
},
Expand Down
6 changes: 6 additions & 0 deletions builder2ibek.README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ recent version of the pmac module:
./builder2ibek.support.py /dls_sw/prod/R3.14.12.7/support/pmac/2-5-23beta1/ -o '14:A+B 474:A+B 801:1 805:1.0 804:1.0'
```

And this for the tetramm:
```bash
./builder2ibek.support.py /dls_sw/prod/R3.14.12.7/support/quadEM/9-4dls1 ../quadEM.ibek.support.yaml -o'21:2 25:100'
```


Without the 3 overrides the tools will fail as builder.py tries to convert
these 3 args to int.

42 changes: 30 additions & 12 deletions builder2ibek.support.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,12 @@ def _make_builder_object(self, name, builder_class):
"""
print("\nObject %s :" % builder_class.__name__)

# Classes with a leading underscore are assumed to be private / abstract
# builder never exposes them to xeb so we don't want them in the YAML
if builder_class.__name__.split(".")[-1].startswith("_"):
print("SKIPPING private class %s" % builder_class.__name__)
return None, None

arg_info = ArgInfo(
name,
getattr(builder_class, "UniqueName", "name"),
Expand Down Expand Up @@ -331,22 +337,32 @@ def _extract_substitutions(self, arginfo):
databases.append(database)

template, substitutions = all_substitutions.popitem()
first_substitution = substitutions[1][0]
if len(substitutions[1]) > 0:
first_substitution = substitutions[1][0]

database["file"] = template
database["file"] = template

print("\nDB Template %s :" % template)
print("\nDB Template %s :" % template)

if hasattr(first_substitution, "ArgInfo"):
arginfo.add_arg_info(first_substitution.ArgInfo)
# the DB Arg entries in the YAML are Dictionary entries with no value
no_values = {k: None for k in arginfo.builder_args}
elif hasattr(first_substitution, "Arguments"):
no_values = {k: None for k in first_substitution.Arguments}
else:
no_values = {"TODO": "No args for this template"}
if hasattr(first_substitution, "ArgInfo"):
arginfo.add_arg_info(first_substitution.ArgInfo)
# the DB Arg entries in the YAML are Dictionary entries with no value
no_values = {k: None for k in arginfo.builder_args}
elif hasattr(first_substitution, "Arguments"):
no_values = {k: None for k in first_substitution.Arguments}
else:
no_values = {"TODO": "No args for this template"}

database.insert(3, "args", no_values)
database.insert(3, "args", no_values)
else:
# this implies this is an included template - at least that is how
# it appears with the Tetramm support module. Included templates
# are brought in by instantiating their parent so do not need to
# appear in the support yaml
print(
"TODO:- No substitutions for %s " % template
+ "- this should be included by the above template"
)

if len(databases) > 0:
arginfo.yaml_defs["databases"] = databases
Expand Down Expand Up @@ -421,6 +437,8 @@ def make_yaml_tree(self):
# make an instance of the builder class and an ArgInfo that
# describes all its arguments
arginfo, builder_object = self._make_builder_object(name, builder_class)
if builder_object is None:
continue

# Go and find all the arguments for all the database templates
# and insert them plus DB file names into the YAML
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ commands =

[tool.ruff]
src = ["src", "tests"]
ignore = [
lint.ignore = [
"C408", # Unnecessary collection call - e.g. list(...) instead of [...]
"E501", # Line too long, should be fixed by black.
]
Expand All @@ -122,7 +122,7 @@ select = [
"W", # pycodestyle warnings - https://beta.ruff.rs/docs/rules/#warning-w
"I001", # isort
]
[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"builder2ibek.support.py" = ["E402"]

[tool.setuptools.packages.find]
Expand Down

0 comments on commit b6c1248

Please sign in to comment.