new cli arg - variable value override
ClosedPublic

Authored by lbrabec on Aug 13 2014, 10:52 AM.

Details

Summary

easy fix fox T244

variable values can be overridden from CLI arg (-o and --override)

Test Plan

py.test

python runtask.py -i xchat-2.8.8-21.fc20 -t koji_build -a x86_64 ../task-rpmlint/rpmlint.yml -o "workdir='/some/dir/' arch=['i386']"
values must be 'eval() acceptable' (string, list of strings..)

Diff Detail

Repository
rLTRN libtaskotron
Branch
feature/T244
Lint
No Linters Available
Unit
No Unit Test Coverage
lbrabec retitled this revision from to new cli arg - variable value override.Aug 13 2014, 10:52 AM
lbrabec updated this object.
lbrabec edited the test plan for this revision. (Show Details)
lbrabec added a reviewer: jskladan.
kparal requested changes to this revision.Aug 13 2014, 11:35 AM
kparal added a reviewer: kparal.
kparal added a subscriber: kparal.

Thanks for the patch. Few adjustment proposals below. Also, could you please add unit tests?

libtaskotron/runner.py
47

It should be safer to evaluate into custom dictionaries instead of globals() and locals() (look at optional arguments for eval()).

48

Please add a debug output here - what gets overridden and to what value.

179

I'd rather keep -o reserved for future use. Overriding should not be that common, let's use just the long version.

Can you make more obvious in help that this is intended to override internal variables used for the runner and the task formula? It might not be clear here. Of course it doesn't make sense to override CLI variables, because that can be adjusted directly from the command line.

Also, it would help a lot to include an example of the option value. And note that it is actually evaluated by eval().

205–214

Let's say:

# process overrides

here to keep it consistent.

207

I might be wrong, but simple

if args['override'] is not None:

should be sufficient here. Or it will be an empty list if we change it to multi-value parameter.

208

I'd rather request -o to be specified multiple times in order to override multiple variables, than introduce a custom multi-value syntax - splitting by whitespace.

Splitting single values into var and value by = sign, that's fine. We can't probably make it more obvious here.

This revision now requires changes to proceed.Aug 13 2014, 11:35 AM
lbrabec updated this revision to Diff 586.Aug 13 2014, 2:39 PM
  • polishing
lbrabec updated this revision to Diff 587.Aug 13 2014, 3:41 PM
  • polishing 2

Is there any specific reason for using:

parser.add_argument("--override", action="append", default=[], ...)
...
if 'override' in args: # <----- this if clause is always True

Instead of

parser.add_argument("--override", action="append", ...)
...
if args['override'] is not None:

?

lbrabec updated this revision to Diff 588.Aug 14 2014, 9:41 AM
  • polishing 3
lbrabec updated this revision to Diff 589.Aug 14 2014, 9:54 AM
  • metavar additon
kparal accepted this revision.Aug 14 2014, 9:57 AM

Looks OK here.

This revision is now accepted and ready to land.Aug 14 2014, 9:57 AM
jskladan accepted this revision.Aug 14 2014, 10:12 AM
tflink accepted this revision.Aug 14 2014, 11:17 AM

LGTM

Closed by commit 11434de (authored by @lbrabec).

lbrabec closed this revision.Aug 14 2014, 11:21 AM