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

Fix/update lint rules #264

Merged
merged 8 commits into from
Nov 26, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ jobs:
pip install ruff
- name: Running Ruff Check
run: |
ruff check $(git ls-files '*.py')
ruff check
1 change: 1 addition & 0 deletions data/ccai_service_kit/conf_score_cfx/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import json
import logging

from dfcx_scrapi.tools.webhook_util import WebhookUtil

# logging config
Expand Down
8 changes: 4 additions & 4 deletions data/get_weather_tool.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""Sample Tool for Agent Builder."""
import logging

import requests
from google.auth import default as google_default_auth
from google.auth.transport.requests import Request as GoogleRequest
from flask import Flask, request
from firebase_admin import initialize_app
from firebase_functions import https_fn

from flask import Flask, request
from google.auth import default as google_default_auth
from google.auth.transport.requests import Request as GoogleRequest

initialize_app()
app = Flask(__name__)
Expand Down
4 changes: 3 additions & 1 deletion examples/bot_building_series/bot_building_101.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@
# limitations under the License.

import sys

import pandas as pd

from dfcx_scrapi.core.agents import Agents
from dfcx_scrapi.core.intents import Intents
from dfcx_scrapi.core.flows import Flows
from dfcx_scrapi.core.intents import Intents
from dfcx_scrapi.core.pages import Pages
from dfcx_scrapi.tools.dataframe_functions import DataframeFunctions
from dfcx_scrapi.tools.maker_util import MakerUtil


def build_agent(creds_path, project_id):
"""Build a simple agent."""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
# limitations under the License.

import sys

import pandas as pd

from dfcx_scrapi.core.agents import Agents
from dfcx_scrapi.tools.dataframe_functions import DataframeFunctions

Expand All @@ -40,18 +42,18 @@ def build_agent(creds_path, project_id, gcp_region, display_name):
# Next, we will set some variables for our agent creation or retrieval args

# Then we will call the `create_agent` and capture the result in a var call
# `my_agent`
# `my_agent`
my_agent = agent_instance.create_agent(project_id, display_name, gcp_region)

# Option 2: If agent already exists
# The agent ID must be entered as a string
# "projects/<PROJECT_ID>/locations/<GCP_REGION>/agents/<AGENT_ID>"
# my_agent = a.get_agent(
# "projects/<PROJECT_ID>/locations/<GCP_REGION>/agents/<AGENT_ID>")
# "projects/<PROJECT_ID>/locations/<GCP_REGION>/agents/<AGENT_ID>")

# ## Create Your First Intent
# For this demo agent, we'll build a basic intent from list of Training
# Phrases (TPs)
# Phrases (TPs)

# To simplify the Intent creation, we'll utilize the `DataframeFunctions`
# class from the `tools` portion of the SCRAPI library.
Expand Down
11 changes: 10 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@ build-backend = "setuptools.build_meta"

[tool.ruff]
line-length = 80
extend-exclude = ["*.ipynb"]
extend-exclude = ["tests", "*.ipynb"]

[tool.ruff.lint]
select = [
"E", # pycodestyle
"F", # Pyflakes
"I", # isort
"W" # warn
]
ignore = []

[tool.ruff.format]
quote-style = "double"
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
# limitations under the License.

import pathlib
from setuptools import setup, find_packages

from setuptools import find_packages, setup

here = pathlib.Path(__file__).parent.resolve()

Expand Down
14 changes: 8 additions & 6 deletions src/agent_assist/agent_assist.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@
# limitations under the License.

import logging

from dfcx_scrapi.core import scrapi_base
from typing import Dict
from google.cloud.dialogflow_v2beta1 import services
from google.cloud.dialogflow_v2beta1 import types
from google.cloud.dialogflow_v2beta1.services.knowledge_bases import KnowledgeBasesClient

from google.cloud.dialogflow_v2beta1 import services, types
from google.cloud.dialogflow_v2beta1.services.knowledge_bases import (
KnowledgeBasesClient,
)
from google.protobuf import field_mask_pb2

from dfcx_scrapi.core import scrapi_base

# logging config
logging.basicConfig(
level=logging.INFO,
Expand Down Expand Up @@ -169,7 +171,7 @@ def create_conversation_profile(
query_config.max_results = max_results
feature_config.query_config = query_config

conversation_profile.human_agent_assistant_config.human_agent_suggestion_config.feature_configs = [feature_config] # pylint: disable=C0301
conversation_profile.human_agent_assistant_config.human_agent_suggestion_config.feature_configs = [feature_config] # noqa: E501

request = types.conversation_profile.CreateConversationProfileRequest(
parent= project_path,
Expand Down
24 changes: 12 additions & 12 deletions src/dfcx_scrapi/agent_extract/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@
# limitations under the License.

import logging
import time
import os
import shutil
import time
from typing import Dict

from dfcx_scrapi.core import agents
from dfcx_scrapi.core import operations
from dfcx_scrapi.core import scrapi_base
from dfcx_scrapi.agent_extract import graph
from dfcx_scrapi.agent_extract import flows
from dfcx_scrapi.agent_extract import intents
from dfcx_scrapi.agent_extract import entity_types
from dfcx_scrapi.agent_extract import test_cases
from dfcx_scrapi.agent_extract import webhooks
from dfcx_scrapi.agent_extract import gcs_utils
from dfcx_scrapi.agent_extract import types
from dfcx_scrapi.agent_extract import (
entity_types,
flows,
gcs_utils,
graph,
intents,
test_cases,
types,
webhooks,
)
from dfcx_scrapi.core import agents, operations, scrapi_base

# logging config
logging.basicConfig(
Expand Down
1 change: 1 addition & 0 deletions src/dfcx_scrapi/agent_extract/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import logging
import re

from dfcx_scrapi.agent_extract import types

# logging config
Expand Down
5 changes: 2 additions & 3 deletions src/dfcx_scrapi/agent_extract/entity_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@

import json
import os

from typing import Dict

from dfcx_scrapi.agent_extract import common
from dfcx_scrapi.agent_extract import types
from dfcx_scrapi.agent_extract import common, types


class EntityTypes:
"""Entity Type processing methods and functions."""
Expand Down
15 changes: 8 additions & 7 deletions src/dfcx_scrapi/agent_extract/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@

import json
import os

from typing import List

from dfcx_scrapi.agent_extract import graph
from dfcx_scrapi.agent_extract import common
from dfcx_scrapi.agent_extract import types
from dfcx_scrapi.agent_extract import pages
from dfcx_scrapi.agent_extract import routes
from dfcx_scrapi.agent_extract import route_groups
from dfcx_scrapi.agent_extract import (
common,
graph,
pages,
route_groups,
routes,
types,
)


class Flows:
Expand Down
1 change: 1 addition & 0 deletions src/dfcx_scrapi/agent_extract/gcs_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# limitations under the License.

import zipfile

from google.cloud import storage
from google.oauth2 import service_account

Expand Down
1 change: 1 addition & 0 deletions src/dfcx_scrapi/agent_extract/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import collections


class Graph:
"""Utility class for manaing graph structure."""

Expand Down
3 changes: 1 addition & 2 deletions src/dfcx_scrapi/agent_extract/intents.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
import json
import os

from dfcx_scrapi.agent_extract import common
from dfcx_scrapi.agent_extract import types
from dfcx_scrapi.agent_extract import common, types


class Intents:
Expand Down
7 changes: 2 additions & 5 deletions src/dfcx_scrapi/agent_extract/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@

import json
import os
from typing import Any, Dict

from typing import Dict, Any

from dfcx_scrapi.agent_extract import common
from dfcx_scrapi.agent_extract import types
from dfcx_scrapi.agent_extract import routes
from dfcx_scrapi.agent_extract import common, routes, types


class Pages:
Expand Down
6 changes: 2 additions & 4 deletions src/dfcx_scrapi/agent_extract/route_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import json
import os

from dfcx_scrapi.agent_extract import common
from dfcx_scrapi.agent_extract import types
from dfcx_scrapi.agent_extract import routes
from dfcx_scrapi.agent_extract import common, routes, types


class RouteGroups:
Expand Down
5 changes: 2 additions & 3 deletions src/dfcx_scrapi/agent_extract/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import Dict, Any
from typing import Any, Dict

from dfcx_scrapi.agent_extract import common
from dfcx_scrapi.agent_extract import types
from dfcx_scrapi.agent_extract import common, types


class Fulfillments:
Expand Down
6 changes: 2 additions & 4 deletions src/dfcx_scrapi/agent_extract/test_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@

import json
import os
from typing import Any, Dict, List

from typing import Dict, List, Any

from dfcx_scrapi.agent_extract import common
from dfcx_scrapi.agent_extract import types
from dfcx_scrapi.agent_extract import common, types


class TestCases:
Expand Down
3 changes: 2 additions & 1 deletion src/dfcx_scrapi/agent_extract/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import Dict, List, Any, Tuple
from dataclasses import dataclass, field
from typing import Any, Dict, List, Tuple

from dfcx_scrapi.agent_extract import graph as graph_class


@dataclass
class AgentMetadata:
"""Used to track the current Agent Metadata attrinbutes."""
Expand Down
4 changes: 2 additions & 2 deletions src/dfcx_scrapi/agent_extract/webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import json
import os

from dfcx_scrapi.agent_extract import common
from dfcx_scrapi.agent_extract import types
from dfcx_scrapi.agent_extract import common, types


class Webhooks:
"""Webhook linter methods and functions."""
Expand Down
4 changes: 2 additions & 2 deletions src/dfcx_scrapi/builders/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import logging
from typing import List

from google.cloud.dialogflowcx_v3beta1.types import Agent
from google.cloud.dialogflowcx_v3beta1.types import SpeechToTextSettings
from google.cloud.dialogflowcx_v3beta1.types import Agent, SpeechToTextSettings

from dfcx_scrapi.builders.builders_common import BuildersCommon

# logging config
Expand Down
6 changes: 4 additions & 2 deletions src/dfcx_scrapi/builders/builders_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
import logging
from typing import List, Union

from google.cloud.dialogflowcx_v3beta1.types import TransitionRoute
from google.cloud.dialogflowcx_v3beta1.types import EventHandler
from google.cloud.dialogflowcx_v3beta1.types import (
EventHandler,
TransitionRoute,
)

# logging config
logging.basicConfig(
Expand Down
1 change: 1 addition & 0 deletions src/dfcx_scrapi/builders/entity_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from typing import List, Union

from google.cloud.dialogflowcx_v3beta1.types import EntityType

from dfcx_scrapi.builders.builders_common import BuildersCommon

# logging config
Expand Down
17 changes: 11 additions & 6 deletions src/dfcx_scrapi/builders/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,19 @@
from dataclasses import dataclass
from typing import List, Union

from google.cloud.dialogflowcx_v3beta1.types import Flow
from google.cloud.dialogflowcx_v3beta1.types import NluSettings
from google.cloud.dialogflowcx_v3beta1.types import TransitionRoute
from google.cloud.dialogflowcx_v3beta1.types import EventHandler
from google.cloud.dialogflowcx_v3beta1.types import (
EventHandler,
Flow,
NluSettings,
TransitionRoute,
)

from dfcx_scrapi.builders.builders_common import BuildersCommon
from dfcx_scrapi.builders.routes import TransitionRouteBuilder
from dfcx_scrapi.builders.routes import EventHandlerBuilder
from dfcx_scrapi.builders.fulfillments import FulfillmentBuilder
from dfcx_scrapi.builders.routes import (
EventHandlerBuilder,
TransitionRouteBuilder,
)

# logging config
logging.basicConfig(
Expand Down
Loading