Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GSK-1608] Update token nomenclature of CLI parameters #1414

Merged
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,14 @@ You can then **upload the test suite** created using the `giskard` Python librar

2. Then execute the ML worker in your notebook:
```python
!giskard worker start -d -k YOUR_TOKEN
!giskard worker start -d -k YOUR_KEY
```

3. Finally upload your test suite to the giskard server using the following code:
```python
token = "API_TOKEN" # Find it in Settings in the Giskard server
key = "API_KEY" # Find it in Settings in the Giskard server
client = GiskardClient(
url="http://localhost:19000", token=token # URL of your Giskard instance
url="http://localhost:19000", key=key # URL of your Giskard instance
)

my_project = client.create_project("my_project", "PROJECT_NAME", "DESCRIPTION")
Expand Down Expand Up @@ -222,7 +222,7 @@ You can then **upload the test suite** created using the `giskard` Python librar
<summary>If Giskard server is installed on an external server</summary>

```python
!giskard worker start -d -k YOUR_TOKEN -u http://ec2-13-50-XXXX.compute.amazonaws.com:19000/
!giskard worker start -d -k YOUR_KEY -u http://ec2-13-50-XXXX.compute.amazonaws.com:19000/
```
</details>

Expand Down
12 changes: 6 additions & 6 deletions frontend/src/components/ClientInstructionCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<v-card height="100%">
<v-card-title class="font-weight-light secondary--text">Create a Giskard Client</v-card-title>
<v-card-text v-if="giskardClientTemplate != null">
<CodeSnippet :code-content="giskardClientTemplate"/>
<CodeSnippet :code-content="giskardClientTemplate" />
</v-card-text>
<v-card-text v-else-if="needFetchWithHFAccessToken == null">
<LoadingFullscreen :name="'Giskard Client creating instructions'"/>
<LoadingFullscreen :name="'Giskard Client creating instructions'" />
</v-card-text>
<v-card-text v-else-if="!state.workerStatus.connected && !props.internalHFAccessToken">
<div class="mb-2">
Expand All @@ -18,7 +18,7 @@
</v-row>
</v-card-text>
<v-card-text v-else>
<HuggingFaceTokenCard @submit="fetchAndSaveHFSpacesTokenWithAccessToken"/>
<HuggingFaceTokenCard @submit="fetchAndSaveHFSpacesTokenWithAccessToken" />
</v-card-text>
</v-card>
</template>
Expand Down Expand Up @@ -55,15 +55,15 @@ function generateGiskardClientInstruction(hf_token: string | null = null) {
let snippet = `from giskard import GiskardClient

