Command Line vs PythonΒΆ
Developers building off the pwfdf-api package may wonder whether to build off of the command line or Python interface. When possible, we recommend building off of the Python interface, as this provides various development options not available from the command line. As discussed on the logging page, the logging streams and format can be customized within a Python session, but are fixed when run from the command line. The command line interface also suppresses error tracebacks by default, setting the global sys.tracebacklimit to 0. By constrast, the Python commands do not alter this setting, so display error messages as normal.
Finally, the Python interface allows developers to address Exceptions not handled by the pwfdf-api. For example, you could use something like the following to retry an API query when the ScienceBase server times out:
from pwfdf_api.errors import ScienceBaseConnectTimeout
from pwfdf_api import assessments
try:
output = assessments(timeout=15)
except ScienceBaseConnectTimeout:
output = assessments(timeout=60)