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

Make logging better for pycbc_make_offline_workflow #4517

Merged

Conversation

GarethCabournDavies
Copy link
Contributor

We realised that the pegasus logging was getting a little out of hand in the pycbc_make_offline_workflow code. Here I fix this three ways:

  • The log that was overbearing was specifically this one from pegasus, so I have added a line to grab the logger for this module, and set the logger level to be one level above the default pycbc logger (so, e.g., INFO would not be shown as default in this code)
  • I also did the same trick for the scitokens warning here.
  • I have reduced the level of this log to be logging.debug as this is called every time a new executable is set up, but this happens for every parallel instance of e.g. pycbc_coinc_findtrigs so was overloading the output as well.

After these three changes, the output is much more manageable (I actually noticed config warnings that I hadn't noticed before!).

HOWEVER we might want the info that I have silenced, so I added the call to pycbc.init_logging to pycbc_make_offline_search_workflow, so that the verbosity level can be increased if desired. It is at info by default, and will go to debug if --verbose is given

@GarethCabournDavies
Copy link
Contributor Author

(The new-style --verbose output actually gives us information we were losing before as the logging level was hardcoded)

Copy link
Contributor

@spxiwh spxiwh left a comment

Choose a reason for hiding this comment

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

MInor changes requested, but I think the changes implemented make sense.

# Log to the screen until we know where the output file is
logging.basicConfig(format='%(asctime)s:%(levelname)s : %(message)s',
level=logging.INFO)

Copy link
Contributor

Choose a reason for hiding this comment

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

Does this move change anything?

Copy link
Contributor Author

@GarethCabournDavies GarethCabournDavies Oct 9, 2023

Choose a reason for hiding this comment

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

Don't think it does - looks like the workflow log file is created correctly, and added to the results page as normal

The only difference I see is that we can now configure to use more verbosity by passing the option

Copy link
Contributor Author

@GarethCabournDavies GarethCabournDavies Oct 9, 2023

Choose a reason for hiding this comment

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

Ahh - Ive just seen that there is the second call to the basicConfig to send to the log file

The change to init_logging also makes the default format change to use ISO standard time format including timezone and removes the level

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suppose the question is which format we want, using the logging level, or the updated timezone format (or neither or both)

I don't want to revert to the direct basicConfig call, as then we would be unable to run with logging.DEBUG and would just lose all of the information we are wanting to make quieter

@@ -38,6 +39,9 @@
PEGASUS_FILE_DIRECTORY = os.path.join(os.path.dirname(__file__),
'pegasus_files')

# Get the logger associated with the Pegasus workflow import
pegasus_logger = logging.getLogger('Pegasus')
Copy link
Contributor

Choose a reason for hiding this comment

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

As you only access this in one place, it doesn't need to be a global variable, just do this above line 325 (unless I'm missing something??)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved - I had thought it would be needed elsewhere, but its just the once

Comment on lines 854 to 857
DeprecationWarning("The from_path method in pegasus_workflow is "
"deprecated. Please use File.from_path (for "
"output files) in core.py or resolve_url_to_file "
"in core.py (for input files) instead.")
Copy link
Contributor

Choose a reason for hiding this comment

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

This will not do anything actually; if you want the warning to be printed, you need something like

import warnings

warnings.warn('Blah', DeprecationWarning)

@GarethCabournDavies
Copy link
Contributor Author

There is an example of the workflow log file in https://ldas-jobs.ligo.caltech.edu/~gareth.cabourndavies/testoutput/pegasus_verbosity/output/results/9._workflow/H1L1-WORKFLOW-LOG-1368933107-679711.html

We should note that is not what is printed to the terminal due to two different loggers, but we see that it removes the super-loud stuff

@spxiwh
Copy link
Contributor

spxiwh commented Oct 9, 2023

@GarethCabournDavies a proposed patch, which I think allows the format to remain, while still updating verbose settings (also minor simplification):

