Server-side usage of arupcomputepy
arupcomputepy
in it's default form may not work when deployed onto a server. To help fix potential issues, the Connection
object can take a set of options through a class called ServerConfig
.
The ServerConfig
class
The ServerConfig
class provides various options that may be useful for server-side usage of arupcomputepy
. These options are provided below
Name | Description | Default |
---|---|---|
logger | An option to provide your own logger to the python client. This logger must follow the interface of the default python logger | None |
authFallback | For use when a clientId and clientSecret are being provided when trying to authenticate with arupcomputepy . If set to True then in cases where the id and secret cannot be found, arupcomputepy will attempt to use interactive mode to authenticate, if set to False then arupcomputepy will raise an exception if it cannot find the id and secret in the environment variables | True |
local | Whether to attempt to use Arup Compute Local. If running on a server then Arup Compute Local will likely never be able to be used. arupcomputepy will never fail due to Compute Local not being installed as it will fallback to using remote when it cannot find Local. However, telling arupcomputepy to never use Compute Local, by setting local to False can save time | True |
Example use
To use, create an instance of the ServerConfig
class, and pass it into Connection
when creating your instance of that class.
serverConfig = arupcomputepy.ServerConfig(logger=logging, authFallback=False, local=False)
connection = arupcomputepy.Connection(jobNumber, serverConfig=serverConfig)
calcID = 8389742 # Sample Library v2.1.60 Examples.BasicUse > Basic Calc https://compute.arup.digital/calcs/2081643
variables = {
'ID': 1,
'A': 2,
'B': 3
}
response = arupcomputepy.MakeCalculationRequest(connection, calcID, isBatch=False, variables=variables, resultType='simple')
Another example showing set up of basic logger can be found in the arupcomputepy
Examples folder.