API Documentation

File

class knps.File(filename)

File wrapper class. This wrapper class should be used when storing a file into a KGPLValue object.

Parameters
  • filename The absolute or relative path to the file .
Example
    import knps
    file = knps.File("picture.png")
    kgplvalue = knps.create_values(file, "a picture")

KGPLValue

class knps.KGPLValue(val, comment, user='anonymous', dependency=[], vid=None, verbose=False)

Python representation of a KGPLValue. Users should not user the constructor to create a KGPLValue object directly. Instead, use the create_value function described below.

Parameters
  • val The concrete value stored in the KGPLValue object.
  • comment A user-readable comment (of type str) associated with this KGPLValue object.
  • user Username of the owner of the KGPLValue object.
  • dependency A list consisting of the KGPL objects that this KGPLValue depended on.
  • vid The unique identifier assigned by the server.
  • verbose If set to true, more information is produced in the terminal. Otherwise, a succint description is printed when the construction succeeds.
getVid(self)

Return the vid

getConcreteVal(self)

Return the concrete value

create_label(self, label, comment)

Create a label to refer to this KGPLValue.

Parameters
  • label A label (of type str) identifier for the value. Consider use label as a
  • comment Descriptive comment for the label creation
Return

The KGPLVariable object that underlies the label

update_label(self, label, new_comment)

Update the input label with this KGPLValue

Parameters
  • label The label to be updated
  • comment Descriptive comment for the label update
Return

The KGPLVariable object that underlies the label

KGPLVariable

class knps.KGPLVariable(val_id, comment, vid, user='anonymous', timestamp=None)

Python representation of a KGPLVariable. Users should not user the constructor to create a KGPLVariable object directly. Instead, use the variable function described below.

Parameters
  • val_id The vid of the KGPLValue to be stored
  • comment A user-readable comment (of type str) associated with this KGPLVariable object.
  • vid The unique identifier assigned by the server.
  • user Username of the owner of the KGPLVariable object.
  • timestamp Timestamp of the variable creation
getVid(self)

Get the vid

Return
  • the vid of this KGPLVariable.
getValid(self)

Get the vid of the contained KGPLValue

Return
  • the vid of the KGPLValue this variable refers to.
refresh(self)

Synchronize with the server to get the newest state of the variable in case of users work on the same variable concurrently.

getConcreteVal(self)

Get the KGPLValue stored in this KGPLVariable object

Return
- The KGPLValue object stored in this variable

API Methods

knps.kgpl
create_value(val, comment, user='anonymous', dependency=[], verbose=False)

Create a KGPLValue based on the inputs and publish to the server.

Parameter
  • 'val' Concrete value to store (We currently support the following types: int, float, bool, list, dict, File, pandas.DataFrame, Relation)
  • 'comment' A human readable comment (of type str) associated with the value creattion
  • 'user' User name of the owner of the KGPLValue, the default value is anonymous
  • dependency A list consisting of the KGPL objects that this KGPLValue depended on. Each element in the list can be one of the three types: KGPLValue, KGPLVariable or Label. The default value is empty list.
  • verbose: If set to true, more information is produced in the terminal. Otherwise, a succint description is printed when the construction succeeds. The default value is False.
Return

A KGPLValue object constructed based on inputs

publish_new(val, comment, label=None, user='anonymous', dependency=[], verbose=False, label_comment='')

Create a KGPLValue based on the inputs and publish to the server, then create and return a label for this KGPLValue.

Parameter
  • val Concrete value to store (We currently support the following types: int, float, bool, list, dict, File, pandas.DataFrame, Relation)
  • comment A human readable comment (of type str) associated with the value creation
  • label A human readable name to refer to the new KGPLValue. The default value is None. In that case, a default label is generated by the server.
  • user User name of the owner of this operation, the default value is anonymous
  • dependency A list consisting of the KGPL objects that this KGPLValue depended on. Each element in the list can be one of the three types: KGPLValue, KGPLVariable or Label. The default value is empty list.
  • verbose: If set to true, more information is produced in the terminal. Otherwise, a succint description is printed when the construction succeeds. The default value is False.
  • 'label_comment' A human readable comment (of type str) associated with the label creation
Return

A KGPLVariable object constructed based on inputs

load_val(vid)

Fetch the KGPLValue of the corresponding vid

Parameter
  • vid The vid of the desired KGPLValue
Return

A KGPLValue object

publish_update(val, comment, label, user='anonymous', dependency=[], verbose=False, label_comment='')

Create a KGPLValue based on the inputs and publish to the server, then update and return the label for this KGPLValue.

Parameter
  • val Concrete value to store (We currently support the following types: int, float, bool, list, dict, File, pandas.DataFrame, Relation)
  • comment A human readable comment (of type str) associated with the value creation
  • label The label being updated
  • user User name of the owner of this operation, the default value is anonymous
  • dependency A list consisting of the KGPL objects that this KGPLValue depended on. Each element in the list can be one of the three types: KGPLValue, KGPLVariable or Label. The default value is empty list.
  • verbose: If set to true, more information is produced in the terminal. Otherwise, a succint description is printed when the construction succeeds. The default value is False.
  • 'label_comment' A human readable comment (of type str) associated with the label update
Return

A KGPLVariable object updated based on inputs

get_label_content(label)

Get the content underlying a label

Parameter
  • label The label being fetched
Return

A KGPLVariable object this label represents

get_history(kg_var)

Fetch the history information of a KGPLVariable object from server

Parameter
  • kg_var: KGPLVariable object whose history information is of interest
Return

A list of vids this variable has refered to. The first element is the newest state while the last element is the oldest state.

check_label_occupied(vid)

Check the server to determine if the label is occupied.

Parameter
  • vid The label name to check
changeNamespace(new_url)

change the namespace of the current program.

Parameter

new_url the new namespace

viewNamespace()

print the current namespace