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 a package_preprocess_mode (#609) #651

Conversation

JeanChristopheMorinPerso
Copy link
Member

This PR implements #609 , which is make it possible to have both a global and local preprocess function run when building a package.

That means it's now possible to have a global preprocess that applies to all packages, and also have specialized preprocesses per packages if need be. This is made possible by a new configuration called package_preprocess_mode. It accepts 3 values: after, before and override.

The default value is override, which mean we have the exact same behavior as before: If you defined package_preprocess_function and you also have a preprocess function in a package, only the package's preprocess function is called.

after and before are what I call the additive modes. They allow you to choose to execute a package's preprocess function before or after the global preprocess.

  • I updated the docs;
  • Wrote tests.

@JeanChristopheMorinPerso
Copy link
Member Author

I'd like to mention that I feel like package_preprocess_function might not be a proper name now that we have additive behavior... I thought about adding a new global_preprocess_function/global_preprocess or something along these lines. It could live along side of package_preprocess_function and both would do the same thing. package_preprocess_function could raise a warning. But there is no warnings in rez as of now, and I don't know if I'm alone to think package_preprocess_function is no more a proper name.

Also, please don't merge this for now. I've written tests but I'd like to see if it fits at a bigger scale and see what I can do with it at RodeoFX to confirm the idea and behavior.

if preprocess_func:
print_info("Applying preprocess from package.py")
def _get_package_level():
print_info("Applying preprocess from package.py")
Copy link
Contributor

Choose a reason for hiding this comment

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

Message printed too early? I would also say '...from package definition' rather than package.py (you can configure rez to use a different filename).

if not preprocess_func or not isfunction(preprocess_func):
print_error("Function '%s' not found" % package_preprocess_function)
return None

print_info("Applying preprocess function %s" % package_preprocess_function)
Copy link
Contributor

Choose a reason for hiding this comment

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

Message printed too early? Would also mention 'applying global preprocess function'

]

def preprocess(this, data):
print 'Local preprocess'
Copy link
Contributor

Choose a reason for hiding this comment

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

use py3 syntax

@nerdvegas
Copy link
Contributor

Cheers! Only some minor issues that I can see.

RE the setting name - I wouldn't worry about this much, I think package_preprocess_function is fine. It would be odd with both settings as suggested, because one would make sense in the global config and one would not - which would be at odds with existing settings.

I'll wait til you're confident after more testing, just let me know.

Thx
A

continue

level = "global" if preprocessor == global_preprocess else "local"
print_info("Applying {0} preprocess function".format(level))
Copy link
Member Author

Choose a reason for hiding this comment

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

@nerdvegas I changed the message a little bit while fixing the messages being printed too early. I tried to make the message consistent across the local and global process. If you don't want to introduce the "global" term here, let me know and I'll try to rephrase.

@nerdvegas
Copy link
Contributor

Looks good JC. Just clarifying that this is ready to merge now, you said you were doing more testing?
Cheers
A

@JeanChristopheMorinPerso
Copy link
Member Author

Hey @nerdvegas sorry for taking so long on this. I'm currently in a big rush at work and it takes me quite a lot of my time. I've booked myself some time tomorrow to test this out a little bit more.

@JeanChristopheMorinPerso
Copy link
Member Author

@nerdvegas I tested more in depth and it's all good to go. You can merge this PR! Really sorry for the delay on this one.

@nerdvegas nerdvegas merged commit ba74f6f into AcademySoftwareFoundation:master Jul 16, 2019
@JeanChristopheMorinPerso JeanChristopheMorinPerso deleted the dev_additive_preprocess branch August 30, 2019 19:54
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.

None yet

2 participants