<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.foji.io/index.php?action=history&amp;feed=atom&amp;title=Using_the_Foji_Python_Client_in_Notebook_Servers</id>
	<title>Using the Foji Python Client in Notebook Servers - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://docs.foji.io/index.php?action=history&amp;feed=atom&amp;title=Using_the_Foji_Python_Client_in_Notebook_Servers"/>
	<link rel="alternate" type="text/html" href="https://docs.foji.io/index.php?title=Using_the_Foji_Python_Client_in_Notebook_Servers&amp;action=history"/>
	<updated>2026-06-22T03:37:47Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.40.1</generator>
	<entry>
		<id>https://docs.foji.io/index.php?title=Using_the_Foji_Python_Client_in_Notebook_Servers&amp;diff=2487&amp;oldid=prev</id>
		<title>Chris.Hansen: /* 4. Prediction Client (AutoML Predictions) */</title>
		<link rel="alternate" type="text/html" href="https://docs.foji.io/index.php?title=Using_the_Foji_Python_Client_in_Notebook_Servers&amp;diff=2487&amp;oldid=prev"/>
		<updated>2024-09-13T17:11:19Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;4. Prediction Client (AutoML Predictions)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 17:11, 13 September 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l68&quot;&gt;Line 68:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 68:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Fetch a prediction using input data&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Fetch a prediction using input data&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;input_data = {&amp;quot;feature1&amp;quot;: 1.5, &amp;quot;feature2&amp;quot;: 3.4}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;input_data = {&amp;quot;feature1&amp;quot;: 1.5, &amp;quot;feature2&amp;quot;: 3.4}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;predicted_value = predictions.fetch(&quot;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;model_id&lt;/del&gt;&quot;, input_data)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;predicted_value = predictions.fetch(&quot;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;configuration_id&lt;/ins&gt;&quot;, input_data)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Fetch multiple predictions&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Fetch multiple predictions&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;input_data_list = [{&amp;quot;feature1&amp;quot;: 1.5, &amp;quot;feature2&amp;quot;: 3.4}, {&amp;quot;feature1&amp;quot;: 2.1, &amp;quot;feature2&amp;quot;: 4.0}]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;input_data_list = [{&amp;quot;feature1&amp;quot;: 1.5, &amp;quot;feature2&amp;quot;: 3.4}, {&amp;quot;feature1&amp;quot;: 2.1, &amp;quot;feature2&amp;quot;: 4.0}]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;predicted_values = predictions.fetch(&quot;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;model_id&lt;/del&gt;&quot;, input_data_list)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;predicted_values = predictions.fetch(&quot;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;configuration_id&lt;/ins&gt;&quot;, input_data_list)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Print predictions&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Print predictions&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wiki:diff::1.12:old-2486:rev-2487 --&gt;
&lt;/table&gt;</summary>
		<author><name>Chris.Hansen</name></author>
	</entry>
	<entry>
		<id>https://docs.foji.io/index.php?title=Using_the_Foji_Python_Client_in_Notebook_Servers&amp;diff=2486&amp;oldid=prev</id>
		<title>Chris.Hansen: Created page with &quot;The Foji Python client is designed to interact with various services within the FojiSoft application suite, including relational data access, metric services, dataset management, and predictive analytics. This guide explains how to use key methods available for these functionalities in Notebook Servers.  ==== Installation ==== The &lt;code&gt;foji&lt;/code&gt; package is already available in your Notebook Server.  ==== Key Components ==== The &quot;Foji&quot; Python client consists of four pr...&quot;</title>
		<link rel="alternate" type="text/html" href="https://docs.foji.io/index.php?title=Using_the_Foji_Python_Client_in_Notebook_Servers&amp;diff=2486&amp;oldid=prev"/>
		<updated>2024-09-13T17:09:49Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;The Foji Python client is designed to interact with various services within the FojiSoft application suite, including relational data access, metric services, dataset management, and predictive analytics. This guide explains how to use key methods available for these functionalities in Notebook Servers.  ==== Installation ==== The &amp;lt;code&amp;gt;foji&amp;lt;/code&amp;gt; package is already available in your Notebook Server.  ==== Key Components ==== The &amp;quot;Foji&amp;quot; Python client consists of four pr...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;The Foji Python client is designed to interact with various services within the FojiSoft application suite, including relational data access, metric services, dataset management, and predictive analytics. This guide explains how to use key methods available for these functionalities in Notebook Servers.&lt;br /&gt;
