Giter VIP home page Giter VIP logo

Comments (7)

ewinston avatar ewinston commented on May 9, 2024 1

Hi @hellmersjl3ds,
Thanks for offering to have a look at this. In PR#108, referenced in this PR, the python logging facility was setup and covers most of the features requested in this enhancement. One thing I think that remains to be done, however, is that the facility has not been applied everywhere (there are still print statements for instance). If you could help make the logging uniform or suggest any other improvements that would be great. For extensive changes you could open a new issue for discussion or continue using this one.

from qiskit.

hellmersjl3ds avatar hellmersjl3ds commented on May 9, 2024 1

Hey guys, unfortunately I'm busy with another project for the next 5 weeks or so, so I won't be able to get to this before then.

from qiskit.

hellmersjl3ds avatar hellmersjl3ds commented on May 9, 2024

What's the status of this? I see a commit from @ewinston but it's not assigned to anyone.

I'd be happy to work on it if nobody else is.

from qiskit.

1ucian0 avatar 1ucian0 commented on May 9, 2024

Not every print call in the code should be replaced by log. Some of them need a thought. Following, a list of files in 0.4, with prints in it, and some comments for some of the cases:

  • qiskit/tools/visualization.py
  • qiskit/tools/qi/qi.py
  • qiskit/tools/qi/pauli.py
  • qiskit/tools/apps/optimization.py
  • qiskit/unroll/_printerbackend.py (probably makes sense to add a file parameter, a la build-in print )
  • qiskit/qasm/_qasmlexer.py: the print call in t_error maybe is an Exception (?)
  • qiskit/qasm/_node/*.py: Many prints happen in to_string methods. This method should return a string instead of printing (maybe should be called __str__)
  • qiskit//qasm/_qasmparser.py: The exception should be re-raised.

Currently, the testsuite do not print any of these issues (I think, it could be that the output is captured in some cases). For sure, tests are needed when performing many of these changes.

This is a very nice opportunity for a first contribution. If anybody wants to work with it and need assistance, let me know! (<- @hellmersjl3ds)

from qiskit.

atilag avatar atilag commented on May 9, 2024

Not every print call in the code should be replaced by log.

The problem of using print()statements, is that it forces the user to dump something to the stdout (usually the monitor), but this is not true for many other uses cases that printing to stdout doesn't make any sense like:

  • Graphics User Interfaces (Windows apps, Mac apps, XWindows apps)
  • Non-Attended devices
  • *nix Daemons and Services
  • ... and probably many others I'm not aware of...

We are building an SDK, so using print() is killing many use-cases we don't really want to kill.
So, basically, yes, we should replace al the prints in the code by log :)
Notice that our logger can dump to stdout like print always does, if the user requires to do so... not sure if we are exposing this functionality to the user at the moment, though.

from qiskit.

1ucian0 avatar 1ucian0 commented on May 9, 2024

Some of the prints I mentioned are messages for an exception, for example.

from qiskit.

atilag avatar atilag commented on May 9, 2024

Ok, so after some PRs... we have included the logging system and we have removed all silent flags.
Still need to remove all presence of print() in the code, but we will create another issue to address this specific issue.
I'm going to close this Issue.

from qiskit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.