Replies: 1 comment
-
|
@MatthewHambley , @yaswant , @t00sa , @Pierre-siddall , @stevemullerworth , @cameronbateman-mo We agreed in the telco on Thursdayto add a new base class to the apps repo, which is the base class for all lfric_apps scripts, and is responsible for modifying Python's
This triggers Or am I missing a better solution here? Feedback really appreciated.
Scott Wales had a different approach, using a top-level But I assume you would consider this as a wrapper script as well? Could someone give me some details how you want this implemented? I.e. a set of dummy files, e,g.:
so that you can use Thanks! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
@MatthewHambley , @yaswant , @Pierre-siddall , @t00sa , @cameronbateman-mo, @jasonjunweilyu
As part of Matthew's review, he raised an issue that boils down to: how do we know where
lfric_coreis when building an application.FWIW, the current (makefile) solution is to use an environment variable (some stuffing around in
local_build.py, but as far as I can see it eventually just exports CORE_ROOT_DIR and the calls make).I had the following design goals in mind when creating our solution:
makeis hiding this pretty well ;) ).psyclone_tools.pycan be imported. This needs to be done somewhere :)There are various solutions of course. Here what Jason and I decided to do (note that this was originally motivated by not having a Fab release, but our approach allows additional things):
Any fab script is called using a wrapper in core, e.g.:
The wrapper is then used to adjust
PYTHONPATHso thatlfric_basefrom the core repo and all other tools can be easily imported. This works the same for applications in core and apps.Matthew told us in the core review:
The wrapper is definitely not pointless, since it connects the application directory with the core directory. Supporting the import of Fab can of course be removed, as long as we are using a released version. For testing new versions of Fab this is still pretty handy (esp. ih this repo, where we evaluate new Fab versions all the time :) ), but indeed that does not need to go into the lfric repos.
Additionally (not done atm since we didn't want to affect the rest of the lfric build), at this step we can ensure that
psyclone_tools.pycan be imported, meaning that cylc and interactive builds are identical (in this regard). And that's basically the same that happens in themakebuild: invoking make scripts from core will modify the PYTONPATH. We can also use this to move the handling of site-specific configurations out of the base class (since Matthew doesn't like that we modifysys.paththere). This would mean, there is just one location that sets up python to work correctly everywhere.FWIW, the current approach using
local_build.pyis to basically use a command line option to specify core (unless it is checked out ... yes, when we do a clean checkout we have the location, but the fab script we are designing is based on what happens once you have the two repos checked out, esp. to support interactive and cylc builds based on current paths). So something like:Which is basically the same information :)
If we add a command line option to the fab scripts to indicate where the core sources are, we either:
lfric_apps_baseclass can import thelfric_baseclass in the beginning (unless more messing around withsys.pathin the script before importing of course :) ).Of, we could use an initialisation script (
. $LFRIC_CORE/init_python?) and then just run it, but I don't find that any clearer.All in all, I actually do like our solution (no surprise :) obviously I am biased ;) ), but am happy for other solutions. Suggestions welcome.
Beta Was this translation helpful? Give feedback.
All reactions