CWorthy-ocean / C-Star

C-Star is a python package for setting up and running ocean model simulations, with a particular focus on marine carbon dioxide removal (mCDR) applications.
https://c-star.readthedocs.io
10 stars 4 forks source link

Hide output #89

Closed dafyddstephenson closed 1 month ago

dafyddstephenson commented 1 month ago

Branches off #81 , do not merge until merging #81 Closes #76 but I have opened #88 to track the implementation of logging

This PR ensures anything printed to the screen under non-erroring circumstances comes from C-Star. Any stdout from completed processes with exit code 0 is hidden, but if a non-zero exit code is returned, the stderr is dumped to the screen. In the case of long processes (like running ROMS) I have used pOpen instead of run and printed a concise summary of the stdout to screen. Here's what the current test case output looks like :


Setting up MARBLComponent
--------------------------

Configuring MARBLBaseModel
---------------------------
MARBLBaseModel correctly configured. Nothing to be done

Setting up ROMSComponent
-------------------------

Configuring ROMSBaseModel
--------------------------
ROMSBaseModel correctly configured. Nothing to be done

Fetching additional code... 
--------------------------
Cloned repository https://github.com/dafyddstephenson/roms_marbl_example.git to /var/folders/1s/xjsjyqrj2rdft8014664qczc0000gn/T/tmp9xg93ncf
Checked out 368d729d9500b98d0f1126a1b56620df7a2bae65 in git repository /var/folders/1s/xjsjyqrj2rdft8014664qczc0000gn/T/tmp9xg93ncf
copying source_mods/bgc.opt to /Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/additional_code/ROMS/source_mods
copying source_mods/bulk_frc.opt to /Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/additional_code/ROMS/source_mods
copying source_mods/cppdefs.opt to /Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/additional_code/ROMS/source_mods
copying source_mods/diagnostics.opt to /Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/additional_code/ROMS/source_mods
copying source_mods/ocean_vars.opt to /Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/additional_code/ROMS/source_mods
copying source_mods/param.opt to /Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/additional_code/ROMS/source_mods
copying source_mods/tracers.opt to /Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/additional_code/ROMS/source_mods
copying source_mods/Makefile to /Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/additional_code/ROMS/source_mods
copying source_mods/get_makefile to /Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/additional_code/ROMS/source_mods
copying source_mods/Make.depend to /Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/additional_code/ROMS/source_mods
copying namelists/roms.in_TEMPLATE to /Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/additional_code/ROMS/namelists
copying /Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/additional_code/ROMS/namelists/roms.in_TEMPLATE to editable namelist /Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/additional_code/ROMS/namelists/roms.in
copying namelists/marbl_in to /Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/additional_code/ROMS/namelists
copying namelists/marbl_tracer_output_list to /Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/additional_code/ROMS/namelists
copying namelists/marbl_diagnostic_output_list to /Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/additional_code/ROMS/namelists

Fetching input datasets...
--------------------------
Downloading file 'roms_grd.nc' from 'https://github.com/CWorthy-ocean/input_datasets_roms_marbl_example/raw/main/roms_grd.nc' to '/Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/input_datasets/ROMS'.
Downloading file 'MARBL_rst.20120103120000.nc' from 'https://github.com/CWorthy-ocean/input_datasets_roms_marbl_example/raw/main/MARBL_rst.20120103120000.nc' to '/Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/input_datasets/ROMS'.
Downloading file 'roms_tides.nc' from 'https://github.com/CWorthy-ocean/input_datasets_roms_marbl_example/raw/main/roms_tides.nc' to '/Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/input_datasets/ROMS'.
Downloading file 'roms_bry_2012.nc' from 'https://github.com/CWorthy-ocean/input_datasets_roms_marbl_example/raw/main/roms_bry_2012.nc' to '/Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/input_datasets/ROMS'.
Downloading file 'roms_bry_bgc_MARBL.nc' from 'https://github.com/CWorthy-ocean/input_datasets_roms_marbl_example/raw/main/roms_bry_bgc_MARBL.nc' to '/Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/input_datasets/ROMS'.
Downloading file 'roms_frc_bgc.nc' from 'https://github.com/CWorthy-ocean/input_datasets_roms_marbl_example/raw/main/roms_frc_bgc.nc' to '/Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/input_datasets/ROMS'.
Downloading file 'roms_frc.201201.nc' from 'https://github.com/CWorthy-ocean/input_datasets_roms_marbl_example/raw/main/roms_frc.201201.nc' to '/Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/input_datasets/ROMS'.

Compiling MARBLComponent
-------------------------
No build steps to be completed for MARBLComponent

Compiling ROMSComponent
------------------------
Compiling UCLA-ROMS configuration...
UCLA-ROMS compiled at /Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/additional_code/ROMS/source_mods

Completing pre-processing steps for MARBLComponent
---------------------------------------------------
No pre-processing steps to be completed for MARBLComponent

Completing pre-processing steps for ROMSComponent
--------------------------------------------------
Partitioning /Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/input_datasets/ROMS/roms_grd.nc into (3,3)
Adding /Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/input_datasets/ROMS/roms_grd.nc to ROMS namelist file
Partitioning /Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/input_datasets/ROMS/MARBL_rst.20120103120000.nc into (3,3)
Adding /Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/input_datasets/ROMS/MARBL_rst.20120103120000.nc to ROMS namelist file
Partitioning /Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/input_datasets/ROMS/roms_tides.nc into (3,3)
Adding /Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/input_datasets/ROMS/roms_tides.nc to ROMS namelist file
Partitioning /Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/input_datasets/ROMS/roms_bry_2012.nc into (3,3)
Adding /Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/input_datasets/ROMS/roms_bry_2012.nc to ROMS namelist file
Partitioning /Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/input_datasets/ROMS/roms_bry_bgc_MARBL.nc into (3,3)
Adding /Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/input_datasets/ROMS/roms_bry_bgc_MARBL.nc to ROMS namelist file
Partitioning /Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/input_datasets/ROMS/roms_frc_bgc.nc into (3,3)
Adding /Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/input_datasets/ROMS/roms_frc_bgc.nc to ROMS namelist file
Partitioning /Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/input_datasets/ROMS/roms_frc.201201.nc into (3,3)
Adding /Users/dafyddstephenson/Code/my_c_star/tests/roms_marbl_example_case/input_datasets/ROMS/roms_frc.201201.nc to ROMS namelist file

Running ROMS: 
------------
Running ROMS: Initializing run...
Running ROMS: time-step 0 of 5 (0.5s elapsed; ETA 0.0s)
Running ROMS: time-step 0 of 5 (2.7s elapsed; ETA 0.0s)
Running ROMS: time-step 1 of 5 (2.8s elapsed; ETA 1.4s)
Running ROMS: time-step 2 of 5 (3.0s elapsed; ETA 2.0s)
Running ROMS: time-step 3 of 5 (3.1s elapsed; ETA 2.0s)
Running ROMS: time-step 4 of 5 (3.2s elapsed; ETA 1.3s)

Completing post-processing steps for ROMSComponent
---------------------------------------------------
Joining netCDF files ROMS_MARBL_bgc.20120103120000.*.nc...
Joining netCDF files ROMS_MARBL_his.20120103120000.*.nc...
Joining netCDF files ROMS_MARBL_bgc_dia.20120103120000.*.nc...
review-notebook-app[bot] commented 1 month ago

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB