diff --git a/src/promptflow-devkit/promptflow/_version.py b/src/promptflow-azure/promptflow/azure/_cli/_user_agent.py similarity index 62% rename from src/promptflow-devkit/promptflow/_version.py rename to src/promptflow-azure/promptflow/azure/_cli/_user_agent.py index 68ee238ac5d..a15fcf9a61d 100644 --- a/src/promptflow-devkit/promptflow/_version.py +++ b/src/promptflow-azure/promptflow/azure/_cli/_user_agent.py @@ -2,4 +2,6 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- -VERSION = "0.0.1" +from promptflow.azure._version import VERSION + +USER_AGENT = "{}/{}".format("promptflow-azure-cli", VERSION) diff --git a/src/promptflow-azure/promptflow/azure/_cli/entry.py b/src/promptflow-azure/promptflow/azure/_cli/entry.py index 14113c8d06b..d0a60927042 100644 --- a/src/promptflow-azure/promptflow/azure/_cli/entry.py +++ b/src/promptflow-azure/promptflow/azure/_cli/entry.py @@ -6,8 +6,8 @@ import time from promptflow._cli._pf.help import show_privacy_statement, show_welcome_message -from promptflow._cli._user_agent import USER_AGENT from promptflow._cli._utils import _get_cli_activity_name, cli_exception_and_telemetry_handler, get_client_info_for_cli +from promptflow.azure._cli._user_agent import USER_AGENT # Log the start time start_time = time.perf_counter() diff --git a/src/promptflow-azure/promptflow/azure/_pf_client.py b/src/promptflow-azure/promptflow/azure/_pf_client.py index a81c370015f..7da2b2be57d 100644 --- a/src/promptflow-azure/promptflow/azure/_pf_client.py +++ b/src/promptflow-azure/promptflow/azure/_pf_client.py @@ -10,7 +10,6 @@ from promptflow._sdk._constants import MAX_SHOW_DETAILS_RESULTS from promptflow._sdk._errors import RunOperationParameterError -from promptflow._sdk._user_agent import USER_AGENT from promptflow._sdk._utils import generate_yaml_entry from promptflow._sdk.entities import Run from promptflow._utils.user_agent_utils import ClientUserAgentUtil, setup_user_agent_to_operation_context @@ -22,6 +21,8 @@ from promptflow.azure.operations._trace_operations import TraceOperations from promptflow.exceptions import UserErrorException +from ._user_agent import USER_AGENT + class PFClient: """A client class to interact with Promptflow service. diff --git a/src/promptflow-azure/promptflow/azure/_user_agent.py b/src/promptflow-azure/promptflow/azure/_user_agent.py new file mode 100644 index 00000000000..a7ac703f3d3 --- /dev/null +++ b/src/promptflow-azure/promptflow/azure/_user_agent.py @@ -0,0 +1,7 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- + +from promptflow.azure._version import VERSION + +USER_AGENT = "{}/{}".format("promptflow-azure-sdk", VERSION) diff --git a/src/promptflow-azure/promptflow/azure/_version.py b/src/promptflow-azure/promptflow/azure/_version.py new file mode 100644 index 00000000000..95fbe8cf1c7 --- /dev/null +++ b/src/promptflow-azure/promptflow/azure/_version.py @@ -0,0 +1,9 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- + +import importlib.metadata + +__version__ = importlib.metadata.version("promptflow-azure") + +VERSION: str = __version__ diff --git a/src/promptflow-azure/promptflow/azure/operations/_flow_operations.py b/src/promptflow-azure/promptflow/azure/operations/_flow_operations.py index 486b5584043..5e9ade0ec52 100644 --- a/src/promptflow-azure/promptflow/azure/operations/_flow_operations.py +++ b/src/promptflow-azure/promptflow/azure/operations/_flow_operations.py @@ -208,7 +208,7 @@ def _update_azure_flow(self, flow: Flow, display_name, **kwargs): @staticmethod def _validate_flow_creation_parameters(source, flow_display_name=None, flow_type=None, **kwargs): """Validate the parameters for flow creation operation.""" - from promptflow._sdk.entities._flow import FlexFlow + from promptflow._sdk.entities._flows import FlexFlow from promptflow.client import load_flow as load_local_flow # validate the source folder @@ -256,7 +256,7 @@ def _validate_flow_creation_parameters(source, flow_display_name=None, flow_type @staticmethod def _validate_flow_schema(source, display_name=None, type=None, **kwargs): """Validate the flow schema.""" - from promptflow._sdk.entities._flow import Flow + from promptflow._sdk.entities._flows import Flow params_override = copy.deepcopy(kwargs) if display_name is not None: diff --git a/src/promptflow-core/promptflow/_constants.py b/src/promptflow-core/promptflow/_constants.py index f81b9588943..e438e9a2bb1 100644 --- a/src/promptflow-core/promptflow/_constants.py +++ b/src/promptflow-core/promptflow/_constants.py @@ -262,6 +262,10 @@ class ConnectionProviderConfig: AZUREML = "azureml" +AZURE_WORKSPACE_REGEX_FORMAT = ( + "^azureml:[/]{1,2}subscriptions/([^/]+)/resource(groups|Groups)/([^/]+)" + "(/providers/Microsoft.MachineLearningServices)?/workspaces/([^/]+)$" +) CONNECTION_DATA_CLASS_KEY = "DATA_CLASS" FLEX_FLOW_PUBLIC_NAME = "flex" diff --git a/src/promptflow-core/promptflow/core/_connection_provider/_connection_provider.py b/src/promptflow-core/promptflow/core/_connection_provider/_connection_provider.py index de83927b789..25eb8fe6c6f 100644 --- a/src/promptflow-core/promptflow/core/_connection_provider/_connection_provider.py +++ b/src/promptflow-core/promptflow/core/_connection_provider/_connection_provider.py @@ -28,9 +28,7 @@ def init_from_provider_config(cls, provider_config: str, credential=None): try: from promptflow._sdk._connection_provider._local_connection_provider import LocalConnectionProvider except ImportError as e: - raise MissingRequiredPackage( - message="Please install 'promptflow-devkit' to use local connection." - ) from e + raise MissingRequiredPackage(message="Please install 'promptflow' to use local connection.") from e return LocalConnectionProvider() if provider_config.startswith(ConnectionProviderConfig.AZUREML): from promptflow.core._connection_provider._workspace_connection_provider import WorkspaceConnectionProvider diff --git a/src/promptflow-core/promptflow/core/_connection_provider/_utils.py b/src/promptflow-core/promptflow/core/_connection_provider/_utils.py index 372a3a2e975..fe07f22e692 100644 --- a/src/promptflow-core/promptflow/core/_connection_provider/_utils.py +++ b/src/promptflow-core/promptflow/core/_connection_provider/_utils.py @@ -5,7 +5,7 @@ import re from promptflow._constants import PF_NO_INTERACTIVE_LOGIN -from promptflow._sdk._constants import AZURE_WORKSPACE_REGEX_FORMAT +from promptflow._constants import AZURE_WORKSPACE_REGEX_FORMAT from promptflow._utils.user_agent_utils import ClientUserAgentUtil from promptflow.core._errors import MalformedConnectionProviderConfig, MissingRequiredPackage from promptflow.exceptions import ValidationException diff --git a/src/promptflow-core/promptflow/core/_version.py b/src/promptflow-core/promptflow/core/_version.py index f8cedcc6bd9..0d9ed9ee627 100644 --- a/src/promptflow-core/promptflow/core/_version.py +++ b/src/promptflow-core/promptflow/core/_version.py @@ -5,3 +5,5 @@ import importlib.metadata __version__ = importlib.metadata.version("promptflow-core") + +VERSION: str = __version__ diff --git a/src/promptflow-devkit/promptflow/_cli/_pf/entry.py b/src/promptflow-devkit/promptflow/_cli/_pf/entry.py index 923e5e71d7e..2b33fd029b5 100644 --- a/src/promptflow-devkit/promptflow/_cli/_pf/entry.py +++ b/src/promptflow-devkit/promptflow/_cli/_pf/entry.py @@ -28,7 +28,14 @@ from promptflow._cli._pf._upgrade import add_upgrade_parser, upgrade_version # noqa: E402 from promptflow._cli._pf.help import show_privacy_statement, show_welcome_message # noqa: E402 from promptflow._cli._user_agent import USER_AGENT # noqa: E402 -from promptflow._sdk._utils import get_promptflow_sdk_version, print_pf_version # noqa: E402 +from promptflow._sdk._utils import ( # noqa: E402 + get_promptflow_azure_version, + get_promptflow_core_version, + get_promptflow_devkit_version, + get_promptflow_sdk_version, + get_promptflow_tracing_version, + print_pf_version, +) from promptflow._utils.logger_utils import get_cli_sdk_logger # noqa: E402 from promptflow._utils.user_agent_utils import setup_user_agent_to_operation_context # noqa: E402 @@ -132,6 +139,23 @@ def main(): command_args = sys.argv[1:] if len(command_args) == 1 and command_args[0] == "version": version_dict = {"promptflow": get_promptflow_sdk_version()} + # check tracing version + version_tracing = get_promptflow_tracing_version() + if version_tracing: + version_dict["promptflow-tracing"] = version_tracing + # check azure version + version_azure = get_promptflow_azure_version() + if version_azure: + version_dict["promptflow-azure"] = version_azure + # check core version + version_core = get_promptflow_core_version() + if version_core: + version_dict["promptflow-core"] = version_core + # check devkit version + version_devkit = get_promptflow_devkit_version() + if version_devkit: + version_dict["promptflow-devkit"] = version_devkit + version_dict_string = ( json.dumps(version_dict, ensure_ascii=False, indent=2, sort_keys=True, separators=(",", ": ")) + "\n" ) diff --git a/src/promptflow-devkit/promptflow/_cli/_user_agent.py b/src/promptflow-devkit/promptflow/_cli/_user_agent.py index 473263d12e2..6eb7b28e288 100644 --- a/src/promptflow-devkit/promptflow/_cli/_user_agent.py +++ b/src/promptflow-devkit/promptflow/_cli/_user_agent.py @@ -1,6 +1,6 @@ # --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- -from promptflow._version import VERSION +from promptflow._sdk._version import VERSION USER_AGENT = "{}/{}".format("promptflow-cli", VERSION) diff --git a/src/promptflow-devkit/promptflow/_internal/__init__.py b/src/promptflow-devkit/promptflow/_internal/__init__.py index 1e67a783601..94258b68fb4 100644 --- a/src/promptflow-devkit/promptflow/_internal/__init__.py +++ b/src/promptflow-devkit/promptflow/_internal/__init__.py @@ -93,7 +93,7 @@ set_context, transpose, ) -from promptflow._version import VERSION +from promptflow._sdk._version import VERSION from promptflow.core._serving.response_creator import ResponseCreator from promptflow.core._serving.swagger import generate_swagger from promptflow.core._serving.utils import ( diff --git a/src/promptflow-devkit/promptflow/_sdk/_constants.py b/src/promptflow-devkit/promptflow/_sdk/_constants.py index 825fc3f2bae..9018c7e9b96 100644 --- a/src/promptflow-devkit/promptflow/_sdk/_constants.py +++ b/src/promptflow-devkit/promptflow/_sdk/_constants.py @@ -14,6 +14,7 @@ ConnectionAuthMode, ConnectionType, CustomStrongTypeConnectionConfigs, + AZURE_WORKSPACE_REGEX_FORMAT ) LOGGER_NAME = "promptflow" @@ -119,10 +120,7 @@ def _prepare_home_dir() -> Path: WORKSPACE_LINKED_DATASTORE_NAME = "workspaceblobstore" LINE_NUMBER = "line_number" AZUREML_PF_RUN_PROPERTIES_LINEAGE = "azureml.promptflow.input_run_id" -AZURE_WORKSPACE_REGEX_FORMAT = ( - "^azureml:[/]{1,2}subscriptions/([^/]+)/resource(groups|Groups)/([^/]+)" - "(/providers/Microsoft.MachineLearningServices)?/workspaces/([^/]+)$" -) +AZURE_WORKSPACE_REGEX_FORMAT = AZURE_WORKSPACE_REGEX_FORMAT DEFAULT_ENCODING = "utf-8" LOCAL_STORAGE_BATCH_SIZE = 1 LOCAL_SERVICE_PORT = 5000 diff --git a/src/promptflow-devkit/promptflow/_sdk/_load_functions.py b/src/promptflow-devkit/promptflow/_sdk/_load_functions.py index 1eedf1fb1d0..2fee3ed8cee 100644 --- a/src/promptflow-devkit/promptflow/_sdk/_load_functions.py +++ b/src/promptflow-devkit/promptflow/_sdk/_load_functions.py @@ -15,7 +15,7 @@ from .entities import Run from .entities._connection import CustomConnection, _Connection from .entities._experiment import Experiment, ExperimentTemplate -from .entities._flow import Flow +from .entities._flows import Flow logger = get_cli_sdk_logger() @@ -79,7 +79,7 @@ def load_flow( An exception is raised if the file does not exist. :type source: Union[PathLike, str] :return: A Flow object - :rtype: ~promptflow._sdk.entities._flow.Flow + :rtype: ~promptflow._sdk.entities._flows.Flow """ return Flow.load(source, **kwargs) diff --git a/src/promptflow-devkit/promptflow/_sdk/_mlflow.py b/src/promptflow-devkit/promptflow/_sdk/_mlflow.py index d30ff3afbcd..03e9ca63243 100644 --- a/src/promptflow-devkit/promptflow/_sdk/_mlflow.py +++ b/src/promptflow-devkit/promptflow/_sdk/_mlflow.py @@ -8,7 +8,7 @@ from promptflow._sdk._constants import DAG_FILE_NAME from promptflow._sdk._orchestrator import remove_additional_includes from promptflow._sdk._utils import _merge_local_code_and_additional_includes -from promptflow._sdk.entities._flow import Flow +from promptflow._sdk.entities._flows import Flow from promptflow.core._serving.flow_invoker import FlowInvoker __all__ = [ diff --git a/src/promptflow-devkit/promptflow/_sdk/_orchestrator/run_submitter.py b/src/promptflow-devkit/promptflow/_sdk/_orchestrator/run_submitter.py index 7e2f76e828c..46d4bcfd93a 100644 --- a/src/promptflow-devkit/promptflow/_sdk/_orchestrator/run_submitter.py +++ b/src/promptflow-devkit/promptflow/_sdk/_orchestrator/run_submitter.py @@ -9,7 +9,7 @@ from promptflow._constants import FlowLanguage from promptflow._sdk._constants import ContextAttributeKey, FlowRunProperties -from promptflow._sdk.entities._flow import Flow +from promptflow._sdk.entities._flows import Flow from promptflow._sdk.entities._run import Run from promptflow._sdk.operations._local_storage_operations import LocalStorageOperations from promptflow._utils.context_utils import _change_working_dir @@ -23,7 +23,7 @@ from .._configuration import Configuration from .._load_functions import load_flow -from ..entities._flow import FlexFlow +from ..entities._flows import FlexFlow from .utils import SubmitterHelper, variant_overwrite_context logger = LoggerFactory.get_logger(name=__name__) diff --git a/src/promptflow-devkit/promptflow/_sdk/_orchestrator/test_submitter.py b/src/promptflow-devkit/promptflow/_sdk/_orchestrator/test_submitter.py index 5eb589bf175..49a63a335f1 100644 --- a/src/promptflow-devkit/promptflow/_sdk/_orchestrator/test_submitter.py +++ b/src/promptflow-devkit/promptflow/_sdk/_orchestrator/test_submitter.py @@ -15,7 +15,7 @@ from promptflow._internal import ConnectionManager from promptflow._proxy import ProxyFactory from promptflow._sdk._constants import PROMPT_FLOW_DIR_NAME -from promptflow._sdk.entities._flow import Flow, FlowContext +from promptflow._sdk.entities._flows import Flow, FlowContext from promptflow._sdk.operations._local_storage_operations import LoggerOperations from promptflow._utils.async_utils import async_run_allowing_running_loop from promptflow._utils.context_utils import _change_working_dir @@ -30,7 +30,7 @@ from promptflow.storage._run_storage import DefaultRunStorage from .._configuration import Configuration -from ..entities._flow import FlexFlow +from ..entities._flows import FlexFlow from .utils import ( SubmitterHelper, print_chat_output, diff --git a/src/promptflow-devkit/promptflow/_sdk/_orchestrator/utils.py b/src/promptflow-devkit/promptflow/_sdk/_orchestrator/utils.py index 0b4ff379fed..f32e1d1f76e 100644 --- a/src/promptflow-devkit/promptflow/_sdk/_orchestrator/utils.py +++ b/src/promptflow-devkit/promptflow/_sdk/_orchestrator/utils.py @@ -41,7 +41,7 @@ from promptflow._sdk._errors import InvalidFlowError, RunOperationError from promptflow._sdk._load_functions import load_flow from promptflow._sdk._utils import _merge_local_code_and_additional_includes -from promptflow._sdk.entities._flow import FlexFlow, Flow +from promptflow._sdk.entities._flows import FlexFlow, Flow from promptflow._utils.flow_utils import dump_flow_dag, load_flow_dag from promptflow._utils.logger_utils import FileHandler, get_cli_sdk_logger from promptflow.contracts.flow import Flow as ExecutableFlow diff --git a/src/promptflow-devkit/promptflow/_sdk/_pf_client.py b/src/promptflow-devkit/promptflow/_sdk/_pf_client.py index 2ecb3db70a9..7ab41b24f54 100644 --- a/src/promptflow-devkit/promptflow/_sdk/_pf_client.py +++ b/src/promptflow-devkit/promptflow/_sdk/_pf_client.py @@ -17,7 +17,7 @@ from ._user_agent import USER_AGENT from ._utils import generate_yaml_entry from .entities import Run -from .entities._flow import FlexFlow +from .entities._flows import FlexFlow from .operations import RunOperations from .operations._connection_operations import ConnectionOperations from .operations._experiment_operations import ExperimentOperations diff --git a/src/promptflow-devkit/promptflow/_sdk/_service/utils/utils.py b/src/promptflow-devkit/promptflow/_sdk/_service/utils/utils.py index cc9f744748c..5da77717b51 100644 --- a/src/promptflow-devkit/promptflow/_sdk/_service/utils/utils.py +++ b/src/promptflow-devkit/promptflow/_sdk/_service/utils/utils.py @@ -31,7 +31,7 @@ from promptflow._sdk._utils import get_promptflow_sdk_version, read_write_by_user from promptflow._utils.logger_utils import get_cli_sdk_logger from promptflow._utils.yaml_utils import dump_yaml, load_yaml -from promptflow._version import VERSION +from promptflow._sdk._version import VERSION from promptflow.exceptions import PromptflowException, UserErrorException logger = get_cli_sdk_logger() diff --git a/src/promptflow-devkit/promptflow/_sdk/_user_agent.py b/src/promptflow-devkit/promptflow/_sdk/_user_agent.py index dde64872ad5..38f541384e3 100644 --- a/src/promptflow-devkit/promptflow/_sdk/_user_agent.py +++ b/src/promptflow-devkit/promptflow/_sdk/_user_agent.py @@ -1,6 +1,6 @@ # --------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # --------------------------------------------------------- -from promptflow._version import VERSION +from promptflow._sdk._version import VERSION USER_AGENT = "{}/{}".format("promptflow-sdk", VERSION) diff --git a/src/promptflow-devkit/promptflow/_sdk/_utils.py b/src/promptflow-devkit/promptflow/_sdk/_utils.py index 2253c506c9c..35d45203c09 100644 --- a/src/promptflow-devkit/promptflow/_sdk/_utils.py +++ b/src/promptflow-devkit/promptflow/_sdk/_utils.py @@ -328,13 +328,63 @@ def incremental_print(log: str, printed: int, fileout) -> int: def get_promptflow_sdk_version() -> str: try: return promptflow.__version__ - except AttributeError: + except ImportError: # if promptflow is installed from source, it does not have __version__ attribute - return "0.0.1" + return None + + +def get_promptflow_tracing_version() -> Union[str, None]: + try: + from promptflow.tracing._version import __version__ + + return __version__ + except ImportError: + return None + + +def get_promptflow_core_version() -> Union[str, None]: + try: + from promptflow.core._version import __version__ + + return __version__ + except ImportError: + return None + + +def get_promptflow_devkit_version() -> Union[str, None]: + try: + from promptflow._sdk._version import __version__ + + return __version__ + except ImportError: + return None + + +def get_promptflow_azure_version() -> Union[str, None]: + try: + from promptflow.azure._version import __version__ + + return __version__ + except ImportError: + return None def print_pf_version(): - print("promptflow\t\t\t {}".format(get_promptflow_sdk_version())) + version_promptflow = get_promptflow_sdk_version() + if version_promptflow: + print("promptflow\t\t\t {}".format(version_promptflow)) + version_tracing = get_promptflow_tracing_version() + if version_tracing: + print("promptflow-tracing\t\t {}".format(version_tracing)) + version_core = get_promptflow_core_version() + if version_core: + print("promptflow-core\t\t\t {}".format(version_core)) + version_devkit = get_promptflow_devkit_version() + if version_devkit: + print("promptflow-devkit\t\t {}".format(version_devkit)) + version_azure = get_promptflow_azure_version() + if version_azure: + print("promptflow-azure\t\t {}".format(version_azure)) print() print("Executable '{}'".format(os.path.abspath(sys.executable))) print("Python ({}) {}".format(platform.system(), sys.version)) diff --git a/src/promptflow-devkit/promptflow/_sdk/_version.py b/src/promptflow-devkit/promptflow/_sdk/_version.py new file mode 100644 index 00000000000..698b806fe83 --- /dev/null +++ b/src/promptflow-devkit/promptflow/_sdk/_version.py @@ -0,0 +1,9 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- + +import importlib.metadata + +__version__ = importlib.metadata.version("promptflow-devkit") + +VERSION: str = __version__ diff --git a/src/promptflow-devkit/promptflow/_sdk/entities/__init__.py b/src/promptflow-devkit/promptflow/_sdk/entities/__init__.py index da06d3173f3..36e7555c846 100644 --- a/src/promptflow-devkit/promptflow/_sdk/entities/__init__.py +++ b/src/promptflow-devkit/promptflow/_sdk/entities/__init__.py @@ -20,7 +20,7 @@ ) from ._run import Run from ._validation import ValidationResult -from ._flow import FlowContext +from ._flows import FlowContext __all__ = [ # region: Connection diff --git a/src/promptflow-devkit/promptflow/_sdk/entities/_flow/__init__.py b/src/promptflow-devkit/promptflow/_sdk/entities/_flows/__init__.py similarity index 100% rename from src/promptflow-devkit/promptflow/_sdk/entities/_flow/__init__.py rename to src/promptflow-devkit/promptflow/_sdk/entities/_flows/__init__.py diff --git a/src/promptflow-devkit/promptflow/_sdk/entities/_flow/_flow_context_resolver.py b/src/promptflow-devkit/promptflow/_sdk/entities/_flows/_flow_context_resolver.py similarity index 99% rename from src/promptflow-devkit/promptflow/_sdk/entities/_flow/_flow_context_resolver.py rename to src/promptflow-devkit/promptflow/_sdk/entities/_flows/_flow_context_resolver.py index a676e5c7310..fa67a1adbf9 100644 --- a/src/promptflow-devkit/promptflow/_sdk/entities/_flow/_flow_context_resolver.py +++ b/src/promptflow-devkit/promptflow/_sdk/entities/_flows/_flow_context_resolver.py @@ -10,7 +10,7 @@ from promptflow._sdk._configuration import Configuration from promptflow._sdk._constants import NODES from promptflow._sdk.entities import FlowContext -from promptflow._sdk.entities._flow import Flow +from promptflow._sdk.entities._flows import Flow from promptflow._utils.flow_utils import load_flow_dag, parse_variant from promptflow._utils.yaml_utils import dump_yaml from promptflow.contracts.flow import Node diff --git a/src/promptflow-devkit/promptflow/_sdk/entities/_flow/base.py b/src/promptflow-devkit/promptflow/_sdk/entities/_flows/base.py similarity index 99% rename from src/promptflow-devkit/promptflow/_sdk/entities/_flow/base.py rename to src/promptflow-devkit/promptflow/_sdk/entities/_flows/base.py index 254ca898134..a6d1900ae3b 100644 --- a/src/promptflow-devkit/promptflow/_sdk/entities/_flow/base.py +++ b/src/promptflow-devkit/promptflow/_sdk/entities/_flows/base.py @@ -245,7 +245,7 @@ def __call__(self, *args, **kwargs): def invoke(self, inputs: dict) -> "LineResult": """Invoke a flow and get a LineResult object.""" - from promptflow._sdk.entities._flow._flow_context_resolver import FlowContextResolver + from promptflow._sdk.entities._flows._flow_context_resolver import FlowContextResolver invoker = FlowContextResolver.resolve(flow=self) result = invoker._invoke( diff --git a/src/promptflow-devkit/promptflow/_sdk/entities/_flow/dag.py b/src/promptflow-devkit/promptflow/_sdk/entities/_flows/dag.py similarity index 100% rename from src/promptflow-devkit/promptflow/_sdk/entities/_flow/dag.py rename to src/promptflow-devkit/promptflow/_sdk/entities/_flows/dag.py diff --git a/src/promptflow-devkit/promptflow/_sdk/entities/_flow/flex.py b/src/promptflow-devkit/promptflow/_sdk/entities/_flows/flex.py similarity index 100% rename from src/promptflow-devkit/promptflow/_sdk/entities/_flow/flex.py rename to src/promptflow-devkit/promptflow/_sdk/entities/_flows/flex.py diff --git a/src/promptflow-devkit/promptflow/_sdk/entities/_run.py b/src/promptflow-devkit/promptflow/_sdk/entities/_run.py index 6ba4fa5d867..20bbde90744 100644 --- a/src/promptflow-devkit/promptflow/_sdk/entities/_run.py +++ b/src/promptflow-devkit/promptflow/_sdk/entities/_run.py @@ -762,7 +762,7 @@ def _flow_type(self) -> str: from promptflow._constants import FlowType from promptflow._sdk._load_functions import load_flow - from promptflow._sdk.entities._flow import FlexFlow + from promptflow._sdk.entities._flows import FlexFlow flow_obj = load_flow(source=self.flow) if isinstance(flow_obj, FlexFlow): diff --git a/src/promptflow-devkit/promptflow/_sdk/operations/_connection_operations.py b/src/promptflow-devkit/promptflow/_sdk/operations/_connection_operations.py index 5e5e5b77ccb..c8c83341585 100644 --- a/src/promptflow-devkit/promptflow/_sdk/operations/_connection_operations.py +++ b/src/promptflow-devkit/promptflow/_sdk/operations/_connection_operations.py @@ -80,7 +80,7 @@ def _convert_core_connection_to_sdk_connection(cls, core_conn): if sdk_conn_cls is None: raise ConnectionClassNotFoundError( f"Correspond sdk connection type not found for core connection type: {core_conn.type!r}, " - f"please install the latest 'promptflow-devkit' and 'promptflow-core'." + f"please re-install the 'promptflow' package." ) common_args = { "name": core_conn.name, diff --git a/src/promptflow-devkit/promptflow/_sdk/operations/_flow_operations.py b/src/promptflow-devkit/promptflow/_sdk/operations/_flow_operations.py index 3d973414f2b..b7074f55484 100644 --- a/src/promptflow-devkit/promptflow/_sdk/operations/_flow_operations.py +++ b/src/promptflow-devkit/promptflow/_sdk/operations/_flow_operations.py @@ -34,7 +34,7 @@ json_load, logger, ) -from promptflow._sdk.entities._flow import FlexFlow, Flow +from promptflow._sdk.entities._flows import FlexFlow, Flow from promptflow._sdk.entities._validation import ValidationResult from promptflow._utils.context_utils import _change_working_dir from promptflow._utils.flow_utils import dump_flow_result, is_executable_chat_flow, is_flex_flow, parse_variant diff --git a/src/promptflow-devkit/promptflow/_sdk/operations/_local_storage_operations.py b/src/promptflow-devkit/promptflow/_sdk/operations/_local_storage_operations.py index 00b1d154c38..3694990cf5e 100644 --- a/src/promptflow-devkit/promptflow/_sdk/operations/_local_storage_operations.py +++ b/src/promptflow-devkit/promptflow/_sdk/operations/_local_storage_operations.py @@ -36,7 +36,7 @@ write_open, ) from promptflow._sdk.entities import Run -from promptflow._sdk.entities._flow import FlexFlow, Flow +from promptflow._sdk.entities._flows import FlexFlow, Flow from promptflow._utils.exception_utils import PromptflowExceptionPresenter from promptflow._utils.logger_utils import LogContext, get_cli_sdk_logger from promptflow._utils.multimedia_utils import MultimediaProcessor diff --git a/src/promptflow-devkit/promptflow/entities/__init__.py b/src/promptflow-devkit/promptflow/entities/__init__.py index e6568ef9505..3a9deb31813 100644 --- a/src/promptflow-devkit/promptflow/entities/__init__.py +++ b/src/promptflow-devkit/promptflow/entities/__init__.py @@ -18,7 +18,7 @@ ) from promptflow._sdk.entities._run import Run from promptflow._core.tool import InputSetting, DynamicList -from promptflow._sdk.entities._flow import FlowContext +from promptflow._sdk.entities._flows import FlowContext __all__ = [ # region Connection diff --git a/src/promptflow/tests/sdk_cli_azure_test/conftest.py b/src/promptflow/tests/sdk_cli_azure_test/conftest.py index 4db847fe5d9..8d983e403c1 100644 --- a/src/promptflow/tests/sdk_cli_azure_test/conftest.py +++ b/src/promptflow/tests/sdk_cli_azure_test/conftest.py @@ -180,7 +180,7 @@ def remote_client(subscription_id: str, resource_group_name: str, workspace_name resource_group_name=resource_group_name, workspace_name=workspace_name, ) - assert "promptflow-sdk" in ClientUserAgentUtil.get_user_agent() + assert "promptflow-azure-sdk" in ClientUserAgentUtil.get_user_agent() assert "promptflow-test" not in ClientUserAgentUtil.get_user_agent() yield client diff --git a/src/promptflow/tests/sdk_cli_azure_test/e2etests/test_cli_with_azure.py b/src/promptflow/tests/sdk_cli_azure_test/e2etests/test_cli_with_azure.py index b86b002b72f..62c76ffed19 100644 --- a/src/promptflow/tests/sdk_cli_azure_test/e2etests/test_cli_with_azure.py +++ b/src/promptflow/tests/sdk_cli_azure_test/e2etests/test_cli_with_azure.py @@ -168,7 +168,7 @@ def test_azure_cli_ua(self, pf: PFClient): ) user_agent = ClientUserAgentUtil.get_user_agent() ua_dict = parse_ua_to_dict(user_agent) - assert ua_dict.keys() == {"promptflow-sdk", "promptflow-cli"} + assert ua_dict.keys() == {"promptflow-azure-sdk", "promptflow-azure-cli"} def test_cli_telemetry(self, pf, runtime: str, randstr: Callable[[str], str]) -> None: name = randstr("name") diff --git a/src/promptflow/tests/sdk_cli_azure_test/e2etests/test_telemetry.py b/src/promptflow/tests/sdk_cli_azure_test/e2etests/test_telemetry.py index 393c3923c0c..08954802339 100644 --- a/src/promptflow/tests/sdk_cli_azure_test/e2etests/test_telemetry.py +++ b/src/promptflow/tests/sdk_cli_azure_test/e2etests/test_telemetry.py @@ -227,7 +227,7 @@ def test_sdk_telemetry_ua(self, pf): def assert_ua(*args, **kwargs): ua = pydash.get(kwargs, "extra.custom_dimensions.user_agent", None) ua_dict = parse_ua_to_dict(ua) - assert ua_dict.keys() == {"promptflow-sdk"} + assert "promptflow-sdk" in ua_dict.keys() logger = MagicMock() logger.info = MagicMock() @@ -259,7 +259,8 @@ def assert_ua(*args, **kwargs): ) user_agent = ClientUserAgentUtil.get_user_agent() ua_dict = parse_ua_to_dict(user_agent) - assert ua_dict.keys() == {"promptflow-sdk"} + # multiple sdk agent since shared Operation Context + assert ua_dict.keys() == {"promptflow-azure-sdk", "promptflow-sdk"} # Call log_activity with log_activity(logger, "test_activity", activity_type=ActivityType.PUBLICAPI): @@ -275,7 +276,8 @@ def assert_ua(*args, **kwargs): ) user_agent = ClientUserAgentUtil.get_user_agent() ua_dict = parse_ua_to_dict(user_agent) - assert ua_dict.keys() == {"promptflow-sdk", "a"} + # multiple sdk agent since shared Operation Context + assert ua_dict.keys() == {"promptflow-sdk", "promptflow-azure-sdk", "a"} context = OperationContext().get_instance() context.user_agent = "" diff --git a/src/promptflow/tests/sdk_cli_global_config_test/e2etests/test_global_config.py b/src/promptflow/tests/sdk_cli_global_config_test/e2etests/test_global_config.py index cf528f63003..30391b1fdb1 100644 --- a/src/promptflow/tests/sdk_cli_global_config_test/e2etests/test_global_config.py +++ b/src/promptflow/tests/sdk_cli_global_config_test/e2etests/test_global_config.py @@ -4,7 +4,7 @@ import pytest from promptflow._sdk._load_functions import load_flow -from promptflow._sdk.entities._flow._flow_context_resolver import FlowContextResolver +from promptflow._sdk.entities._flows._flow_context_resolver import FlowContextResolver from promptflow.core._connection_provider._workspace_connection_provider import WorkspaceConnectionProvider FLOWS_DIR = Path(__file__).parent.parent.parent / "test_configs" / "flows" diff --git a/src/promptflow/tests/sdk_cli_test/e2etests/test_flow_as_func.py b/src/promptflow/tests/sdk_cli_test/e2etests/test_flow_as_func.py index 32d3dc12508..53a1c71ee16 100644 --- a/src/promptflow/tests/sdk_cli_test/e2etests/test_flow_as_func.py +++ b/src/promptflow/tests/sdk_cli_test/e2etests/test_flow_as_func.py @@ -14,7 +14,7 @@ from promptflow import load_flow from promptflow._sdk._errors import ConnectionNotFoundError, InvalidFlowError from promptflow._sdk.entities import CustomConnection -from promptflow._sdk.entities._flow._flow_context_resolver import FlowContextResolver +from promptflow._sdk.entities._flows._flow_context_resolver import FlowContextResolver from promptflow._utils.flow_utils import dump_flow_dag, load_flow_dag from promptflow.entities import FlowContext from promptflow.exceptions import UserErrorException diff --git a/src/promptflow/tests/sdk_cli_test/unittests/test_flow.py b/src/promptflow/tests/sdk_cli_test/unittests/test_flow.py index 5f981b3d2c3..fdb0fb0fe3c 100644 --- a/src/promptflow/tests/sdk_cli_test/unittests/test_flow.py +++ b/src/promptflow/tests/sdk_cli_test/unittests/test_flow.py @@ -7,7 +7,7 @@ from marshmallow import ValidationError from promptflow import load_flow -from promptflow._sdk.entities._flow import FlexFlow, Flow +from promptflow._sdk.entities._flows import FlexFlow, Flow FLOWS_DIR = Path("./tests/test_configs/flows") EAGER_FLOWS_DIR = Path("./tests/test_configs/eager_flows") diff --git a/src/promptflow/tests/sdk_cli_test/unittests/test_mlflow_dependencies.py b/src/promptflow/tests/sdk_cli_test/unittests/test_mlflow_dependencies.py index ddd542b9ea0..5e96cf62d44 100644 --- a/src/promptflow/tests/sdk_cli_test/unittests/test_mlflow_dependencies.py +++ b/src/promptflow/tests/sdk_cli_test/unittests/test_mlflow_dependencies.py @@ -12,7 +12,7 @@ class TestMLFlowDependencies: def test_mlflow_dependencies(self): assert module.DAG_FILE_NAME == "flow.dag.yaml" - assert module.Flow == promptflow._sdk.entities._flow.Flow + assert module.Flow == promptflow._sdk.entities._flows.Flow assert module.FlowInvoker == promptflow.core._serving.flow_invoker.FlowInvoker assert module.remove_additional_includes is not None assert module._merge_local_code_and_additional_includes is not None diff --git a/src/promptflow/tests/sdk_cli_test/unittests/test_run.py b/src/promptflow/tests/sdk_cli_test/unittests/test_run.py index 574687950f2..2943c2e660a 100644 --- a/src/promptflow/tests/sdk_cli_test/unittests/test_run.py +++ b/src/promptflow/tests/sdk_cli_test/unittests/test_run.py @@ -16,7 +16,7 @@ from promptflow._sdk._run_functions import create_yaml_run from promptflow._sdk._utils import callable_to_entry_string from promptflow._sdk.entities import Run -from promptflow._sdk.entities._flow import Flow +from promptflow._sdk.entities._flows import Flow from promptflow._sdk.operations._local_storage_operations import LocalStorageOperations from promptflow._utils.context_utils import inject_sys_path from promptflow._utils.yaml_utils import load_yaml diff --git a/src/promptflow/tests/sdk_pfs_test/e2etests/test_connection_apis.py b/src/promptflow/tests/sdk_pfs_test/e2etests/test_connection_apis.py index 85d4e33c538..4e002a74b70 100644 --- a/src/promptflow/tests/sdk_pfs_test/e2etests/test_connection_apis.py +++ b/src/promptflow/tests/sdk_pfs_test/e2etests/test_connection_apis.py @@ -11,6 +11,7 @@ from promptflow import PFClient from promptflow._sdk.entities import CustomConnection +from promptflow._sdk._version import VERSION from promptflow.recording.record_mode import is_replay from ..utils import PFSOperations, check_activity_end_telemetry @@ -34,7 +35,7 @@ def test_list_connections(self, pf_client: PFClient, pfs_op: PFSOperations) -> N def test_list_connections_with_different_user_agent(self, pf_client: PFClient, pfs_op: PFSOperations) -> None: create_custom_connection(pf_client) - base_user_agent = ["local_pfs/0.0.1"] + base_user_agent = [f"local_pfs/{VERSION}"] for _, extra_user_agent in enumerate( [ ["another_test_user_agent/0.0.1"], diff --git a/src/promptflow/tests/sdk_pfs_test/e2etests/test_telemetry_apis.py b/src/promptflow/tests/sdk_pfs_test/e2etests/test_telemetry_apis.py index 5610341c13c..09b14912e5c 100644 --- a/src/promptflow/tests/sdk_pfs_test/e2etests/test_telemetry_apis.py +++ b/src/promptflow/tests/sdk_pfs_test/e2etests/test_telemetry_apis.py @@ -4,6 +4,8 @@ import pytest +from promptflow._sdk._version import VERSION + from ..utils import PFSOperations, check_activity_end_telemetry @@ -34,7 +36,7 @@ def test_post_telemetry(self, pfs_op: PFSOperations) -> None: with check_activity_end_telemetry( activity_name="pf.flow.test", activity_type="InternalCall", - user_agent=f"{user_agent} local_pfs/0.0.1", + user_agent=f"{user_agent} local_pfs/{VERSION}", request_id=request_id, ): response = pfs_op.create_telemetry( diff --git a/src/promptflow/tests/sdk_pfs_test/utils.py b/src/promptflow/tests/sdk_pfs_test/utils.py index 0741d4b7238..141e0bbe4fa 100644 --- a/src/promptflow/tests/sdk_pfs_test/utils.py +++ b/src/promptflow/tests/sdk_pfs_test/utils.py @@ -11,6 +11,7 @@ from flask.testing import FlaskClient from promptflow._sdk._service.utils.utils import encrypt_flow_path +from promptflow._sdk._version import VERSION @contextlib.contextmanager @@ -33,7 +34,7 @@ def check_activity_end_telemetry( "first_call": True, "activity_type": "PublicApi", "completion_status": "Success", - "user_agent": [f"Werkzeug/{werkzeug.__version__}", "local_pfs/0.0.1"], + "user_agent": [f"Werkzeug/{werkzeug.__version__}", f"local_pfs/{VERSION}"], } for i, expected_activity in enumerate(expected_activities): temp = default_expected_call.copy()