Skip to content

Overview

This is the base application that all others should inherit from, and extend where needed. You can see examples of this in segmeneter/accounts.py where we inherit, and extend, the base functionality of the Account class and the AccountList.

However, it must be noted: this pattern has been used incorrectly where a developer added BaseSingleAccountList, which was specifically for the Visscore system, to dps/accounts.py. This is not wrong in its self (though the name is incorrect, how can a Single item also be a List ?), but the functions added to it are specifically ONLY for the Visscore systems. Also it has can_poll which is for the SQS queues, and now this class is bound to that logic, which is wrong.

The correct way to have done this would have been to add to the DPS project, something like:

class SingleAccountManager(Account):
    def __init__(self, server):
        self.server = server
        self.account_token = self.get_account_token()
        super().__init__(server)

    @tag_state('pulling_account')
    @metrics.get_account_token.time
    def get_account_token(self):
        return "account_token"

And then in the visscore/accounts.py done this:

from pydps.accounts import SingleAccountManager 

class VisscoreAccount(SingleAccountManager)

    def __init__(self, server):
        super().__init__(server) 
        self.can_poll = {'main' : False, 'retry' : False}

    def loop(self):
        # do all the things it needs to do

This is not 100% complete, please do not update the code with these changes. This is here to show how it should have been done. For this to work the concept in Server needs to be changed to not "loop" an AccountList but just manage SingleAccountManager. To continue this example, this means visscore/server.py should of had its logic changed to deal with having only 1 account.