Skip to content

Optional Gaia server messages? #3196

@robertdstein

Description

@robertdstein

Right now I am using astroquery as a dependency for a package, and have doc tests that involve my module. These occasionally break, because of gaia status messages which get printed directly to stdout.

def get_status_messages(self):

That's fair enough, I think most users might want to see these messages by default. However, I would personally like to switch them off. So I try using the kwarg argument to switch them off:

from astroquery.gaia import GaiaClass
Gaia = GaiaClass(show_server_messages=False)

which makes use of:

if show_server_messages:

In theory that should work, but right at the bottom of the script defining the GaiaClass class, there is this line:

Gaia = GaiaClass()

That creates a GaiaClass object, and uses the default settings (i.e show_server_message=True). So, by time I've hit the line from astroquery.gaia import GaiaClass I already get the stdout message.

As a workaround I can send things to dev null for that one specific import line, but it seems to me like the show_server_message argument is not behaving as intended, so I thought I would create the github issue here first.

Options I can think of to fix this include be to using the python logger rather than print (then I can toggle the message on/off), have the default of the printing set by an environment level, or setting a default of show_server_message=False. Apologies if a discussion about this already exists.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions