Skip to content

Heartbeat#294

Closed
eendebakpt wants to merge 14 commits intomasterfrom
heartbeat
Closed

Heartbeat#294
eendebakpt wants to merge 14 commits intomasterfrom
heartbeat

Conversation

@eendebakpt
Copy link
Contributor

Fixes #98, #265 (logging, debugging), #172

Changes proposed in this pull request:

  • Add a submodule qcodes.config
  • Add a ZMQ logging gui
  • Add logging handlers that send messages over ZMQ
  • Add a heartbeat option to the server process

The PR is not ready for inclusion into master, but before making it complete (docs, tests) I would like to discuss some aspects:

  • The logging GUI is completely standalone. I want it that way, so the logging can always continue to run, no matter what happens in the main process
  • For communication ZMQ is used. It is an additional dependency, but one that is well known and installs out of the box
  • The adding of logging handlers is optional, for the final PR I suggest to set the default to 0
  • The config system is only a stub. Making a complete config system is something for another PR.
  • To make the heartbeat work I set the timeout in the run_event_loop to 5 seconds. This should be made configurable again, but I am not sure about the best with. With the old default None, the heartbeat does not work.
  • By default the qcodes module is not loaded in any subprocesses. Therefore to make sure the heartbeat starts in the subprocces I create an instrument like
class DummyInstrument(Instrument):

    def __init__(self, name='dummy', gates=['dac1', 'dac2', 'dac3'], **kwargs):
        super().__init__(name, **kwargs)

        # manual load
        from qcodes.utils.loggingGUI import installZMQlogger
        qlogger=installZMQlogger()

        logging.info('create DummyInstrument')
        self.add_parameter('test',
                               get_cmd=self.getfunc,
                               vals=Numbers())

    def getfunc(self):
        logging.info('DummyInstrument: getfunc')
        return os.getpid()

I am not sure why the qcodes module is not automatically loaded.

@alexcjohnson @giulioungaretti @MerlinSmiles

@qcodes-bot
Copy link

Codacy Here is an overview of what got changed by this pull request:

Issues
======
- Added 2


Complexity increasing per file
==============================
- qcodes/utils/loggingGUI.py  3

See the complete overview on Codacy

RESPONSE_OK = 'OK'
RESPONSE_ERROR = 'ERROR'

from qcodes import config

Choose a reason for hiding this comment

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

@giulioungaretti
Copy link
Contributor

@eendebakpt @peendebak going through this as it is really relevant to general architecture.
How does the workflow looks like?
I see a main which looks like it's the gui?
Is the logging acutally I/O bound ? I.e what happens if one pushes too many messages?

@peendebak
Copy link
Contributor

@giulioungaretti

  1. The GUI is in loggingGUI.py. This should be started separately from the session with qcodes.

In the qcodes process a hook an be installed in the logging module with installZMQlogger. This hook makes sure all logging messages are published (using ZMQ). The GUI acts as a subscriber to receive the messages.

The ZMQ logging hook is automatically started for instruments on a server (see run_event_loop around line 298).

  1. The heartbeat is a mechanism to make sure we can always kill a process started by qcodes. To do this functionality is added to the run_event_loop that checks a special file on disk. For a separate python session this file can be modified such that all processes close themselves (https://github.com/qdev-dk/Qcodes/pull/294/files#diff-f1073d02245e5798e2dcd0033f6fdc7dR310)

Note: I do not use the heartbeat any more. By the logging I know the pid of each process, so I can kill them using the normal operating commands or a button in the logging GUI.

I suggest we split this PR and add the logging hook (and config system PR308) to master. The heartbeat code can wait I think.

@giulioungaretti
Copy link
Contributor

how is your QT button killing the process still via kill pid ?
cool about the PR , let's talk about this in slack.

@peendebak peendebak mentioned this pull request Sep 2, 2016
@peendebak peendebak closed this Sep 2, 2016
@giulioungaretti giulioungaretti deleted the heartbeat branch February 9, 2017 09:33
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.

4 participants