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

add values support (completed) #68

Merged
merged 16 commits into from
May 11, 2023
Merged

add values support (completed) #68

merged 16 commits into from
May 11, 2023

Conversation

gilesknap
Copy link
Member

I'm struggling with implementing 'values' calculated fields.

The example I want to render is https://github.com/epics-containers/ibek-defs/blob/psc/ipac/ipac.ibek.support.yaml.

I first tried adding the values in as defaulted Args in make_entity_class. But this interfered with the schema - so you could see the entry and override it just like it was an Arg (I suppose we could call that a feature but its not clear that you are not supposed to supply a value for it).

Next I decided to just copy the values into all instances in ioc_deserialize. The current PR shows this. It does not work because converting the instance to Dict for Jinja does not pick up the new attributes because they are not in dataclass_fields. I could fix that I suppose but it is feeling really nasty.

@coretl I wondered if you had ideas on how to do this nicely.

(Values should really be a class variable that gets passed to all entity instances but is not needed in ioc yaml. If there is a nice way to do this it might need to change with the Pydantic update.)

@gilesknap gilesknap temporarily deployed to github-pages May 10, 2023 11:36 — with GitHub Actions Inactive
@gilesknap gilesknap temporarily deployed to github-pages May 10, 2023 13:06 — with GitHub Actions Inactive
Thus saving passing it around everywhere.
@gilesknap gilesknap temporarily deployed to github-pages May 10, 2023 13:19 — with GitHub Actions Inactive
@gilesknap gilesknap temporarily deployed to github-pages May 10, 2023 13:23 — with GitHub Actions Inactive
@gilesknap gilesknap temporarily deployed to github-pages May 10, 2023 13:34 — with GitHub Actions Inactive
@codecov-commenter
Copy link

codecov-commenter commented May 10, 2023

Codecov Report

Merging #68 (af36d3c) into main (9460e41) will decrease coverage by 0.22%.
The diff coverage is 97.72%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##             main      #68      +/-   ##
==========================================
- Coverage   97.84%   97.63%   -0.22%     
==========================================
  Files           9        9              
  Lines         372      381       +9     
==========================================
+ Hits          364      372       +8     
- Misses          8        9       +1     
Impacted Files Coverage Δ
src/ibek/support.py 98.82% <87.50%> (-1.18%) ⬇️
src/ibek/__main__.py 100.00% <100.00%> (ø)
src/ibek/gen_scripts.py 100.00% <100.00%> (ø)
src/ibek/ioc.py 97.80% <100.00%> (+0.36%) ⬆️
src/ibek/render.py 97.59% <100.00%> (-0.26%) ⬇️
src/ibek/utils.py 90.62% <100.00%> (+0.30%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@gilesknap gilesknap changed the title add values support (broken) add values support (in progress) May 10, 2023
@gilesknap
Copy link
Member Author

This is now working using post_init in Entity class to add a context.

Next I need to do the first stage Jinja render in the context at post_init time.

At present things that use counters will continue to increment for each reference e,g,

    script:
      - type: function
        name: ipacAddHy8002
        header: |
          #   Create a new Hy8002 carrier.
          #   The resulting carrier handle (card id) is saved in an env variable.
        args:
          # args are combined into a single string - hence the quoting below
          '"slot, interrupt_level"': '"{{ slot }}, {{ int_level }}"'
      - epicsEnvSet {{ name }} {{ card_id }} {{ card_id }} {{ card_id }} {{ card_id }} {{ card_id }} {{ card_id }}

src/ibek/ioc.py Outdated Show resolved Hide resolved
src/ibek/ioc.py Outdated Show resolved Hide resolved
src/ibek/gen_scripts.py Outdated Show resolved Hide resolved
src/ibek/gen_scripts.py Outdated Show resolved Hide resolved
@gilesknap gilesknap temporarily deployed to github-pages May 10, 2023 19:06 — with GitHub Actions Inactive
@gilesknap gilesknap temporarily deployed to github-pages May 10, 2023 19:12 — with GitHub Actions Inactive
@gilesknap gilesknap temporarily deployed to github-pages May 11, 2023 06:46 — with GitHub Actions Inactive
@gilesknap gilesknap temporarily deployed to github-pages May 11, 2023 07:16 — with GitHub Actions Inactive
@gilesknap gilesknap temporarily deployed to github-pages May 11, 2023 07:45 — with GitHub Actions Inactive
@gilesknap gilesknap changed the title add values support (in progress) add values support (completed) May 11, 2023
@gilesknap gilesknap temporarily deployed to github-pages May 11, 2023 07:52 — with GitHub Actions Inactive
@gilesknap gilesknap temporarily deployed to github-pages May 11, 2023 07:57 — with GitHub Actions Inactive
@gilesknap gilesknap temporarily deployed to github-pages May 11, 2023 08:19 — with GitHub Actions Inactive
src/ibek/ioc.py Show resolved Hide resolved
src/ibek/ioc.py Show resolved Hide resolved
src/ibek/render.py Outdated Show resolved Hide resolved
src/ibek/render.py Outdated Show resolved Hide resolved
@gilesknap gilesknap temporarily deployed to github-pages May 11, 2023 11:14 — with GitHub Actions Inactive
@gilesknap gilesknap temporarily deployed to github-pages May 11, 2023 13:20 — with GitHub Actions Inactive
@gilesknap gilesknap temporarily deployed to github-pages May 11, 2023 13:29 — with GitHub Actions Inactive
@gilesknap gilesknap merged commit 5f8d4fe into main May 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants