Getting started
It is recommended to use VS Code and venv
to set up your python development environment. Setup guide for Python and VS Code.
Installation
arupcomputepy
can be installed via pip from the Arup python packages server or from the GitHub repo.
Install via pip from the packages server using the command:
pip install https://packages.arup.com/arupcomputepy.tar
You will need to be on the VPN to access the Arup python packages server
Install via pip from the GitHub repo using the command:
pip install git+https://github.com/arup-group/arupcomputepy.git
You will need to have Git installed for this command to work
Example usage
A python code snippet is auto-generated for every function on ArupCompute to make getting started with a new function easier, just click on the 'Python' tab.
# import the libraries we need
import arupcomputepy
# set up our connection ArupCompute
jobNumber = '00000000' # for testing only - please use a real job number
connection = arupcomputepy.Connection(jobNumber)
# Set calculation details and inputs
calcID = 6641609 # Sample Library v2.1.76 Examples.BasicUse > Basic Calc https://compute.arup.digital/calcs/6641609
variables = {
'a': 1,
'b': 2
}
# Send off to ArupCompute
response = arupcomputepy.MakeCalculationRequest(connection, calcID, isBatch=False, variables=variables)
print(response)
The calcID, which is unique to each calculation version (ie. changes every time a library version is published), can be easily found in the URL of the ArupCompute Web UI
Example usage with persistent calc ID
AC Calculations can be referenced with their persistent calc ID (UUID), instead of their calc ID, which is specific to a library version and must be updated to access each new library version.
# Note that we will refer to our calculation using its persistent ID (UUID)
# DesignCheck2 > Examples > SimpleCalculation
persistentCalcId = "b408ee23-2cfb-32fa-a107-4606a70b6069"
# To execute a calculation using its persistent calcID (UUID) we need to refer to the calc by its UUID instead of its library version based calc ID
# We can assign the UUID value to the persistentCalcId parameter
# By default, ArupCompute will lookup and execute the latest available stable version
# of the calculation
response = arupcomputepy.MakeCalculationRequest(
connection,
persistentCalcId=persistentCalcId,
isBatch=False,
variables=variables
)
# We can also specify version criteria for the calc we want to look up with persistent
# ID by providing major, minor and patch version information. Remember that we use semver
# to describe our versions, so a change in major version corresponds to a breaking change.
# Say we have a script set up to specifically use the 1.x.x version of our calculation
# (ie. compatible with minor and patch changes). We can pass a major version of 1 to make
# sure we fetch and execute only the latest calc with a major revision of 1
# (ignoring newer major versions of the calc if they exist)
response = arupcomputepy.MakeCalculationRequest(
connection,
persistentCalcId=persistentCalcId,
isBatch=False,
variables=variables,
major=1
)
The persistent calcID, or calc UUID, is unique to each calculation but remains constant across library versions. It can be easily found on the ArupCompute Website in the information tab of each calculation:
Further examples (including batch execution, creating pdfs, and working with objects) can be found in the arupcomputepy
Examples folder.
Next steps
The above example is simple, but there are many more useful calculations hosted on ArupCompute that can be accessed just as easily:
- Explore the ArupCompute website to find out which calculation you are interested in
- Trial it via the web interface
- Integrate the ArupCompute calculations into your python workflows
Further reading
There are more ways to make use of arupcomputepy
, find out more in our how-to guides.
Or you may wish to use the reference documentation to find exhaustive details.