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 typo that causes error in pytest collection #2839

Merged
merged 2 commits into from
Apr 18, 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
6 changes: 3 additions & 3 deletions src/promptflow-evals/tests/evals/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ def is_replay():
return False


PROMOTFLOW_ROOT = Path(__file__) / "../../../.."
CONNECTION_FILE = (PROMOTFLOW_ROOT / "promptflow-evals/connections.json").resolve().absolute().as_posix()
RECORDINGS_TEST_CONFIGS_ROOT = Path(PROMOTFLOW_ROOT / "promptflow-recording/recordings/local").resolve()
PROMPTFLOW_ROOT = Path(__file__) / "../../../.."
CONNECTION_FILE = (PROMPTFLOW_ROOT / "promptflow-evals/connections.json").resolve().absolute().as_posix()
RECORDINGS_TEST_CONFIGS_ROOT = Path(PROMPTFLOW_ROOT / "promptflow-recording/recordings/local").resolve()


def pytest_configure():
Expand Down
18 changes: 9 additions & 9 deletions src/promptflow-tools/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
from promptflow.tools.aoai import AzureOpenAI
from promptflow.tools.aoai_gpt4v import AzureOpenAI as AzureOpenAIVision

PROMOTFLOW_ROOT = Path(__file__).absolute().parents[1]
CONNECTION_FILE = (PROMOTFLOW_ROOT / "connections.json").resolve().absolute().as_posix()
root_str = str(PROMOTFLOW_ROOT.resolve().absolute())
PROMPTFLOW_ROOT = Path(__file__).absolute().parents[1]
CONNECTION_FILE = (PROMPTFLOW_ROOT / "connections.json").resolve().absolute().as_posix()
root_str = str(PROMPTFLOW_ROOT.resolve().absolute())
if root_str not in sys.path:
sys.path.insert(0, root_str)

Expand Down Expand Up @@ -108,42 +108,42 @@ def skip_if_no_api_key(request, mocker):
# example prompts
@pytest.fixture
def example_prompt_template() -> str:
with open(PROMOTFLOW_ROOT / "tests/test_configs/prompt_templates/marketing_writer/prompt.jinja2") as f:
with open(PROMPTFLOW_ROOT / "tests/test_configs/prompt_templates/marketing_writer/prompt.jinja2") as f:
prompt_template = f.read()
return prompt_template


@pytest.fixture
def example_prompt_template_with_name_in_roles() -> str:
with open(PROMOTFLOW_ROOT / "tests/test_configs/prompt_templates/prompt_with_name_in_roles.jinja2") as f:
with open(PROMPTFLOW_ROOT / "tests/test_configs/prompt_templates/prompt_with_name_in_roles.jinja2") as f:
prompt_template = f.read()
return prompt_template


@pytest.fixture
def chat_history() -> list:
with open(PROMOTFLOW_ROOT / "tests/test_configs/prompt_templates/marketing_writer/history.json") as f:
with open(PROMPTFLOW_ROOT / "tests/test_configs/prompt_templates/marketing_writer/history.json") as f:
history = json.load(f)
return history


@pytest.fixture
def example_prompt_template_with_function() -> str:
with open(PROMOTFLOW_ROOT / "tests/test_configs/prompt_templates/prompt_with_function.jinja2") as f:
with open(PROMPTFLOW_ROOT / "tests/test_configs/prompt_templates/prompt_with_function.jinja2") as f:
prompt_template = f.read()
return prompt_template


@pytest.fixture
def example_prompt_template_with_image() -> str:
with open(PROMOTFLOW_ROOT / "tests/test_configs/prompt_templates/prompt_with_image.jinja2") as f:
with open(PROMPTFLOW_ROOT / "tests/test_configs/prompt_templates/prompt_with_image.jinja2") as f:
prompt_template = f.read()
return prompt_template


@pytest.fixture
def example_image() -> Image:
with open(PROMOTFLOW_ROOT / "tests/test_configs/prompt_templates/images/number10.jpg", "rb") as f:
with open(PROMPTFLOW_ROOT / "tests/test_configs/prompt_templates/images/number10.jpg", "rb") as f:
image = Image(f.read())
return image

Expand Down
12 changes: 6 additions & 6 deletions src/promptflow/tests/_constants.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from pathlib import Path

PROMOTFLOW_ROOT = Path(__file__).parent.parent
RUNTIME_TEST_CONFIGS_ROOT = Path(PROMOTFLOW_ROOT / "tests/test_configs/runtime")
EXECUTOR_REQUESTS_ROOT = Path(PROMOTFLOW_ROOT / "tests/test_configs/executor_api_requests")
MODEL_ROOT = Path(PROMOTFLOW_ROOT / "tests/test_configs/e2e_samples")
CONNECTION_FILE = (PROMOTFLOW_ROOT / "connections.json").resolve().absolute().as_posix()
ENV_FILE = (PROMOTFLOW_ROOT / ".env").resolve().absolute().as_posix()
PROMPTFLOW_ROOT = Path(__file__).parent.parent
RUNTIME_TEST_CONFIGS_ROOT = Path(PROMPTFLOW_ROOT / "tests/test_configs/runtime")
EXECUTOR_REQUESTS_ROOT = Path(PROMPTFLOW_ROOT / "tests/test_configs/executor_api_requests")
MODEL_ROOT = Path(PROMPTFLOW_ROOT / "tests/test_configs/e2e_samples")
CONNECTION_FILE = (PROMPTFLOW_ROOT / "connections.json").resolve().absolute().as_posix()
ENV_FILE = (PROMPTFLOW_ROOT / ".env").resolve().absolute().as_posix()

# below constants are used for pfazure and global config tests
DEFAULT_SUBSCRIPTION_ID = "96aede12-2f73-41cb-b983-6d11a904839b"
Expand Down
Loading