Installation#
neat is distributed as a Python package. It is organized into two modules:
- core: holds definition of objects (conceptual and physical data model, and instances), and ETL operations on these objects, accompanied with helper operations such as the objects' analysis and provenance.
- session: is a notebook (user) interface for the core.
neat is used primarily in a notebook environment such as, for example,
Jupyter Notebooks. Another notebook environment is the CDF notebooks.
CDF Notebooks Environment#
CDF Notebooks are a part of the Cognite Data Fusion (CDF) platform. These notebooks are a great way to get started with
neat, even if you have no coding experience.
Limitations
CDF Notebooks are running in your browser. This have some limitations compared to running neat locally. The
main difference is that locally neat can use a more powerful graph storage oxigraph . This means that if you are working
with large amounts of instances, you might want to consider running neat locally.
- Go to Cognite Data Fusion
- Login to your account
- Ensure you have selected the
Data Managementworkspace. - Select
Build solutionsin your left menubar. - Click on
Jupyter Notebooksunder the expandedBuild solutionsmenu. - Launch a new notebook.
- Install
cognite-neatby running%pip install cognite-neatin a cell. - Import
NeatSessionandCogniteClientand start using it as shown below
from cognite.client import CogniteClient
from cognite.neat import NeatSession
client = CogniteClient()
neat = NeatSession(client)
# Start using neat by typing neat.<TAB>
Local Notebook Environment#
Running neat locally requires a Python environment as well as a notebook environment. The following steps will
guide you through the installation process using Jupyter Lab as the notebook environment.
Prerequisites: Installed Python 3.10 or later, see python.org
- Create and enter directory for
neatinstallation - Create a virtual environment:
- Activate your virtual environment
- Install
cognite-neat - Install a notebook environment,
pip install jupyterlab - Install tqdm for progress bars,
pip install tqdm - Start your notebook environment,
jupyter lab - Import
NeatSessionandget_cognite_clientand start using it
In a notebook cell, you can now import NeatSession and get_cognite_client and start using it as shown below
from cognite.neat import NeatSession, get_cognite_client
client = get_cognite_client(".env")
neat = NeatSession(client)
# Start using neat by typing neat.<TAB>
Helper get_cognite_client function
The get_cognite_client function is a helper function that reads the environment variables from a .env file
and creates a CogniteClient instance. This is a common pattern when working with Cognite Data Fusion through
Python. Note that if you don't have a .env file, it will prompt you to enter environment variables
interactively and offer to save them to a .env file. You can instantiate a CogniteClient instance directly
if you prefer.