SLIPO Client for Jupyter notebooks¶
SLIPO API client wrapper.
This class provides methods for accessing SLIPO API functionality from Jupyter notebooks
-
class
slipoframes.context.
SlipoContext
(api_key: str, base_url: str = None, requires_ssl: bool = True)[source]¶ A class that wraps
Client
object.- Parameters
api_key (str) – SLIPO API key.
base_url (str, optional) – Base URL for SLIPO API endpoints. The default value is
https://app.dev.slipo.eu/
.requires_ssl (bool, optional) – If False, unsecured connections are allowed (default True).
- Returns
A
SlipoContext
object.
-
file_browse
(sort_col: str = 'modified', sort_asc: bool = True, format_size: bool = False) → pandas.core.frame.DataFrame[source]¶ Browse all files and folders on the remote file system.
- Parameters
sort_col (str) – Sorting column name (default modified).
sort_asc (bool, optional) – Sets ascending sort order (default True).
format_size (bool, optional) – If True, the file size is converted to a user friendly string (default False).
- Returns
A
pandas.DataFrame
with all files- Raises
SlipoException – If a network or server error has occurred.
-
file_download
(source: str, target: str, overwrite: bool = False) → None[source]¶ Download a file from the remote file system.
- Parameters
source (str) – Relative file path on the remote file system.
target (str) – The path where to save the file.
overwrite (bool, optional) – Set true if the operation should overwrite any existing file.
- Raises
SlipoException – If a network, server error or I/O error has occurred.
-
file_upload
(source: str, target: str, overwrite: bool = False) → None[source]¶ Upload a file or folder to the remote file system.
When a folder is being copied, only the files of the folder are copied while any sub-folders are ignored.
Note
File size constraints are enforced on the uploaded file. The default installation allows files up to 20 Mb.
Moreover, space quotas are applied on the server. The default user space is 5GB.
Directory nesting constraints are applied for the
target
value. The default installation allows nesting of directories up to 5 levels.- Parameters
source (str) – The path of the file to upload.
target (str) – Relative path on the remote file system where to save the file. If the directory does not exist, it will be created.
overwrite (bool, optional) – Set true if the operation should overwrite any existing file.
- Raises
SlipoException – If a network, server error or I/O error has occurred.
-
catalog_query
(term: str = None, pageIndex: int = 0, pageSize: int = 10) → pandas.core.frame.DataFrame[source]¶ Query resource catalog for RDF datasets.
- Parameters
term (str, optional) – A term for filtering resources. If specified, only the resources whose name contains the term are returned.
pageIndex (str, optional) – Page index for data pagination.
pageSize (str, optional) – Page size for data pagination.
- Returns
A
pandas.DataFrame
with the selected resources- Raises
SlipoException – If a network or server error has occurred.
-
catalog_download
(resource_id: int, target: str) → None[source]¶ Download resource to the local file system
- Parameters
resource_id (int) – The resource id.
target (str) – The path where to save the file.
- Raises
SlipoException – If a network, server error or I/O error has occurred.
-
process_query
(term: str = None, pageIndex: int = 0, pageSize: int = 10) → pandas.core.frame.DataFrame[source]¶ Query workflow instances.
- Parameters
term (str, optional) – A term for filtering workflows. If specified, only the workflows whose name contains the term are returned.
pageIndex (str, optional) – Page index for data pagination (default 0).
pageSize (str, optional) – Page size for data pagination (default 10).
- Returns
A
pandas.DataFrame
with the selected processes- Raises
SlipoException – If a network or server error has occurred.
-
process_save
(process_id: Union[int, slipoframes.model.Process]) → slipoframes.model.Process[source]¶ Creates a new version for the specified workflow. The most recent version of the workflow is copied.
-
process_status
(process_id: Union[int, slipoframes.model.Process], process_version: int = None, format_size: bool = False) → slipoframes.model.Process[source]¶ Check the status of a workflow execution instance and return all execution files.
- Parameters
- Returns
A new instance of
Process
class.- Raises
SlipoException – If a network or server error has occurred.
-
process_start
(process_id: Union[int, slipoframes.model.Process], process_version: int = None) → slipoframes.model.Process[source]¶ Start or resume execution of a workflow instance.
- Parameters
- Returns
A new instance of
Process
class.- Raises
SlipoException – If a network or server error has occurred.
-
process_stop
(process_id: Union[int, slipoframes.model.Process], process_version: int = None) → None[source]¶ Stop a running workflow execution instance.
-
process_file_download
(process_id: Union[int, slipoframes.model.StepFile], process_version: int = None, file_id: int = None, target: str = None, overwrite: bool = False) → None[source]¶ Download an input or output file for a specific workflow execution instance.
- During the execution of a workflow the following file types may be created:
CONFIGURATION
: Tool configurationINPUT
: Input fileOUTPUT
: Output fileSAMPLE
: Sample data collected during step executionKPI
: Tool specific or aggregated KPI dataQA
: Tool specific QA dataLOG
: Logs recorded during step execution
- Parameters
process_id (Union[int, StepFile]) – The process id or an instance of
StepFile
. If a file object is specified, process_version and file_id arguments are ignored.process_version (int, optional) – The process revision.
file_id (int, optional) – The file id.
target (str) – The path where to save the file.
overwrite (bool, optional) – Set true if the operation should overwrite any existing file.
- Raises
SlipoException – If a network, server error or I/O error has occurred.
-
process_render
(process: slipoframes.model.Process) → IPython.core.display.HTML[source]¶ Render a process as a directed acyclic graph (DAG)
-
profiles
() → pandas.core.frame.DataFrame[source]¶ Get the profiles of all SLIPO Toolkit components.
- Returns
A
pandas.DataFrame
with the profiles of all SLIPO Toolkit components.- Raises
SlipoException – If a network or server error has occurred.
-
transform_csv
(path: str, **kwargs) → slipoframes.model.Process[source]¶ Transforms a CSV file to a RDF dataset.
- Parameters
path (str) – The relative path for a file on the remote user file system.
**kwargs –
Keyword arguments to control the transform operation. Options are:
attrCategory (str, optional): Field name containing literals regarding classification into categories (e.g., type of points, road classes etc.) for each feature.
attrGeometry (str, optional): Parameter that specifies the name of the geometry column in the input dataset.
attrKey (str, optional): Field name containing unique identifier for each entity (e.g., each record in the shapefile).
attrName (str, optional): Field name containing name literals (i.e., strings).
attrX (str, optional): Specify attribute holding X-coordinates of point locations. If inputFormat is not CSV, the parameter is ignored.
attrY (str, optional): Specify attribute holding Y-coordinates of point locations. If inputFormat is not CSV, the parameter is ignored.
classificationSpec (str, optional): The relative path to a YML/CSV file describing a classification scheme.
defaultLang (str, optional): Default lang for the labels created in the output RDF (default: en).
delimiter (str, optional): Specify the character delimiting attribute values.
encoding (str, optional): The encoding (character set) for strings in the input data (default: UTF-8)
featureSource (str, optional): Specifies the data source provider of the input features.
mappingSpec (str, optional): The relative path to a YML file containing mappings from input schema to RDF according to a custom ontology.
profile (str, optional): The name of the profile to use. Profile names can be retrieved using
profiles()
method. If profile is not set, the mappingSpec parameter must be set.quote (str, optional): Specify quote character for string values.
sourceCRS (str, optional): Specify the EPSG code for the source CRS (default: EPSG:4326).
targetCRS (str, optional): Specify the EPSG code for the target CRS (default: EPSG:4326).
- Returns
A new instance of
Process
class.- Raises
SlipoException – If a network or server error has occurred.
-
transform_shapefile
(path: str, **kwargs) → slipoframes.model.Process[source]¶ Transforms a SHAPEFILE file to a RDF dataset.
- Parameters
path (str) – The relative path for a file on the remote user file system.
**kwargs –
Keyword arguments to control the transform operation. Options are:
attrCategory (str, optional): Field name containing literals regarding classification into categories (e.g., type of points, road classes etc.) for each feature.
attrGeometry (str, optional): Parameter that specifies the name of the geometry column in the input dataset.
attrKey (str, optional): Field name containing unique identifier for each entity (e.g., each record in the shapefile).
attrName (str, optional): Field name containing name literals (i.e., strings).
classificationSpec (str, optional): The relative path to a YML/CSV file describing a classification scheme.
defaultLang (str, optional): Default lang for the labels created in the output RDF (default: en).
encoding (str, optional): The encoding (character set) for strings in the input data (default: UTF-8)
featureSource (str, optional): Specifies the data source provider of the input features.
mappingSpec (str, optional): The relative path to a YML file containing mappings from input schema to RDF according to a custom ontology.
profile (str, optional): The name of the profile to use. Profile names can be retrieved using
profiles()
method. If profile is not set, the mappingSpec parameter must be set.sourceCRS (str, optional): Specify the EPSG code for the source CRS (default: EPSG:4326).
targetCRS (str, optional): Specify the EPSG code for the target CRS (default: EPSG:4326).
- Returns
A new instance of
Process
class.- Raises
SlipoException – If a network or server error has occurred.
-
interlink
(profile: str, left: Union[str, Tuple[int, int], Tuple[int, int, int], slipoframes.model.StepFile], right: Union[str, Tuple[int, int], Tuple[int, int, int], slipoframes.model.StepFile]) → slipoframes.model.Process[source]¶ Generates links for two RDF datasets.
Arguments left, right and links may be either:
A
str
that represents a relative path to the remote user file systemA
tuple
of two integer values that represents the id and revision of a catalog resource.A
tuple
of three integer values that represents the process id, process revision and output file id for a specific workflow or SLIPO API operation execution.A
StepFile
that represents the output of an operation.
- Parameters
profile (str) – The name of the profile to use. Profile names can be retrieved using
profiles()
method.left (Union[str, Tuple[int, int], Tuple[int, int, int], StepFile]) – The left RDF dataset.
right (Union[str, Tuple[int, int], Tuple[int, int, int], StepFile]) – The right RDF dataset.
- Returns
A new instance of
Process
class.- Raises
SlipoException – If a network or server error has occurred.
-
fuse
(profile: str, left: Union[str, Tuple[int, int], Tuple[int, int, int], slipoframes.model.StepFile], right: Union[str, Tuple[int, int], Tuple[int, int, int], slipoframes.model.StepFile], links: Union[str, Tuple[int, int], Tuple[int, int, int], slipoframes.model.StepFile]) → slipoframes.model.Process[source]¶ Fuses two RDF datasets using Linked Data and returns a new RDF dataset.
- Parameters
profile (str) – The name of the profile to use. Profile names can be retrieved using
profiles()
method.left (Union[str, Tuple[int, int], Tuple[int, int, int], StepFile]) – The left RDF dataset.
right (Union[str, Tuple[int, int], Tuple[int, int, int], StepFile]) – The right RDF dataset.
links (Union[str, Tuple[int, int], Tuple[int, int, int], StepFile]) – The links for the left and right datasets.
- Returns
A new instance of
Process
class.- Raises
SlipoException – If a network or server error has occurred.
-
enrich
(profile: str, source: Union[str, Tuple[int, int], Tuple[int, int, int], slipoframes.model.StepFile]) → slipoframes.model.Process[source]¶ Enriches a RDF dataset.
- Parameters
profile (str) – The name of the profile to use. Profile names can be retrieved using
profiles()
method.source (Union[str, Tuple[int, int], Tuple[int, int, int], StepFile]) – The RDF dataset to enrich.
- Returns
A new instance of
Process
class.- Raises
SlipoException – If a network or server error has occurred.
-
export_csv
(profile: str, source: Union[str, Tuple[int, int], Tuple[int, int, int], slipoframes.model.StepFile], **kwargs) → slipoframes.model.Process[source]¶ Exports a RDF dataset to a CSV file.
- Parameters
profile (str) – The name of the profile to use. Profile names can be retrieved using
profiles()
method.source (Union[str, Tuple[int, int], Tuple[int, int, int]) – The RDF dataset to export.
**kwargs –
Keyword arguments to control the transform operation. Options are:
defaultLang (str, optional): The default language for labels created in output RDF. The default is “en”.
delimiter (str, optional):A field delimiter for records (default: ;).
encoding (str, optional): The encoding (character set) for strings in the input data (default: UTF-8)
quote (str, optional): Specify quote character for string values (default “).
sourceCRS (str, optional): Specify the EPSG code for the source CRS (default: EPSG:4326).
sparqlFile (str, optional): The relative path to a file containing a user-specified SELECT query (in SPARQL) that will retrieve results from the input RDF triples. This query should conform with the underlying ontology of the input RDF triples.
targetCRS (str, optional): Specify the EPSG code for the target CRS (default: EPSG:4326).
- Returns
A new instance of
Process
class.- Raises
SlipoException – If a network or server error has occurred.
-
export_shapefile
(profile: str, source: Union[str, Tuple[int, int], Tuple[int, int, int], slipoframes.model.StepFile], **kwargs) → slipoframes.model.Process[source]¶ Exports a RDF dataset to a SHAPEFILE file.
- Parameters
profile (str) – The name of the profile to use. Profile names can be retrieved using
profiles()
method.source (Union[str, Tuple[int, int], Tuple[int, int, int], StepFile]) – The RDF dataset to export.
**kwargs –
Keyword arguments to control the transform operation. Options are:
defaultLang (str, optional): The default language for labels created in output RDF. The default is “en”.
delimiter (str, optional):A field delimiter for records (default: ;).
encoding (str, optional): The encoding (character set) for strings in the input data (default: UTF-8)
quote (str, optional): Specify quote character for string values (default “).
sourceCRS (str, optional): Specify the EPSG code for the source CRS (default: EPSG:4326).
sparqlFile (str, optional): The relative path to a file containing a user-specified SELECT query (in SPARQL) that will retrieve results from the input RDF triples. This query should conform with the underlying ontology of the input RDF triples.
targetCRS (str, optional): Specify the EPSG code for the target CRS (default: EPSG:4326).
- Returns
A new instance of
Process
class.- Raises
SlipoException – If a network or server error has occurred.