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

rose macro: suite level functionality #1884

Merged
merged 1 commit into from
May 11, 2016

Conversation

oliver-sanders
Copy link
Member

Closes the suite-level aspect of #1498

@arjclark Please Review
@benfitzpatrick Please Review

@oliver-sanders oliver-sanders added this to the soon milestone Apr 26, 2016
@@ -947,7 +950,7 @@ def run_macros(config_map, meta_config, config_name, macro_names,
reporter=reporter)
if not rc and no_changes:
reporter(MacroFinishNothingEvent())
sys.exit(rc)
return True if rc == 0 else False
Copy link
Contributor

Choose a reason for hiding this comment

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

You could just return rc == 0

@arjclark
Copy link
Contributor

arjclark commented Apr 26, 2016

Test battery pep8 checking item is failing:

t/syntax/00-lib.t (Wstat: 0 Tests: 3 Failed: 2)
  Failed tests:  1-2

One comment above.

@benfitzpatrick - please review 2 and confirm you're happy with these changes as resident rose macro expert. I've manually checked through a few examples I've got knocking around (both on CLI and in rose edit) but you're probably best placed to know any of the awkward cases that might cause issues.

@matthewrmshin
Copy link
Member

I believe this change should close #1498. We can raise a follow-on issue for the rose suite-run part after this is merged.

config_file_path = os.path.join(conf_dir, rose.TOP_CONFIG_NAME)
if (os.path.exists(config_file_path) and
os.path.isfile(config_file_path)):
for _, subdirs, _ in os.walk(os.path.join(conf_dir,
Copy link
Contributor

Choose a reason for hiding this comment

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

I know it sounds weird, but there can be apps with rose-app.conf files a couple of levels deep within their own directory structure! It's probably easier to do the same as we do with optional configuration files above (glob.glob) and only look for SUB_CONFIG_DIR + "/*/" + SUB_CONFIG_NAME.

@benfitzpatrick
Copy link
Contributor

This is a good change that people have been wanting for a while. Two comments above, and also I guess that technically running rose macro with an output directory (-O) is a bad idea across multiple apps - maybe disallow it.

@arjclark
Copy link
Contributor

I guess that technically running rose macro with an output directory (-O) is a bad idea across multiple apps - maybe disallow it.

Agreed, that sounds safest.

@oliver-sanders
Copy link
Member Author

@benfitzpatrick, @arjclark

  • Have disabled -O mode except when rose macro is run in an app (a single app).
  • When running over a suite apps will only be picked up in the path app/*/ to avoid problems with exotic suites.
  • App macros are now run in alphabetical order, suite macros are run last.

else:
# are we in an apps folder?
apps = []
for _, subdirs, _ in os.walk(conf_dir):
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, we could do with doing glob.glob here as well - or actually, it might be better to do what rose edit does and just go down the directory tree until we find a relevant configuration file. That avoids the problem of being stuck in e.g. etc/foo/bar/ suite subdirectory and running rose macro. rose edit in rose/config_editor/main.py does:

    path = os.getcwd()
    name_set = set([rose.SUB_CONFIG_NAME, rose.TOP_CONFIG_NAME])
    while True:
        if set(os.listdir(path)) & name_set:
            break
        path = os.path.dirname(path)
        if path == os.path.dirname(path):
            # We don't support suites located at the root!
            break
    if path != os.getcwd() and path != os.path.dirname(path):
        os.chdir(path)

Maybe we could pull this out into a new function and call that?

Copy link
Contributor

Choose a reason for hiding this comment

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

Or we could do it in a later PR

@oliver-sanders oliver-sanders force-pushed the 1498.2 branch 2 times, most recently from 8b8677e to 2215925 Compare May 3, 2016 11:15
@oliver-sanders
Copy link
Member Author

@benfitzpatrick Changed logic a bit.
Code now scans up through the directory structure until it encounters a rose-app.conf or a rose-suite.conf. If rose-app.conf run macros for that app only, if rose-suite.conf run macros for all apps located suite/app/* and for the suite itself. Running rose macro in suite/app is now equilivant to running in suite

@matthewrmshin matthewrmshin modified the milestones: soon, next-release May 5, 2016
@benfitzpatrick
Copy link
Contributor

OK, good - just needs t/syntax/00-lib.t fixing

@oliver-sanders
Copy link
Member Author

@benfitzpatrick Fixed syntax issue.

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