Client

Module that expose the base class for DIRAC Clients.

This class exposes possible RPC calls, given a url of a service.

class DIRAC.Core.Base.Client.Client(**kwargs)

Bases: object

Simple class to redirect unknown actions directly to the server. Arguments to the constructor are passed to the RPCClient constructor as they are. Some of them can however be overwritten at each call (url and timeout).

  • The self.serverURL member should be set by the inheriting class

__init__(**kwargs)

C’tor.

Parameters:

kwargs – just stored as an attribute and passed when creating the RPCClient

property call

To be removed once we’re sure self.call has been removed

Type:

Deprecated

executeRPC(*parms, **kws)

This method extracts some parameters from kwargs that are used as parameter of the constructor or RPCClient. Unfortunately, only a few of all the available parameters of BaseClient are exposed.

Parameters:
  • rpc – if an RPC client is passed, use that one

  • timeout – we can change the timeout on a per call bases. Default is self.timeout

  • url – We can specify which url to use

getClientKWArgs()

Returns a copy of the connection arguments

getServer()

Getter for the server url. Useful ?

httpsClient

alias of TornadoClient

setServer(url)

Set the server URL used by default

Parameters:

url – url of the service

DIRAC.Core.Base.Client.createClient(serviceName)

Decorator to expose the service functions automatically in the Client.

Parameters:

serviceName (str) – system/service. e.g. WorkloadManagement/JobMonitoring

DIRAC.Core.Base.Client.executeRPCStub(rpcStub)

Playback a stub with the correct client (https or dips)

class DIRAC.Core.Base.Client.partialmethodWithDoc(func, /, *args, **keywords)

Bases: partialmethod

Extension of meth:functools.partialmethod that preserves docstrings

__init__(func, /, *args, **keywords)

Initialization

Before clients can be used DIRAC’s internal state must be configured. For dirac- commands this is handled by DIRAC.Core.Base.Script.Script. For all other purposes DIRAC.initialize should be used:

DIRAC.initialize(*, require_auth: bool = True, security_expression: None | SecurityProperty | UnevaluatedProperty = None, log_level: LogLevel | None = None, extra_config_files: list[PathLike] | None = None, extra_config: dict[str, Any] | None = None, host_credentials: tuple[PathLike, PathLike] | None = None) None

Prepare the global state so that DIRAC clients can be used.

This method needs to be called before any DIRAC client is created to ensure that the necessary global state is configured.

Raises:

DIRAC.Core.Utilities.exceptions.DIRACInitError – If initialization fails. (or a subclass thereof) is raised.

Parameters:
  • require_auth – Set to False to skip the authentication check.

  • security_expression – Check that the current credentials have the required properties. See SecurityProperty for details.

  • log_level – Override the default DIRAC logging level.

  • extra_config_files – Files to merge into the local configuration.

  • extra_config – Dictionary to merge into the local configuration.

  • host_credentials – Tuple of (host certificate, host key) to force the use of server certificate credentials.