Skip to content

Commit

Permalink
v1.7 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
parkererickson-tg committed Aug 20, 2024
1 parent b94aa02 commit bb24113
Show file tree
Hide file tree
Showing 9 changed files with 172 additions and 72 deletions.
10 changes: 10 additions & 0 deletions generator/docstring2asciidoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,18 @@ def processTypes(node, colon: bool = True) -> str:
for t in child.elts:
partial += processTypes(t, False) + ", "
return cln + "Tuple[" + partial[:-2] + "]"
if node.value.id == "Dict":
partial = ""
for child in ast.iter_child_nodes(node):
if isinstance(child, ast.Tuple):
for t in child.elts:
partial += processTypes(t, False) + ", "
return cln + "Dict[" + partial[:-2] + "]"
else:
for child in ast.iter_child_nodes(node):
print(child)
return cln + "???4 " + str(type(node))
return ""


def processFunction(node, adocFile, h2s = False):
Expand All @@ -136,6 +144,8 @@ def processFunction(node, adocFile, h2s = False):
except:
raise(Exception("No docstring for {}".format(node.name)))

print("\tProcessing function {}".format(node.name))

if h2s:
adocFile.write("== {}".format(node.name if node.name != "__init__" else "\\__init__" if node.name != "__call__" else "\\__call__"))
else:
Expand Down
41 changes: 39 additions & 2 deletions modules/ai/pages/copilot.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
= AI Submodule

The AI submodule is used to interact with the TigerGraph CoPilot service.
It allows users to register custom queries, run natural language queries, and interact with the CoPilot service.

To use the AI submodule, you must first create a TigerGraphConnection object, and verify that you have a TigerGraph CoPilot service running.

For example, to use the AI submodule, you can run the following code:

[source,python]
----
from pyTigerGraph import TigerGraphConnection
conn = TigerGraphConnection(
host="https://YOUR_DB_ADDRESS",
graphname="DigitalInfra",
username="YOUR_DB_USERNAME",
password="YOUR_DB_PASSWORD"
)
conn.getToken()
conn.ai.configureCoPilotHost(hostname="http://COPILOT_ADDRESS")
conn.ai.query("How many servers are there?")
----