url = "${apiURL}"
api_token = "${apiKeyStore.getFirstApiKey ? apiKeyStore.getFirstApiKey : '<Generate your API Key first>'}"
api_key = "${apiKeyStore.getFirstApiKey ? apiKeyStore.getFirstApiKey : '<Generate your API Key first>'}"
`;
if (hf_token) {
snippet += `hf_token = "${hf_token}"
`;
}
snippet += `
# Create a giskard client to communicate with Giskard
client = GiskardClient(url, api_token`;
client = GiskardClient(url, api_key`;
if (hf_token) {
snippet += `, hf_token`;
}
Expand All @@ -82,7 +82,7 @@ async function fetchAndSaveHFSpacesTokenWithAccessToken(accessToken: string) {
const token = await hfSpacesTokenStore.getHFSpacesToken();
if (token === null) {
needFetchWithHFAccessToken.value = true;
mainStore.addNotification({content: 'Invalid Hugging Face access token', color: TYPE.ERROR});
mainStore.addNotification({ content: 'Invalid Hugging Face access token', color: TYPE.ERROR });
} else {
giskardClientTemplate.value = generateGiskardClientInstruction(token);
needFetchWithHFAccessToken.value = false;
Expand Down
30 changes: 15 additions & 15 deletions frontend/src/components/StartWorkerInstructions.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<v-card outlined v-if="needFetchWithHFAccessToken === false" :loading="isLoading">
<v-skeleton-loader v-if="isLoading" type="card"/>
<v-skeleton-loader v-if="isLoading" type="card" />
<template v-else>
<v-card-text v-if="apiKeyStore.getFirstApiKey">
<v-alert class="pa-0 text-body-2" colored-border type="info">
Expand All @@ -12,11 +12,11 @@
</v-alert>
<div>
<p>To connect a worker, install giskard library in any code environment of your choice with</p>
<CodeSnippet codeContent='pip install "giskard>=2.0.0b" -U'/>
<CodeSnippet codeContent='pip install "giskard>=2.0.0b" -U' />
<p class="mt-4 mb-4">then run the following command to connect to this Giskard server:</p>
<CodeSnippet :codeContent="codeContent"/>
<CodeSnippet :codeContent="codeContent" />
<p class="mt-4" v-if="route.name !== 'admin-general'">You can check the status of an ML Worker and
generate a new API token on the
generate a new API Access Key on the
<router-link :to="{ name: 'admin-general' }">Settings</router-link>
page
</p>
Expand All @@ -36,21 +36,21 @@
</v-card-text>
</template>
</v-card>
<HuggingFaceTokenCard v-else-if="needFetchWithHFAccessToken" @submit="fetchAndSaveHFSpacesTokenWithAccessToken"/>
<LoadingFullscreen v-else :name="'MLWorker instructions'"/>
<HuggingFaceTokenCard v-else-if="needFetchWithHFAccessToken" @submit="fetchAndSaveHFSpacesTokenWithAccessToken" />
<LoadingFullscreen v-else :name="'MLWorker instructions'" />
</template>

<script setup lang="ts">
import {computed, onMounted, ref} from "vue";
import {useMainStore} from "@/stores/main";
import {useRoute} from "vue-router/composables";
import {apiURL} from "@/env";
import { computed, onMounted, ref } from "vue";
import { useMainStore } from "@/stores/main";
import { useRoute } from "vue-router/composables";
import { apiURL } from "@/env";
import CodeSnippet from "./CodeSnippet.vue";
import {saveLocalHFToken} from "@/utils";
import { saveLocalHFToken } from "@/utils";
import HuggingFaceTokenCard from "./HuggingFaceTokenCard.vue";
import LoadingFullscreen from "./LoadingFullscreen.vue";
import {TYPE} from 'vue-toastification';
import {useApiKeyStore} from "@/stores/api-key-store";
import { TYPE } from 'vue-toastification';
import { useApiKeyStore } from "@/stores/api-key-store";
import { useHFSpacesTokenStore } from "@/stores/hfspaces";

const appSettings = computed(() => mainStore.appSettings);
Expand All @@ -68,7 +68,7 @@ const isLoading = ref<boolean>(true);
const codeContent = computed(() => {
if (mainStore.appSettings!.isRunningOnHfSpaces && hfToken.value) {
try {
return `giskard worker start -u ${apiURL} -k ${apiKeyStore.getFirstApiKey} -t ${hfToken.value}`;
return `giskard worker start -u ${apiURL} -k ${apiKeyStore.getFirstApiKey} --hf-token ${hfToken.value}`;
} catch (error) {
console.error(error);
}
Expand All @@ -85,7 +85,7 @@ async function fetchAndSaveHFSpacesTokenWithAccessToken(accessToken: string) {
if (token === null) {
// Private HFSpaces or no valid HF access token
needFetchWithHFAccessToken.value = true;
mainStore.addNotification({content: 'Invalid Hugging Face access token', color: TYPE.ERROR});
mainStore.addNotification({ content: 'Invalid Hugging Face access token', color: TYPE.ERROR });
} else if (!hfSpacesTokenStore.publicSpace) {
needFetchWithHFAccessToken.value = false;
hfToken.value = token;
Expand Down
4 changes: 2 additions & 2 deletions python-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ First, install the Giskard server by following [this documentation](https://docs

```python
# Create a Giskard client after having installed the Giskard server (see documentation)
token = "API_TOKEN" # Find it in Settings in the Giskard server
key = "API_KEY" # Find it in Settings in the Giskard server
client = GiskardClient(
url="http://localhost:19000", token=token # URL of your Giskard instance
url="http://localhost:19000", key=key # URL of your Giskard instance
)

my_project = client.create_project("my_project", "PROJECT_NAME", "DESCRIPTION")
Expand Down
2 changes: 1 addition & 1 deletion python-client/docs/cli/ngrok/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Copy the following key:

3. Expose the giskard server
^^^^^^^^^^^^^^^^^^^^^^^
Now you can run :code:`giskard server expose --token <ngrok_API_key>` which should prompt you with the following instructions:::
Now you can run :code:`giskard server expose --ngrok-token <ngrok_API_key>` which should prompt you with the following instructions:::

Exposing Giskard Server to the internet...
Giskard Server is now exposed to the internet.
Expand Down
3,054 changes: 3,044 additions & 10 deletions python-client/docs/getting-started/quickstart.ipynb

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions python-client/docs/guides/installation_app/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ You can either install and run the server **locally** or on an **external server
- A public Space: open to everyone (ideal for showcasing your models and their performance).
- A private Space: restricted to your organization or yourself (facilitates internal collaboration and ensures security for your data and models).

**For private Hugging Face Spaces, you'll need an extra token (YOUR_SPACE_TOKEN) to connect the Giskard Client and ML worker.**
**For private Hugging Face Spaces, you'll need an extra token (YOUR_HF_SPACES_TOKEN) to connect the Giskard Client and ML worker.**

If you're new to Giskard, we recommend trying this method. For comprehensive details, explore the guide on `Installation in Hugging Face Spaces <install_hfs/index.md>`_ or visit `our Hugging Face organization page <https://huggingface.co/giskardai>`_ if you're acquainted with Hugging Face Spaces.

Expand All @@ -98,25 +98,25 @@ Giskard executes your model using a worker that runs the model directly in your

.. tab-item:: From your local notebook

To start the ML worker from your notebook, you need to start Giskard in the deamon mode by providing the token in the Settings tab of the Giskard server (accessible via http://localhost:19000/).
To start the ML worker from your notebook, you need to start Giskard in the deamon mode by providing the API Access Key in the Settings tab of the Giskard server (accessible via http://localhost:19000/).

- If Giskard server is installed **locally**, run in a cell in your notebook:

.. code-block:: sh

!giskard worker start -d -k YOUR_TOKEN
!giskard worker start -d -k YOUR_KEY

- If Giskard server is installed on an **external server** (for instance in AWS ec2 instance), or a public Space on Hugging Face Spaces, run the following in your notebook:

.. code-block:: sh

!giskard worker start -d -k YOUR_TOKEN -u http://ec2-13-50-XXXX.compute.amazonaws.com:19000/
!giskard worker start -d -k YOUR_KEY -u http://ec2-13-50-XXXX.compute.amazonaws.com:19000/

- If Giskard server is hosted on a private Space on Hugging Face Spaces, run the following in your notebook:

.. code-block:: sh

!giskard worker start -d -k YOUR_TOKEN -u https://huggingface.co/spaces/<user-id>/<space-id> -t YOUR_SPACE_TOKEN
!giskard worker start -d -k YOUR_KEY -u https://huggingface.co/spaces/<user-id>/<space-id> --hf-token YOUR_HF_SPACES_TOKEN

.. hint:: To see the available commands of the worker, you can execute:

Expand All @@ -128,31 +128,31 @@ Giskard executes your model using a worker that runs the model directly in your

.. tab-item:: From Colab notebook

To start the ML worker from your Colab notebook, you need to start Giskard in the deamon mode by providing the token in the Settings tab of the Giskard server (accessible via http://localhost:19000/).
To start the ML worker from your Colab notebook, you need to start Giskard in the deamon mode by providing the API Access Key in the Settings tab of the Giskard server (accessible via http://localhost:19000/).

- If the Giskard server is installed **locally**:

Run in your **local** terminal (not the the terminal from Colab):

.. code-block:: sh

giskard server expose --token <ngrok_API_token>
giskard server expose --ngrok-token <ngrok_API_token>

Read the flowing `instructions <https://docs.giskard.ai/en/latest/cli/ngrok/index.html>`_ in order to get the
:code:`ngrok_API_token`. Then run the below 4 lines of code in a **cell of your Colab notebook**:

.. code-block:: sh

%env GSK_API_KEY=YOUR_API_KEY
!giskard worker start -d -k YOUR_TOKEN -u https://e840-93-23-184-184.ngrok-free.app
!giskard worker start -d -k YOUR_KEY -u https://e840-93-23-184-184.ngrok-free.app

- If the Giskard server is installed on an **external** server (for instance on an AWS ec2 instance), or a public Space on Hugging Face Spaces:

Run on a cell in Colab:

.. code-block:: sh

!giskard worker start -d -k YOUR_TOKEN -u http://ec2-13-50-XXXX.compute.amazonaws.com:19000/
!giskard worker start -d -k YOUR_KEY -u http://ec2-13-50-XXXX.compute.amazonaws.com:19000/


- If Giskard server is hosted on a private Space on Hugging Face Spaces:
Expand All @@ -161,7 +161,7 @@ Giskard executes your model using a worker that runs the model directly in your

.. code-block:: sh

!giskard worker start -d -k YOUR_TOKEN -u https://huggingface.co/spaces/<user-id>/<space-id> -t YOUR_SPACE_TOKEN
!giskard worker start -d -k YOUR_KEY -u https://huggingface.co/spaces/<user-id>/<space-id> --hf-token YOUR_HF_SPACES_TOKEN

.. hint:: To see the available commands of the worker, you can execute:

Expand All @@ -181,7 +181,7 @@ Giskard executes your model using a worker that runs the model directly in your

giskard worker start -u http://localhost:19000/

You then will be asked to provide your API token. The API access token can be found in the Settings tab of the Giskard server (accessible via: http://localhost:19000/)
You then will be asked to provide your API Access Key. The API Access key can be found in the Settings tab of the Giskard server (accessible via: http://localhost:19000/)

- If Giskard server is installed in an **external server** (for instance in AWS ec2 instance), or a public Space on Hugging Face Spaces:

Expand All @@ -197,7 +197,7 @@ Giskard executes your model using a worker that runs the model directly in your

.. code-block:: sh

!giskard worker start -d -k YOUR_TOKEN -u https://huggingface.co/spaces/<user-id>/<space-id> -t YOUR_SPACE_TOKEN
!giskard worker start -d -k YOUR_KEY -u https://huggingface.co/spaces/<user-id>/<space-id> --hf-token YOUR_HF_SPACES_TOKEN

.. hint:: To see the available commands of the worker, you can execute:

Expand Down
8 changes: 4 additions & 4 deletions python-client/docs/guides/scan/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ You can then upload the test suite to the local Giskard server. This will enable

from giskard import GiskardClient

token = "API_TOKEN" # Find it in Settings in the Giskard server
key = "API_KEY" # Find it in Settings in the Giskard server
client = GiskardClient(
url="http://localhost:19000", # URL of your Giskard instance
token=token
key=key
)

my_project = client.create_project("my_project", "PROJECT_NAME", "DESCRIPTION")
Expand All @@ -137,11 +137,11 @@ You can then upload the test suite to the local Giskard server. This will enable

.. code-block:: python

token = "API_TOKEN" # Find it in Settings in your Giskard Hugging Face Space instance
key = "API_KEY" # Find it in Settings in your Giskard Hugging Face Space instance
hf_token = "SPACE_TOKEN" # Find it in Upload instructions in your Giskard Hugging Face Space instance
client = GiskardClient(
url="https://huggingface.co/spaces/<user-id>/<space-id>", # URL of the Space
token=token,
key=key,
hf_token=hf_token,
)

Expand Down
30 changes: 15 additions & 15 deletions python-client/docs/guides/upload/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,25 @@ from giskard import GiskardClient

url = "http://localhost:19000" # If Giskard is installed locally
# url = "http://app.giskard.ai" # If you want to upload in a Giskard server
token = "API_TOKEN" # you can generate your API token in the Settings tab of the Giskard application
key = "API_KEY" # you can generate your API key in the Settings tab of the Giskard application
project_name = "enron"

# Create a giskard client to communicate with Giskard
client = GiskardClient(url, token)
client = GiskardClient(url, key)
```

You can find the URL and the tokens in the Settings tab of the Giskard application.
You can find the URL and the API Access Key in the Settings tab of the Giskard application.

:::{hint}
You may also need an extra token (Giskard Space Token) to upload your test suite to a private Space on Hugging Face Spaces. To create your Giskard client, please use the following code snippet instead:

```python
url = "https://huggingface.co/spaces/<user-id>/<space-id>"
token = "API_TOKEN" # You can generate your API token in the Settings tab of your Giskard Hugging Face Space
key = "API_KEY" # You can generate your API Access Key in the Settings tab of your Giskard Hugging Face Space
hf_token = "<Giskard Space Token>" # Find it in Settings in your Giskard Hugging Face Space
client = GiskardClient(
url=url,
token=token,
key=key,
hf_token=hf_token,
)
```
Expand Down Expand Up @@ -88,11 +88,11 @@ giskard_model = Model(

url = "http://localhost:19000" # If Giskard is installed locally
# url = "http://app.giskard.ai" # If you want to upload on a an external Giskard server
token = "API_TOKEN" # you can generate your API token in the Settings tab of the Giskard application
key = "API_KEY" # you can generate your API Acces Key in the Settings tab of the Giskard application
project_name = "my_project_id"

# Create a giskard client to communicate with Giskard
client = GiskardClient(url, token)
client = GiskardClient(url, key)

# Create a project
client.create_project(project_name, "Project name", "Small description of the project")
Expand Down Expand Up @@ -142,11 +142,11 @@ giskard_model = Model(

url = "http://localhost:19000" # If Giskard is installed locally
# url = "http://app.giskard.ai" # If you want to upload on a an external Giskard server
token = "API_TOKEN" # you can generate your API token in the Settings tab of the Giskard application
key = "API_KEY" # you can generate your API Access Key in the Settings tab of the Giskard application
project_name = "my_project_id"

# Create a giskard client to communicate with Giskard
client = GiskardClient(url, token)
client = GiskardClient(url, key)

# Create a project
client.create_project(project_name, "Project name", "Small description of the project")
Expand Down Expand Up @@ -175,11 +175,11 @@ giskard_dataset = Dataset(

url = "http://localhost:19000" # If Giskard is installed locally
# url = "http://app.giskard.ai" # If you want to upload on a an external Giskard server
token = "API_TOKEN" # you can generate your API token in the Settings tab of the Giskard application
key = "API_KEY" # you can generate your API Access Key in the Settings tab of the Giskard application
project_name = "my_project_id"

# Create a giskard client to communicate with Giskard
client = GiskardClient(url, token)
client = GiskardClient(url, key)

# Create a project
client.create_project(project_name, "Project name", "Small description of the project")
Expand All @@ -205,11 +205,11 @@ def slice_sex(row: pd.Series):

url = "http://localhost:19000" # If Giskard is installed locally
# url = "http://app.giskard.ai" # If you want to upload on a an external Giskard server
token = "API_TOKEN" # you can generate your API token in the Settings tab of the Giskard application
key = "API_KEY" # you can generate your API Access Key in the Settings tab of the Giskard application
project_name = "my_project_id"

# Create a giskard client to communicate with Giskard
client = GiskardClient(url, token)
client = GiskardClient(url, key)

# Create a project
client.create_project(project_name, "Project name", "Small description of the project")
Expand Down Expand Up @@ -238,11 +238,11 @@ def increase_age(row):

url = "http://localhost:19000" # If Giskard is installed locally
# url = "http://app.giskard.ai" # If you want to upload on a an external Giskard server
token = "API_TOKEN" # you can generate your API token in the Settings tab of the Giskard application
key = "API_KEY" # you can generate your API Acces Key in the Settings tab of the Giskard application
project_name = "my_project_id"

# Create a giskard client to communicate with Giskard
client = GiskardClient(url, token)
client = GiskardClient(url, key)

# Create a project
client.create_project(project_name, "Project name", "Small description of the project")
Expand Down
Loading
Loading