Workgroups and Projects
The first step of using the iGrafx P360 Live Mining SDK will be to create a workgroup, using the credentials you copied from Process Explorer 360:
w_id = "<Your Workgroup ID>"
w_key = "<Your Workgroup KEY>"
api_url = "<Your Mining Platform API URL>"
auth_url = "<Your Mining Platform Auth URL>"
jdbc_url = "<Your JDBC URL>"
wg = igx.Workgroup(w_id, w_key, api_url, auth_url, jdbc_url)
The JDBC URL is used to connect to the database and do queries and operations on datasources.
Once the workgroup is created, you can access the list of
projects associated
with the workgroup through the get_project_list() method:
project_list = wg.get_project_list()
The list of project IDs associated with the workgroup can be accessed with:
project_id_list = [p.id for p in project_list]
A specific project ID can be accessed from the list by specifying its index:
project_id_list[0]
The project ID can also be found in the URL:
https://<Mining Platform URL>/workgroups/<Workgroup ID>/projects/<Project ID>/data
On top of that, if you already know the ID of the project you want to work with you can use:
my_project = wg.project_from_id("<Your Project ID>")
It is also possible to unarchive a project. A project is automatically archived after 2 weeks of inactivity.
my_project.unarchive()
Please note that for a given Workgroup it is possible to retrieve its metadata which includes its name, its creation date and expiration date and finally its data version. To retrieve the metadata of a Workgroup, you can use the following method:
wg_metadata = wg.get_workgroup_metadata
To retrieve the name, creation or expiration dates of the workgroup specifically, you may do as follows:
wg_metadata = wg.get_workgroup_metadata.get("name")
wg_metadata = wg.get_workgroup_metadata.get("creationDate")
wg_metadata = wg.get_workgroup_metadata.get("expirationDate")
Moreover, to retrieve the data version of the Workgroup, you may do as follows:
wg_data_version = wg.get_workgroup_data_version
It is also possible to retrieve the app version:
wg_app_version = wg.get_app_version()
Once you have the project you want to use, several actions can be taken.
You can check if the project existsand get its name:
my_project.exists
my_project.get_project_name()
Furthermore, the column mapping of a project can be retrieved:
my_project.get_column_mapping()
This method returns the entirety of the column mapping of a project in a JSON format (as shown directly below). This JSON can directly be used to add a column mapping, and thus to add a file. For more details on how to add a column mapping using a JSON, view the next section.
{
"col1": {"name": "case_id", "columnIndex": "0", "columnType": "CASE_ID"},
"col2": {"name": "task_name", "columnIndex": "1", "columnType": "TASK_NAME"},
"col3": {"name": "time", "columnIndex": "2", "columnType": "TIME", "format": "yyyy-MM-dd'T'HH:mm"}
}
More precisely, the mapping infos of the project can be retrieved:
my_project.get_mapping_infos()
The list of available lookups for the project can also be retrieved:
my_project.get_project_lookups()
An example of what will be returned is the following:
[
{
"name": "be755cbe-1c70-46b7-ac60-f09478a122e6_excluded_cases",
"description": "string",
"usage": "SELECT LOOKUP(graphkey, 'be755cbe-1c70-46b7-ac60-f09478a122e6_variants') from \"be755cbe-1c70-46b7-ac60-f09478a122e6\""
}
]
You may then use the lookups as you desire.
The project can also be deleted:
my_project.delete_project()
Its variants and completed cases can also be retrieved:
my_project.get_project_variants(<Page Index>, <Limit>, "<Search>" )
my_project.get_project_completed_cases(<Page Index>, <Limit>, "<Search Case ID>")
Where Page Index is the page index for pagination, Limit is the maximum number of items to return per page,
Search is the search query to filter variants by name (optional) and Search Case ID is the search
query to filter cases by ID (also optional).
Moreover, you can reset the project if needed:
my_project.reset
Alternatively, if you wish to create your own project, you can do so as follows:
w = Workgroup(w_id, w_key, api_url, auth_url, jdbc_url)
project_name = "<Your Project name>"
project_description = "<Your Project description>"
created_project = w.create_project(project_name, project_description)
Note that the description is optional. If not needed, you can do the following:
created_project = w.create_project(project_name)