diff --git a/bin/workflows/pycbc_make_offline_search_workflow b/bin/workflows/pycbc_make_offline_search_workflow
index 9b3a7da867..b6895314a8 100755
--- a/bin/workflows/pycbc_make_offline_search_workflow
+++ b/bin/workflows/pycbc_make_offline_search_workflow
@@ -59,15 +59,17 @@ def ifo_combos(ifos):
 
 parser = argparse.ArgumentParser(description=__doc__[1:])
 parser.add_argument('--version', action='version', version=__version__)
-parser.add_argument('--verbose', action='count',
+parser.add_argument('--verbose', action='count', default=0,
     help="Incrementally add more verbosity")
 wf.add_workflow_command_line_group(parser)
 wf.add_workflow_settings_cli(parser)
 args = parser.parse_args()
 
+# Set up logging to the screen
 # By default, we do logging.info, each --verbose adds a level of verbosity
-logging_level = args.verbose + 1 if args.verbose else logging.INFO
-pycbc.init_logging(logging_level)
+logging_level = args.verbose*10 + logging.INFO
+logging.basicConfig(format='%(asctime)s:%(levelname)s : %(message)s',
+                    level=logging_level)
 
 container = wf.Workflow(args, args.workflow_name)
 workflow = wf.Workflow(args, args.workflow_name + '-main')

@GarethCabournDavies
Copy link
Contributor Author

GarethCabournDavies commented Oct 10, 2023

Latest, with Ian's patch:

Standard output: here

output with --verbose here

@GarethCabournDavies GarethCabournDavies merged commit ec9221a into gwastro:master Oct 10, 2023
31 checks passed
GarethCabournDavies added a commit to GarethCabournDavies/pycbc that referenced this pull request Oct 11, 2023
* Make logging better for pycbc_make_offline_workflow

* comment

* Fix bug

* CC complaint - there are some other, but these havent been changed by this PR

* CC

* Update pycbc/workflow/core.py

Co-authored-by: Tito Dal Canton <[email protected]>

* IH/TDC comments

* use warnings module

---------

Co-authored-by: Tito Dal Canton <[email protected]>
@GarethCabournDavies GarethCabournDavies deleted the pegasus_verbosity branch October 16, 2023 09:00
PRAVEEN-mnl pushed a commit to PRAVEEN-mnl/pycbc that referenced this pull request Nov 3, 2023
* Make logging better for pycbc_make_offline_workflow

* comment

* Fix bug

* CC complaint - there are some other, but these havent been changed by this PR

* CC

* Update pycbc/workflow/core.py

Co-authored-by: Tito Dal Canton <[email protected]>

* IH/TDC comments

* use warnings module

---------

Co-authored-by: Tito Dal Canton <[email protected]>
bhooshan-gadre pushed a commit to bhooshan-gadre/pycbc that referenced this pull request Mar 4, 2024
* Make logging better for pycbc_make_offline_workflow

* comment

* Fix bug

* CC complaint - there are some other, but these havent been changed by this PR

* CC

* Update pycbc/workflow/core.py

Co-authored-by: Tito Dal Canton <[email protected]>

* IH/TDC comments

* use warnings module

---------

Co-authored-by: Tito Dal Canton <[email protected]>
lpathak97 pushed a commit to lpathak97/pycbc that referenced this pull request Mar 13, 2024
* Make logging better for pycbc_make_offline_workflow

* comment

* Fix bug

* CC complaint - there are some other, but these havent been changed by this PR

* CC

* Update pycbc/workflow/core.py

Co-authored-by: Tito Dal Canton <[email protected]>

* IH/TDC comments

* use warnings module

---------

Co-authored-by: Tito Dal Canton <[email protected]>
acorreia61201 pushed a commit to acorreia61201/pycbc that referenced this pull request Apr 4, 2024
* Make logging better for pycbc_make_offline_workflow

* comment

* Fix bug

* CC complaint - there are some other, but these havent been changed by this PR

* CC

* Update pycbc/workflow/core.py

Co-authored-by: Tito Dal Canton <[email protected]>

* IH/TDC comments

* use warnings module

---------

Co-authored-by: Tito Dal Canton <[email protected]>
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.

3 participants