1919import argparse
2020import getpass
2121import re
22- import socket
2322import subprocess
2423import shutil
2524import shlex
@@ -77,35 +76,6 @@ def raise_exception(result: subprocess.CompletedProcess, command: str) -> None:
7776 raise Exception (f"[FAIL] Error running command: '{ command } '\n { result .stderr } " )
7877
7978
80- def set_dependency_path (apps : Path , core : Path ) -> None :
81- """
82- Edit an LFRic Apps dependencies.sh file so that it points at the provided
83- LFRic Core source
84- """
85-
86- print ("[INFO] Updating dependencies.yaml Core source" )
87-
88- hostname = socket .gethostname ()
89- dep_path = apps / "dependencies.yaml"
90- with open (dep_path ) as f :
91- lines = f .readlines ()
92- in_core = False
93- for i , line in enumerate (lines ):
94- if line .strip ().startswith ("lfric_core" ):
95- in_core = True
96- elif in_core and "source:" in line :
97- prefix , _ , _ = line .partition ("source:" )
98- line = f"{ prefix } source: { hostname } :{ core } \n "
99- elif in_core and "ref:" in line :
100- prefix , _ , _ = line .partition ("ref:" )
101- line = f"{ prefix } ref:"
102- elif in_core :
103- break
104- lines [i ] = line
105- with open (dep_path , "w" ) as f :
106- f .write ("" .join (x for x in lines ))
107-
108-
10979def find_meta_dirs (paths : list [Path ], exclude_dirs : tuple [str ] = ()) -> set [Path ]:
11080 """
11181 Return a set of rose-metadata directories that can be found in the apps and
@@ -232,11 +202,9 @@ def copy_head_meta(meta_dirs: list[Path], apps: Path, core: Path, version: str)
232202 shutil .copytree (head , new )
233203 if core in new .parents :
234204 new = new .relative_to (core )
235- print (new )
236205 command = f"git -C { core } add { new } "
237206 elif apps in new .parents :
238207 new = new .relative_to (apps )
239- print (new )
240208 command = f"git -C { apps } add { new } "
241209 _ = run_command (command )
242210
@@ -446,6 +414,9 @@ def parse_args() -> argparse.Namespace:
446414 type = Path ,
447415 help = "Path to the LFRic Core working copy being used." ,
448416 )
417+ parser .add_argument (
418+ "-p" , "--processes" , type = int , default = 4 , help = "Number of processes to use"
419+ )
449420 args = parser .parse_args ()
450421
451422 args .apps = get_root_path (args .apps )
@@ -468,8 +439,6 @@ def main() -> None:
468439 args .core ,
469440 )
470441
471- set_dependency_path (args .apps , args .core )
472-
473442 # Find all metadata directories, excluing lfric-inputs as this has metadata but no
474443 # macros.
475444 exclude_dirs = (
@@ -495,6 +464,7 @@ def main() -> None:
495464 args .old_version ,
496465 args .apps ,
497466 args .core ,
467+ nproc = args .processes ,
498468 )
499469 print ("\n [INFO] Successfully upgraded apps" )
500470
0 commit comments