For a more detailed and varied examples, see the demo notebooks in the (TigerGraph CoPilot GitHub repository)[https://github.com/tigergraph/CoPilot/tree/main/copilot/docs/notebooks].

== configureInquiryAIHost()
`configureInquiryAIHost(hostname: str)`

Expand Down Expand Up @@ -166,19 +195,27 @@ JSON response from the question answer.


== forceConsistencyUpdate()
`forceConsistencyUpdate()`
`forceConsistencyUpdate(method = "supportai")`

Force a consistency update for SupportAI embeddings.
[discrete]
==== Parameter:
* `method (str)`: The doc initialization method to run
Currentlty only "supportai" is supported in CoPilot v0.9.
[discrete]
==== Returns:
JSON response from the consistency update.


== checkConsistencyProgress()
`checkConsistencyProgress()`
`checkConsistencyProgress(method = "supportai")`

Check the progress of the consistency update.
[discrete]
==== Parameter:
* `method (str)`: The doc initialization method to check or run.
Currentlty only "supportai" is supported in CoPilot v0.9.
[discrete]
==== Returns:
JSON response from the consistency update progress.

Expand Down
17 changes: 10 additions & 7 deletions modules/core-functions/pages/auth.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ See https://docs.tigergraph.com/tigergraph-server/current/user-access/managing-c

[discrete]
==== Returns:
If your TigerGraph instance is running version 3.5 or before, the return value is
If your TigerGraph instance is running version <=3.10, the return value is
a tuple of `(<token>, <expiration_timestamp_unixtime>, <expiration_timestamp_ISO8601>)`.
The return value can be ignored, as the token is automatically set for the connection after this call.

If your TigerGraph instance is running version 3.6 or later, the return value is just the token.
If your TigerGraph instance is running version 4.0, the return value is a tuple of `(<token>, <expiration_timestamp_with_local_time>).

[NOTE]
The expiration timestamp's time zone might be different from your computer's local time
Expand All @@ -111,13 +111,14 @@ error occurred.

[discrete]
==== Endpoint:
- `POST /requesttoken`
- `POST /requesttoken` (In TigerGraph versions 3.x)
+
See https://docs.tigergraph.com/tigergraph-server/current/api/built-in-endpoints#_request_a_token[this] for more details.
- `POST /gsql/v1/tokens` (In TigerGraph versions 4.x)


== refreshToken()
`refreshToken(secret: str, token: str = "", lifetime: int = None) -> tuple`
`refreshToken(secret: str, token: str = "", setToken: bool = True, lifetime: int = None) -> tuple`

Extends a token's lifetime.

Expand Down Expand Up @@ -149,10 +150,11 @@ zone.

[discrete]
==== Raises:
`TigerGraphException` if REST++ authentication is not enabled or if an authentication error
occurs.
`TigerGraphException` if REST++ authentication is not enabled, if an authentication error
occurs, or if calling while using TigerGraph 4.x.

Note:
Not avaliable on TigerGraph version 4.x

[discrete]
==== Endpoint:
Expand Down Expand Up @@ -192,8 +194,9 @@ occurred, for example if the specified token does not exist.

[discrete]
==== Endpoint:
- `DELETE /requesttoken`
- `DELETE /requesttoken` (In TigerGraph version 3.x)
+
See https://docs.tigergraph.com/tigergraph-server/current/api/built-in-endpoints#_delete_a_token[this] for more details.
- `DELETE /gsql/v1/tokens` (In TigerGraph version 4.x)


49 changes: 46 additions & 3 deletions modules/core-functions/pages/base.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ A TigerGraphConnection object provides the HTTP(S) communication used by all oth


== \__init__()
`__init__(host: str = "http://127.0.0.1", graphname: str = "MyGraph", gsqlSecret: str = "", username: str = "tigergraph", password: str = "tigergraph", tgCloud: bool = False, restppPort: Union[int, str] = "9000", gsPort: Union[int, str] = "14240", gsqlVersion: str = "", version: str = "", apiToken: str = "", useCert: bool = None, certPath: str = None, debug: bool = None, sslPort: Union[int, str] = "443", gcp: bool = False)`
`__init__(host: str = "http://127.0.0.1", graphname: str = "MyGraph", gsqlSecret: str = "", username: str = "tigergraph", password: str = "tigergraph", tgCloud: bool = False, restppPort: Union[int, str] = "9000", gsPort: Union[int, str] = "14240", gsqlVersion: str = "", version: str = "", apiToken: str = "", useCert: bool = None, certPath: str = None, debug: bool = None, sslPort: Union[int, str] = "443", gcp: bool = False, jwtToken: str = "")`
Initiate a connection object.
Expand All @@ -26,13 +26,14 @@ this is automatically set to `True`, and you do not need to set this argument.
* `gsPort`: The port for gsql server.
* `gsqlVersion`: The version of the GSQL client to be used. Effectively the version of the database
being connected to.
* `apiToken (Optional)`: Paremeter for specifying a RESTPP service token. Use `getToken()` to get a token.
* `version`: DEPRECATED; use `gsqlVersion`.
* `apiToken`: DEPRECATED; use `getToken()` with a secret to get a session token.
* `useCert`: DEPRECATED; the need for a CA certificate is now determined by URL scheme.
* `certPath`: The filesystem path to the CA certificate. Required in case of https connections.
* `debug`: DEPRECATED; configure standard logging in your app.
* `sslPort`: Port for fetching SSL certificate in case of firewall.
* `gcp`: DEPRECATED. Previously used for connecting to databases provisioned on GCP in TigerGraph Cloud.
* `jwtToken`: The JWT token generated from customer side for authentication
[discrete]
==== Raises:
Expand All @@ -46,11 +47,53 @@ Method to configure the request header.
[discrete]
==== Parameters:
* `timeout (int, optional)`: The timeout value desired in milliseconds. Defaults to 16,000 ms (16 sec)
* `tiemout (int, optional)`: The timeout value desired in milliseconds. Defaults to 16,000 ms (16 sec)
* `responseSize`: The size of the response in bytes. Defaults to 3.2E7 bytes (32 MB).
[discrete]
==== Returns:
Nothing. Sets `responseConfigHeader` class attribute.
== getVersion()
`getVersion(raw: bool = False) -> Union[str, list]`
Retrieves the git versions of all components of the system.
[discrete]
==== Parameter:
* `raw`: Return unprocessed version info string, or extract version info for each component
into a list.
[discrete]
==== Returns:
Either an unprocessed string containing the version info details, or a list with version
info for each component.
[discrete]
==== Endpoint:
- `GET /version`
See xref:tigergraph-server:API:built-in-endpoints.adoc#_show_component_versions[Show component versions]
== getVer()
`getVer(component: str = "product", full: bool = False) -> str`
Gets the version information of a specific component.
Get the full list of components using `getVersion()`.
[discrete]
==== Parameters:
* `component`: One of TigerGraph's components (e.g. product, gpe, gse).
* `full`: Return the full version string (with timestamp, etc.) or just X.Y.Z.
[discrete]
==== Returns:
Version info for specified component.
[discrete]
==== Raises:
`TigerGraphException` if invalid/non-existent component is specified.
16 changes: 8 additions & 8 deletions modules/core-functions/pages/edge.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,15 @@ A dictionary of `edge_type: edge_count` pairs.


== upsertEdge()
`upsertEdge(sourceVertexType: str, sourceVertexId: str, edgeType: str, targetVertexType: str, targetVertexId: str, attributes: dict = None) -> int`
`upsertEdge(sourceVertexType: str, sourceVertexId: str, edgeType: str, targetVertexType: str, targetVertexId: str, attributes: dict = None, vertexMustExist: bool = False) -> int`

Upserts an edge.

Data is upserted:

- If edge is not yet present in graph, it will be created (see special case below).
- If it's already in the graph, it is updated with the values specified in the request.
- If `vertex_must_exist` is True then edge will only be created if both vertex exists
- If `vertex_must_exist` is True then edge will only be created if both vertices exists
in graph. Otherwise missing vertices are created with the new edge; the newly created
vertices' attributes (if any) will be created with default values.

Expand All @@ -266,7 +266,7 @@ Example:
{"visits": (1482, "+"), "max_duration": (371, "max")}
----

For valid values of `<operator>` see xref:tigergraph-server:API:upsert-rest.adoc#_operation_codes[Upsert > Operation Codes] .
For valid values of `<operator>` see https://docs.tigergraph.com/dev/restpp-api/built-in-endpoints#operation-codes[this] .

[discrete]
==== Returns:
Expand All @@ -276,12 +276,12 @@ A single number of accepted (successfully upserted) edges (0 or 1).
==== Endpoint:
- `POST /graph/{graph_name}`
+
See xref:tigergraph-server:API:upsert-rest.adoc[Upsert data to graph] for more details.
See https://docs.tigergraph.com/dev/restpp-api/built-in-endpoints#upsert-data-to-graph[this] for more details.



== upsertEdges()
`upsertEdges(sourceVertexType: str, edgeType: str, targetVertexType: str, edges: list) -> int`
`upsertEdges(sourceVertexType: str, edgeType: str, targetVertexType: str, edges: list, vertexMustExist = False) -> int`

Upserts multiple edges (of the same type).

Expand Down Expand Up @@ -313,7 +313,7 @@ Example:
]
----

For valid values of `<operator>` see xref:tigergraph-server:API:upsert-rest.adoc#_operation_codes[Upsert > Operation Codes] .
For valid values of `<operator>` see https://docs.tigergraph.com/dev/restpp-api/built-in-endpoints#operation-codes[this] .

[discrete]
==== Returns:
Expand All @@ -323,12 +323,12 @@ A single number of accepted (successfully upserted) edges (0 or positive integer
==== Endpoint:
- `POST /graph/{graph_name}`
+
See xref:tigergraph-server:API:upsert-rest.adoc[Upsert Data to Graph] for more details.
See https://docs.tigergraph.com/dev/restpp-api/built-in-endpoints#upsert-data-to-graph[this] for more details.



== upsertEdgeDataFrame()
`upsertEdgeDataFrame(df: pd.DataFrame, sourceVertexType: str, edgeType: str, targetVertexType: str, from_id: str = "", to_id: str = "", attributes: dict = None) -> int`
`upsertEdgeDataFrame(df: pd.DataFrame, sourceVertexType: str, edgeType: str, targetVertexType: str, from_id: str = "", to_id: str = "", attributes: dict = None, vertexMustExist: bool = False) -> int`

Upserts edges from a Pandas DataFrame.

Expand Down
23 changes: 20 additions & 3 deletions modules/core-functions/pages/gsql.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ time of establishing the connection will be used.
==== Returns:
The output of the statement(s) executed.

[discrete]
==== Endpoint:
- `POST /gsqlserver/gsql/file` (In TigerGraph versions 3.x)
- `POST /gsql/v1/statements` (In TigerGraph versions 4.x)


== installUDF()
`installUDF(ExprFunctions: str = "", ExprUtil: str = "") -> None`
Expand All @@ -37,9 +42,13 @@ See https://docs.tigergraph.com/gsql-ref/current/querying/func/query-user-define
==== Returns:
Status of the installation.

[discrete]
==== Endpoints:
- `PUT /gsqlserver/gsql/userdefinedfunction?filename={ExprFunctions or ExprUtil}"` (In TigerGraph versions 3.x)


== getUDF()
`getUDF(ExprFunctions: bool = True, ExprUtil: bool = True) -> Union[str, Tuple[str, str]]`
`getUDF(ExprFunctions: bool = True, ExprUtil: bool = True, json_out: bool = False) -> Union[str, Tuple[str, str], Dict[str, str]]`

Get user defined functions (UDF) installed in the database.
+
Expand All @@ -49,10 +58,18 @@ See https://docs.tigergraph.com/gsql-ref/current/querying/func/query-user-define
==== Parameters:
* `ExprFunctions (bool, optional)`: Whether to get ExprFunctions. Defaults to True.
* `ExprUtil (bool, optional)`: Whether to get ExprUtil. Defaults to True.
* `json_out (bool, optional)`: Whether to output as JSON. Defaults to False.
Only supported on version >=4.1

[discrete]
==== Returns:
str: If only one of `ExprFunctions` or `ExprUtil` is True, return of the content of that file.
Tuple[str, str]: content of ExprFunctions and content of ExprUtil.
- `str`: If only one of `ExprFunctions` or `ExprUtil` is True and json_out is False, return of the content of that file.
- `Tuple[str, str]`: If both `ExprFunctions` and `ExprUtil` are True and json_out is False, return content of ExprFunctions and content of ExprUtil.
- `Dict[str, str]`: If json_out is True, return dict with `ExprFunctions` and/or `ExprUtil` as keys and content of file as value.

[discrete]
==== Endpoints:
- `GET /gsqlserver/gsql/userdefinedfunction?filename={ExprFunctions or ExprUtil}` (In TigerGraph versions 3.x)
- `GET /gsql/v1/udt/files/{ExprFunctions or ExprUtil}` (In TigerGraph versions 4.x)


Loading

0 comments on commit bb24113

Please sign in to comment.