Skip to content

Commit

Permalink
[trace][bugfix] Fix possible circular import for trace util (#2803)
Browse files Browse the repository at this point in the history
# Description

Make an import locally to avoid circular import.

# All Promptflow Contribution checklist:
- [x] **The pull request does not introduce [breaking changes].**
- [ ] **CHANGELOG is updated for new features, bug fixes or other
significant changes.**
- [x] **I have read the [contribution guidelines](../CONTRIBUTING.md).**
- [ ] **Create an issue and link to the pull request to get dedicated
review from promptflow team. Learn more: [suggested
workflow](../CONTRIBUTING.md#suggested-workflow).**

## General Guidelines and Best Practices
- [x] Title of the pull request is clear and informative.
- [x] There are a small number of commits, each of which have an
informative message. This means that previously merged commits do not
appear in the history of the PR. For more information on cleaning up the
commits in your PR, [see this
page](https://github.com/Azure/azure-powershell/blob/master/documentation/development-docs/cleaning-up-commits.md).

### Testing Guidelines
- [x] Pull request includes test coverage for the included changes.
  • Loading branch information
zhengfeiwang authored Apr 16, 2024
1 parent 289c0f5 commit 095129b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/promptflow-devkit/promptflow/_sdk/_orm/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from sqlalchemy.orm import Session, sessionmaker
from sqlalchemy.schema import CreateTable

from promptflow._sdk._configuration import Configuration
from promptflow._sdk._constants import (
CONNECTION_TABLE_NAME,
EVENT_TABLENAME,
Expand Down Expand Up @@ -90,6 +89,7 @@ def mgmt_db_session() -> Session:
engine = create_engine(f"sqlite:///{str(LOCAL_MGMT_DB_PATH)}?check_same_thread=False", future=True)
engine = support_transaction(engine)

from promptflow._sdk._configuration import Configuration
from promptflow._sdk._orm import Connection, Experiment, ExperimentNodeRun, Orchestrator, RunInfo

create_or_update_table(engine, orm_class=RunInfo, tablename=RUN_INFO_TABLENAME)
Expand Down
9 changes: 5 additions & 4 deletions src/promptflow-devkit/promptflow/_sdk/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@
UnsecureConnectionError,
)
from promptflow._sdk._vendor import IgnoreFile, get_ignore_file, get_upload_files_from_folder
from promptflow._sdk.entities._flows.base import FlowBase
from promptflow._sdk.entities._flows.dag import Flow as DAGFlow
from promptflow._utils.flow_utils import is_flex_flow, resolve_flow_path
from promptflow._utils.logger_utils import get_cli_sdk_logger
from promptflow._utils.user_agent_utils import ClientUserAgentUtil
Expand Down Expand Up @@ -1077,10 +1075,13 @@ def is_flex_run(run: "Run") -> bool:
update_dict_value_with_connections = update_dict_value_with_connections


def get_flow_name(flow: Union[FlowBase, Path]) -> str:
def get_flow_name(flow) -> str:
if isinstance(flow, Path):
return flow.resolve().name

from promptflow._sdk.entities._flows.dag import Flow as DAGFlow

if isinstance(flow, DAGFlow):
return flow.name
# others: flex flow, prompty, etc.
# should be promptflow._sdk.entities._flows.base.FlowBase: flex flow, prompty, etc.
return flow.code.name

0 comments on commit 095129b

Please sign in to comment.