# Rose: Any way to get list of opt conf keys used?

**URL:** <https://cylc.discourse.group/t/rose-any-way-to-get-list-of-opt-conf-keys-used/990>\
**Category:** Rose Support\
**Created:** [July 24, 2024, 1:56am UTC](https://cylc.discourse.group/t/rose-any-way-to-get-list-of-opt-conf-keys-used/990 "2024-07-24T01:56:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![TomC](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/tomc/32/115_2.png) [@TomC](https://cylc.discourse.group/u/TomC)\
**Post date:** [July 24, 2024, 1:56am UTC](https://cylc.discourse.group/t/rose-any-way-to-get-list-of-opt-conf-keys-used/990/1 "2024-07-24T01:56:07Z")

</div>

Hi,

If you use `rose task-run` to launch an app and pass it opt conf keys from that command, e.g. `rose task-run -O foo -O bar`, is it possible to find out what opt conf keys were used? I couldn’t see any reference to them in any environment variables. I know I can look in the job.out file, but I was hoping there was a way to just know from shell. Yes, I know the environment variable ROSE\_APP\_OPT\_CONF\_KEYS could be used, but its a bit tedious using that if you’re needing to use a default and add things to it as [Cylc does not support mutations of previously defined items natively](https://github.com/cylc/cylc-flow/issues/1363).

---

<div class="post-metadata">

**Author:** ![wxtim](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/wxtim/32/151_2.png) [@wxtim](https://cylc.discourse.group/u/wxtim)\
**Post date:** [July 24, 2024, 8:50am UTC](https://cylc.discourse.group/t/rose-any-way-to-get-list-of-opt-conf-keys-used/990/2 "2024-07-24T08:50:54Z")

</div>

I’ve had a think and a look a the docs, but I couldn’t see an easy way of doing this.

The best I can come up with is:

```ini
default=ROSE_TASK_CMD=$(grep "rose task-run" "${ROSE_TASK_LOG_ROOT}")
       =echo "ROSE_TASK_CMD=${ROSE_TASK_CMD}"
       =ROSE_TASK_OPTS=$(python -c 'import re; getopts = re.compile("(?:-O|--opt-conf-key)\s+(\S+)"); print(" ".join(getopts.findall("rose task-run -O foo -O bar")))')
       =echo "ROSE_TASK_OPTS=${ROSE_TASK_OPTS}"

```

YMMV: You might be able to write the regex in Bash or Perl to avoid the expensive Python call.  
You can probably condense this into a one liner at the expense of making it even less readable.

@oliver.sanders - is this a variable it would be reasonable to have rose export?

---

<div class="post-metadata">

**Author:** ![oliver.sanders](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/oliver.sanders/32/110_2.png) [@oliver.sanders](https://cylc.discourse.group/u/oliver.sanders)\
**Post date:** [July 31, 2024, 8:51am UTC](https://cylc.discourse.group/t/rose-any-way-to-get-list-of-opt-conf-keys-used/990/3 "2024-07-31T08:51:12Z")

</div>

Hi,

From a bit of playing, it seems the optional configs that are used get logged in verbose mode. If you add `-v` onto the `rose task-run` command, you should see something like this:

```auto
[INFO] Configuration: app/myapp
[INFO] file: rose-app.conf
[INFO] optional key: foo

```

The processed configuration that Rose used (which includes any optional config overrides) is also output to the `rose-app-run.conf` which should be written to the task’s working directory.

It would be reasonable to add `opts` into the `rose-app-run.conf` (but commented out) similar to what we do with the `rose-suite-cylc-install.conf` file to make it easier for people to access the linearised optional config list post-run.

> <https://github.com/metomi/rose/issues/2804>
>
> \> \*\*Note\*\* This applies to \`rose app-run\` and \`rose task run\`.
> 
> When a rose ap…plication is run, we output the flattened configuration to the \`rose-app-run.conf\` file.
> 
> Any optional configs or CLI options are applied before this file is written out, so this exists to reference the exact configuration run.
> 
> It might be useful to record any optional configurations that the app was run with in this file for ease of reference.
> 
> E.G:
> 
> \`\`\`ini
> !opts=foo bar baz
> 
> \[command\]
> default=true
> \`\`\`
> 
> Note, I have made \`opts\` an "ignored" variable here as the opts have already been applied (so are no longer a functional part of the configuration) and because the \`opt/\` files are not present at this point (so leaving it "enabled" would prevent you from being able to parse this config at a later date).
> 
> See https://cylc.discourse.group/t/rose-any-way-to-get-list-of-opt-conf-keys-used/990/3
