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

MAINT: Add Import Sorting for Docs and Jupyter Notebooks (isort/nbqa-isort) #646

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,15 @@ repos:
hooks:
- id: isort
name: Import Sort (Python files)
exclude: (doc/|__init__.py)
args: ["--profile", "black", "--filter-files"]
exclude: __init__.py
args: [--profile=black, --filter-files, --treat-comment-as-code "# %%"]

- repo: https://github.com/nbQA-dev/nbQA
rev: 1.9.1
hooks:
- id: nbqa-isort
name: Import Sort (Jupyter Notebooks)
args: [--profile=black]

- repo: https://github.com/PyCQA/flake8
rev: 7.1.1
Expand Down
1 change: 0 additions & 1 deletion doc/code/converters/1_llm_converters.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
}
],
"source": [
"\n",
"from pyrit.prompt_converter import (\n",
" MaliciousQuestionGeneratorConverter,\n",
" NoiseConverter,\n",
Expand Down
1 change: 0 additions & 1 deletion doc/code/memory/chat_message.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
}
],
"source": [
"\n",
"chat_messages = normalizer.from_chatml(\n",
" \"\"\"\\\n",
" <|im_start|>system\n",
Expand Down
6 changes: 2 additions & 4 deletions doc/code/orchestrators/1_prompt_sending_orchestrator.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@
}
],
"source": [
"\n",
"import pathlib\n",
"\n",
"from pyrit.common.path import DATASETS_PATH\n",
Expand Down Expand Up @@ -349,10 +348,9 @@
"source": [
"import uuid\n",
"\n",
"from pyrit.common import initialize_pyrit, IN_MEMORY\n",
"from pyrit.prompt_target import OpenAIChatTarget\n",
"from pyrit.common import IN_MEMORY, initialize_pyrit\n",
"from pyrit.orchestrator import PromptSendingOrchestrator\n",
"\n",
"from pyrit.prompt_target import OpenAIChatTarget\n",
"\n",
"initialize_pyrit(memory_db_type=IN_MEMORY)\n",
"\n",
Expand Down
5 changes: 2 additions & 3 deletions doc/code/orchestrators/1_prompt_sending_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,9 @@
# %%
import uuid

from pyrit.common import initialize_pyrit, IN_MEMORY
from pyrit.prompt_target import OpenAIChatTarget
from pyrit.common import IN_MEMORY, initialize_pyrit
from pyrit.orchestrator import PromptSendingOrchestrator

from pyrit.prompt_target import OpenAIChatTarget

initialize_pyrit(memory_db_type=IN_MEMORY)

Expand Down
3 changes: 0 additions & 3 deletions doc/code/orchestrators/3_xpia_orchestrator.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@
}
],
"source": [
"\n",
"from xpia_helpers import AzureStoragePlugin, SemanticKernelPluginAzureOpenAIPromptTarget\n",
"\n",
"from pyrit.common import IN_MEMORY, initialize_pyrit\n",
Expand Down Expand Up @@ -784,7 +783,6 @@
}
],
"source": [
"\n",
"from pyrit.orchestrator import XPIATestOrchestrator\n",
"from pyrit.prompt_target import AzureBlobStorageTarget\n",
"from pyrit.score import SubStringScorer\n",
Expand Down Expand Up @@ -1133,7 +1131,6 @@
}
],
"source": [
"\n",
"import os\n",
"\n",
"from xpia_helpers import AzureStoragePlugin\n",
Expand Down
1 change: 0 additions & 1 deletion doc/deployment/deploy_hf_model_aml.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
"metadata": {},
"outputs": [],
"source": [
"\n",
"import os\n",
"import random\n",
"import string\n",
Expand Down
4 changes: 1 addition & 3 deletions doc/deployment/download_and_register_hf_model_aml.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,13 @@
"import os\n",
"from typing import Union\n",
"\n",
"from dotenv import load_dotenv\n",
"\n",
"# Import necessary libraries for Azure ML operations and authentication\n",
"from azure.ai.ml import MLClient, UserIdentityConfiguration\n",
"from azure.ai.ml.dsl import pipeline\n",
"from azure.ai.ml.entities import AmlCompute\n",
"from azure.core.exceptions import ResourceNotFoundError\n",
"from azure.identity import DefaultAzureCredential, InteractiveBrowserCredential\n",
"\n"
"from dotenv import load_dotenv"
]
},
{
Expand Down
3 changes: 1 addition & 2 deletions doc/deployment/download_and_register_hf_model_aml.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,13 @@
import os
from typing import Union

from dotenv import load_dotenv

# Import necessary libraries for Azure ML operations and authentication
from azure.ai.ml import MLClient, UserIdentityConfiguration
from azure.ai.ml.dsl import pipeline
from azure.ai.ml.entities import AmlCompute
from azure.core.exceptions import ResourceNotFoundError
from azure.identity import DefaultAzureCredential, InteractiveBrowserCredential
from dotenv import load_dotenv

# %% [markdown]
# ### 1.2 Load Environment Variables
Expand Down
1 change: 0 additions & 1 deletion doc/how_to_guide.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"metadata": {},
"outputs": [],
"source": [
"\n",
"import os\n",
"\n",
"from pyrit.common import DUCK_DB, initialize_pyrit\n",
Expand Down
Loading