Tutorial: Get Tamr version¶
This tutorial will cover basic Python client usage by guiding you through:
Configuring the connection to a Tamr instance
Retrieving the version of that instance
To complete this tutorial you will need:
access to a Tamr instance, specifically:
a username and password that allow you to log in to Tamr
the socket address of the instance
The socket address is composed of
The protocol, such as
The host, which may be
"localhost"if the instance is deployed from the same machine from which your Python code will be run
The port at which you access the Tamr user interface, typically
When you view the Tamr user interface in a browser, the url is
<protocol>://<host>:<port>. If the port is missing, the URL is simply
The Tamr Python client uses a
Session to persist the user’s authentication details across requests made to the server where Tamr is hosted.
Session carries authentication credentials derived from a username and password, and is not explicitly tied to any single Tamr instance. For more details, see the documentation for the Requests library.
Use your username and password to create an instance of
Use the function
tamr_client.session.from.authto create a
from getpass import getpass import tamr_client as tc username = input("Tamr Username:") password = getpass("Tamr Password:") auth = tc.UsernamePasswordAuth(username, password) session = tc.session.from_auth(auth)
Instance models the installation or instance of Tamr with which a user interacts via the Python client.
portof your Tamr instance.
protocol = "http" host = "localhost" port = 9100 instance = tc.Instance(protocol=protocol, host=host, port=port)
Getting the version of Tamr¶
Instance defined, you can now interact with the API of the Tamr instance. One simple example is fetching the version of the Tamr software running on the server.
Use the function
tc.instance.versionand print the returned value.
All of the above steps can be combined into the following script
from getpass import getpass import tamr_client as tc username = input("Tamr Username:") password = getpass("Tamr Password:") auth = tc.UsernamePasswordAuth(username, password) session = tc.session.from_auth(auth) protocol = "http" host = "localhost" port = 9100 instance = tc.Instance(protocol=protocol, host=host, port=port) print(tc.instance.version(session, instance))
To run the script via command line:
TAMR_CLIENT_BETA=1 python get_tamr_version.py
If successful, the printed result should be similar to
Congratulations! This is just the start of what can be done with the Tamr Python client.
To continue learning, see other tutorials and examples.