&lt;br /&gt;
==== Installation ====&lt;br /&gt;
The &amp;lt;code&amp;gt;foji&amp;lt;/code&amp;gt; package is already available in your Notebook Server.&lt;br /&gt;
&lt;br /&gt;
==== Key Components ====&lt;br /&gt;
The &amp;quot;Foji&amp;quot; Python client consists of four primary modules that facilitate the following tasks:&lt;br /&gt;
&lt;br /&gt;
# &amp;#039;&amp;#039;&amp;#039;Relational (ClickHouse Client)&amp;#039;&amp;#039;&amp;#039;: Execute queries against a relational data store.&lt;br /&gt;
# &amp;#039;&amp;#039;&amp;#039;Metrics (Cortex Client)&amp;#039;&amp;#039;&amp;#039;: Fetch real-time and time-series metrics from the Cortex service.&lt;br /&gt;
# &amp;#039;&amp;#039;&amp;#039;DataSets&amp;#039;&amp;#039;&amp;#039;: Fetch datasets from the Forge AI platform.&lt;br /&gt;
# &amp;#039;&amp;#039;&amp;#039;Predictions (AutoML Client)&amp;#039;&amp;#039;&amp;#039;: Retrieve predictions from pre-trained Forge AI models.&lt;br /&gt;
&lt;br /&gt;
==== How to Use ====&lt;br /&gt;
&lt;br /&gt;
===== 1. ClickHouse Client (Relational Data Access) =====&lt;br /&gt;
The ClickHouse client provides access to a relational data store using SQL queries. It also supports date parsing.&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from foji import relational&lt;br /&gt;
&lt;br /&gt;
# Execute a SQL query with optional parameters&lt;br /&gt;
query = &amp;quot;SELECT * FROM users WHERE age &amp;gt; {age:Int32}&amp;quot;&lt;br /&gt;
params = {&amp;quot;age&amp;quot;: 25}&lt;br /&gt;
results = relational.query(query, params)&lt;br /&gt;
&lt;br /&gt;
# Print results&lt;br /&gt;
for row in results:&lt;br /&gt;
    print(row)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;#039;&amp;#039;&amp;#039;Key Method&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;query(query: str, params: dict[str, Any] = None) -&amp;gt; list[dict]&amp;lt;/code&amp;gt;: Executes an SQL query with optional parameters and returns the results as a list of dictionaries.&lt;br /&gt;
&lt;br /&gt;
===== 2. Cortex Client (Metrics Service) =====&lt;br /&gt;
The Cortex client provides interfaces to query real-time and historical metrics using the Cortex API.&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from foji import metrics&lt;br /&gt;
&lt;br /&gt;
# Query for an instant metric value&lt;br /&gt;
result = metrics.instant(&amp;quot;up&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Query for a range of metrics&lt;br /&gt;
result_range = metrics.range(&amp;quot;up&amp;quot;, &amp;quot;2023-01-01T00:00:00Z&amp;quot;, &amp;quot;2023-01-01T01:00:00Z&amp;quot;, &amp;quot;60s&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Print results&lt;br /&gt;
print(result)&lt;br /&gt;
print(result_range)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;#039;&amp;#039;&amp;#039;Key Methods&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;instant(query: str, time: int | str = None) -&amp;gt; CortexResult&amp;lt;/code&amp;gt;: Queries metrics at a specific point in time.&lt;br /&gt;
* &amp;lt;code&amp;gt;query(query: str, time: int | str = None) -&amp;gt; CortexResult&amp;lt;/code&amp;gt;: Queries metrics at a specific point in time.&lt;br /&gt;
* &amp;lt;code&amp;gt;range(query: str, start: int | str, end: int | str, step: float | str = None) -&amp;gt; CortexResult&amp;lt;/code&amp;gt;: Queries time-series metrics for a given time range.&lt;br /&gt;
&lt;br /&gt;
===== 3. DataSets Client (Dataset Management) =====&lt;br /&gt;
The DataSets client allows you to fetch datasets stored within Foji.&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from foji import dataSets&lt;br /&gt;
&lt;br /&gt;
# Fetch a dataset by its ID&lt;br /&gt;
data = dataSets.fetch(&amp;quot;dataset_id&amp;quot;, &amp;quot;2023-01-01T00:00:00Z&amp;quot;, &amp;quot;2023-01-01T01:00:00Z&amp;quot;, &amp;quot;60s&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Print data&lt;br /&gt;
print(data)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;#039;&amp;#039;&amp;#039;Key Method&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;fetch(id: str, start: str, end: str, step: str = &amp;quot;1m&amp;quot;) -&amp;gt; list[dict[str, Any]]&amp;lt;/code&amp;gt;: Fetches data from a Data Set&lt;br /&gt;
&lt;br /&gt;
===== 4. Prediction Client (AutoML Predictions) =====&lt;br /&gt;
The Predictions client enables you to retrieve predictions from pre-trained Forge AI models.&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from foji import predictions&lt;br /&gt;
&lt;br /&gt;
# Fetch a prediction using input data&lt;br /&gt;
input_data = {&amp;quot;feature1&amp;quot;: 1.5, &amp;quot;feature2&amp;quot;: 3.4}&lt;br /&gt;
predicted_value = predictions.fetch(&amp;quot;model_id&amp;quot;, input_data)&lt;br /&gt;
&lt;br /&gt;
# Fetch multiple predictions&lt;br /&gt;
input_data_list = [{&amp;quot;feature1&amp;quot;: 1.5, &amp;quot;feature2&amp;quot;: 3.4}, {&amp;quot;feature1&amp;quot;: 2.1, &amp;quot;feature2&amp;quot;: 4.0}]&lt;br /&gt;
predicted_values = predictions.fetch(&amp;quot;model_id&amp;quot;, input_data_list)&lt;br /&gt;
&lt;br /&gt;
# Print predictions&lt;br /&gt;
print(predicted_value)&lt;br /&gt;
for prediction in predicted_values:&lt;br /&gt;
    print(prediction)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;#039;&amp;#039;&amp;#039;Key Method&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;fetch(id: str, data: dict | list[dict]) -&amp;gt; float | str | list[Prediction]&amp;lt;/code&amp;gt;: Fetches single or multiple predictions based on the input data.&lt;br /&gt;
&lt;br /&gt;
==== Conclusion ====&lt;br /&gt;
The &amp;quot;Foji&amp;quot; Python client provides seamless integration with Foji services, enabling efficient access to relational data, metrics, datasets, and prediction models. By leveraging these key methods, you can streamline data processing and predictive analysis within the Forge AI Notebook Server environment.&lt;br /&gt;
[[Category:ForgeAI]]&lt;/div&gt;</summary>
		<author><name>Chris.Hansen</name></author>
	</entry>
</feed>