8000 Bosh simulate consistency patch by DarrinFong · Pull Request #605 · boutiques/boutiques · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Bosh simulate consistency patch #605

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

Merged
merged 5 commits into from
May 4, 2020

Conversation

DarrinFong
Copy link
Contributor
@DarrinFong DarrinFong commented Apr 16, 2020

Related issues

#578

Purpose

bosh exec simulate should yield consistent results regardless of an invocation's presence through option -i.

Current behaviour

Descriptor's optional: true inputs with default-value are not added to simulated command-line output, but are added when an invocation (created by bosh example) is supplied.

New behaviour

optional: true inputs with default-value are added to simulated command-line output consistently.

Implementation Detail

In simulate, localExec.addDefaultValues is called before LocalExecutor.generateRandomParams.

LocalExecutor.generateRandomParams no longer takes argument n for the number of iterations to attempt. This is to prevent the LocalExecutor.in_dict from clearing before each iteration (in_dict contains inputs to use when generating random param values).

…dified LocalExecutor.generateRandomParams. To be discussed (can no longer loop _randomFillInDict)
@coveralls
Copy link
coveralls commented Apr 17, 2020

Coverage Status

Coverage increased (+0.08%) to 94.047% when pulling 1197636 on DarrinFong:bsimulate_inconsistency_#578 into 9dc12cf on boutiques:develop.

@DarrinFong DarrinFong marked this pull request as ready for review April 17, 2020 19:00
@glatard glatard requested a review from gkiar April 19, 2020 00:35
@glatard
Copy link
Member
glatard commented Apr 19, 2020

@gkiar would you like to review and test this one?

@gkiar
Copy link
Member
gkiar commented Apr 20, 2020

@glatard @DarrinFong yep - sorry for the delay, I'll get to this tomorrow :)

@gkiar
Copy link
Member
gkiar commented Apr 24, 2020

@DarrinFong the changes look good, thanks!

However, I'm still getting the exact same error in the config file case as is documented in #578 . Could you add the descriptor I pasted in that issue to the test suite, and verify consistent performance? Thanks for the hard work!

Copy link
Member
@gkiar gkiar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Send me a ping when it's ready for the next review!

@DarrinFong
Copy link
Contributor Author
DarrinFong commented Apr 28, 2020

However, I'm still getting the exact same error in the config file case as is documented in #578

@gkiar Hi Greg, I couldn't replicate the same errors despite using the descriptor and commands in #578 . Can you let me know if the new test covers the issue? Thanks a lot!

@gkiar
Copy link
Member
gkiar commented Apr 29, 2020

Hmm @DarrinFong, could it perhaps be the way the command-line utility is invoking this? I've just checked out your last commit and did/got the following:

[DarrinFong/bsimulate_inconsistency_#578] gkiar $ git log -1
commit d986441e55d665453831e25424f2d43401620e6b (HEAD -> DarrinFong/bsimulate_inconsistency_#578)
Author: darrinfong <darrinfong@gmail.com>
Date:   Tue Apr 28 16:45:59 2020 -0400

    python string incompatibility fix
[DarrinFong/bsimulate_inconsistency_#578] gkiar $ cat tmp.json
{
    "name": "tool",
    "tool-version": "1",
    "description": "a tool",
    "command-line": "tool_cli [CONFIG_FILE]",
    "schema-version": "0.5",
    "inputs": [
    {
        "id": "value",
        "name": "value",
        "type": "String",
        "value-key": "[VALUE]",
        "value-choices": ["yes", "no"],
        "default-value": "no",
        "optional": true
    }
    ],
    "output-files": [
    {
        "id": "config_file",
        "name": "Configuration file",
        "value-key": "[CONFIG_FILE]",
        "path-template": "config.toml",
        "file-template": [
            "hi__",
            "value = [VALUE]",
            "__bye"
            ]
        }
    ]
}

[DarrinFong/bsimulate_inconsistency_#578] gkiar $ bosh exec simulate tmp.json && cat config.toml
Generated Command:
tool_cli config.toml
hi__
value = no
__bye

[DarrinFong/bsimulate_inconsistency_#578] gkiar $ bosh example tmp.json && cat config.toml
{}
hi__

__bye

@DarrinFong
Copy link
Contributor Author
DarrinFong commented Apr 29, 2020

@gkiar If I remember correctly bosh example is behaving as expected (#373), the value field will be populated in the config file if --complete flag is used. However the default value will not be used (value is randomly generated in localExec amongst value-choices). I'm not sure where to go from here, maybe have a new issue where bosh example [desc] --complete would prioritise default-value?

@gkiar
Copy link
Member
gkiar commented Apr 30, 2020

Hey @DarrinFong I think you're right in the case of common descriptors/invocations, but I think in a config file the default values should always be populated as having empty lines in a config file where some input is expected may cause issue. In this case, I think it's safer to assume the value isn't a default in the sense of "will be assumed" but rather as "the expected value" of a parameter.

What do you think? Could you maybe build in a switch that automatically forces --complete for all arguments which would get substituted within a config file, and leave the behaviour for other arguments as-is?

In any case, I think we should have consistency between our simulation methods -- I wouldn't expect bosh exec simulate and bosh example do give us different behaviour, and think harmonizing these is important.

Thanks for the hard work on this!

@DarrinFong
Copy link
Contributor Author

Hey @gkiar, I agree we should expect consistent behaviour, so I went back and thought about this: The purpose of example and exec simulate should be different since example is to generate a sample invocation, and exec simulate is to simulate an execution.

From that, we shouldn't expect example to generate a config file at all, because the file should only be generated during an execution. Therefore I propose to remove any output other than the invocation from example and leave exec simulate unchanged from last commit.

Let me know if I made an incorrect assumption on example's or exec simulate's behaviour. Thanks for the followup 😃

@gkiar
Copy link
Member
gkiar commented May 2, 2020

@DarrinFong -- I agree completely, great point and yes let's make that happen! Thanks for the great work on this, it's hugely appreciated!

@gkiar
Copy link
Member
gkiar commented May 4, 2020

Looks great :) Nicely done, @DarrinFong !

@gkiar gkiar merged commit 29eb45c into boutiques:develop May 4, 2020
@glatard glatard mentioned this pull request May 21, 2020
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.

4 participants
0