class_docstr: Contains information about accounts.
  `path`: Path to sqlite file where the information about accounts is stored.
docstr: Update account except `api_key`. Only an admin or the owner of the account can update.
docstr_tok: ["Update","account","except","`","api_key","`",".","Only","an","admin","or","the","owner","of","the","account","can","update","."]
code: def update_account(
      self, auth: Authentication, account: Account
  ) -> Account:
      """
      Update account except `api_key`. Only an admin or the owner of the account can update.
      """
      with SqliteDict(self.path) as cache:
          self._authenticate_with_cache(auth, cache)
  
          # Check that the account we're updating exists.
          if account.api_key not in cache:
              raise ValueError(
                  f"Account with API key {account.api_key} does not exist."
              )
  
          editor: Account = from_dict(Account, cache.get(auth.api_key))
          current_account: Account = from_dict(
              Account, cache.get(account.api_key)
          )
  
          if not editor.is_admin and editor.api_key != account.api_key:
              raise AuthenticationError(
                  f"A user with API key {auth.api_key} attempted to edit an account that doesn't belong to them."
              )
  
          current_account.description = account.description
          current_account.emails = account.emails
          current_account.groups = account.groups
  
          if editor.is_admin:
              current_account.is_admin = account.is_admin
  
              # `used` field in any Usage is immutable, so copy current values of used
              usages = copy.deepcopy(account.usages)
              for service_key, service in usages.items():
                  for granularity_key, granularity in service.items():
                      if (
                          service_key in current_account.usages
                          and granularity_key
                          in current_account.usages[service_key]
                      ):
                          current_used: int = current_account.usages[
                              service_key
                          ][granularity_key].used
                          usages[service_key][
                              granularity_key
                          ].used = current_used
              current_account.usages = usages
  
          cache[account.api_key] = asdict(current_account)
          cache.commit()
          return current_account
  
imports: import copy
  import datetime
  import random
  import string
  from typing import Dict, Optional, Callable, List
  from dacite import from_dict
  from dataclasses import asdict, dataclass, field
  from sqlitedict import SqliteDict
  from helm.common.authentication import Authentication
  from helm.common.general import hlog
label_desc: Use image node_id 12 for calling the Accounts obj's underlying member method code with example usage: obj.update_account(auth, account) and returns: current_account