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

[SDK/CLI] Write instance_results.jsonl path in run properties #3014

Merged
merged 1 commit into from
Apr 25, 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
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def check_local_to_cloud_run(pf: PFClient, run: Run, check_run_details_in_cloud:
assert cloud_run.properties["azureml.promptflow.local_to_cloud"] == "true"
assert cloud_run.properties["azureml.promptflow.snapshot_id"]
assert cloud_run.properties[Local2CloudProperties.TOTAL_TOKENS]
assert cloud_run.properties[Local2CloudProperties.EVAL_ARTIFACTS]

# if no description or tags, skip the check, since one could be {} but the other is None
if run.description:
Expand All @@ -74,12 +75,12 @@ def check_local_to_cloud_run(pf: PFClient, run: Run, check_run_details_in_cloud:
"mock_set_headers_with_user_aml_token",
"single_worker_thread_pool",
"vcr_recording",
"mock_isinstance_for_mock_datastore",
"mock_get_azure_pf_client",
"mock_trace_destination_to_cloud",
)
class TestFlowRunUpload:
@pytest.mark.skipif(condition=not pytest.is_live, reason="Bug - 3089145 Replay failed for test 'test_upload_run'")
@pytest.mark.usefixtures(
"mock_isinstance_for_mock_datastore", "mock_get_azure_pf_client", "mock_trace_destination_to_cloud"
)
def test_upload_run(
self,
pf: PFClient,
Expand All @@ -103,9 +104,6 @@ def test_upload_run(
Local2CloudTestHelper.check_local_to_cloud_run(pf, run, check_run_details_in_cloud=True)

@pytest.mark.skipif(condition=not pytest.is_live, reason="Bug - 3089145 Replay failed for test 'test_upload_run'")
@pytest.mark.usefixtures(
"mock_isinstance_for_mock_datastore", "mock_get_azure_pf_client", "mock_trace_destination_to_cloud"
)
def test_upload_flex_flow_run_with_yaml(self, pf: PFClient, randstr: Callable[[str], str]):
name = randstr("flex_run_name_with_yaml_for_upload")
local_pf = Local2CloudTestHelper.get_local_pf(name)
Expand All @@ -125,9 +123,6 @@ def test_upload_flex_flow_run_with_yaml(self, pf: PFClient, randstr: Callable[[s
Local2CloudTestHelper.check_local_to_cloud_run(pf, run)

@pytest.mark.skipif(condition=not pytest.is_live, reason="Bug - 3089145 Replay failed for test 'test_upload_run'")
@pytest.mark.usefixtures(
"mock_isinstance_for_mock_datastore", "mock_get_azure_pf_client", "mock_trace_destination_to_cloud"
)
def test_upload_flex_flow_run_without_yaml(self, pf: PFClient, randstr: Callable[[str], str]):
name = randstr("flex_run_name_without_yaml_for_upload")
local_pf = Local2CloudTestHelper.get_local_pf(name)
Expand All @@ -148,9 +143,6 @@ def test_upload_flex_flow_run_without_yaml(self, pf: PFClient, randstr: Callable
Local2CloudTestHelper.check_local_to_cloud_run(pf, run)

@pytest.mark.skipif(condition=not pytest.is_live, reason="Bug - 3089145 Replay failed for test 'test_upload_run'")
@pytest.mark.usefixtures(
"mock_isinstance_for_mock_datastore", "mock_get_azure_pf_client", "mock_trace_destination_to_cloud"
)
def test_upload_prompty_run(self, pf: PFClient, randstr: Callable[[str], str]):
# currently prompty run is skipped for upload, this test should be finished without error
name = randstr("prompty_run_name_for_upload")
Expand All @@ -167,9 +159,6 @@ def test_upload_prompty_run(self, pf: PFClient, randstr: Callable[[str], str]):
Local2CloudTestHelper.check_local_to_cloud_run(pf, run)

@pytest.mark.skipif(condition=not pytest.is_live, reason="Bug - 3089145 Replay failed for test 'test_upload_run'")
@pytest.mark.usefixtures(
"mock_isinstance_for_mock_datastore", "mock_get_azure_pf_client", "mock_trace_destination_to_cloud"
)
def test_upload_run_with_customized_run_properties(self, pf: PFClient, randstr: Callable[[str], str]):
name = randstr("batch_run_name_for_upload_with_customized_properties")
local_pf = Local2CloudTestHelper.get_local_pf(name)
Expand Down Expand Up @@ -200,9 +189,6 @@ def test_upload_run_with_customized_run_properties(self, pf: PFClient, randstr:
assert cloud_run.properties[Local2CloudUserProperties.EVAL_ARTIFACTS] == eval_artifacts

@pytest.mark.skipif(condition=not pytest.is_live, reason="Bug - 3089145 Replay failed for test 'test_upload_run'")
@pytest.mark.usefixtures(
"mock_isinstance_for_mock_datastore", "mock_get_azure_pf_client", "mock_trace_destination_to_cloud"
)
def test_upload_eval_run(self, pf: PFClient, randstr: Callable[[str], str]):
main_run_name = randstr("main_run_name_for_test_upload_eval_run")
local_pf = Local2CloudTestHelper.get_local_pf(main_run_name)
Expand All @@ -216,8 +202,8 @@ def test_upload_eval_run(self, pf: PFClient, randstr: Callable[[str], str]):

# run an evaluation run
eval_run_name = randstr("eval_run_name_for_test_upload_eval_run")
local_lpf = Local2CloudTestHelper.get_local_pf(eval_run_name)
eval_run = local_lpf.run(
local_pf = Local2CloudTestHelper.get_local_pf(eval_run_name)
eval_run = local_pf.run(
flow=f"{FLOWS_DIR}/simple_hello_world",
data=f"{DATAS_DIR}/webClassification3.jsonl",
run=main_run_name,
Expand All @@ -229,7 +215,6 @@ def test_upload_eval_run(self, pf: PFClient, randstr: Callable[[str], str]):
assert eval_run.properties["azureml.promptflow.variant_run_id"] == main_run_name

@pytest.mark.skipif(condition=not pytest.is_live, reason="Bug - 3089145 Replay failed for test 'test_upload_run'")
@pytest.mark.usefixtures("mock_isinstance_for_mock_datastore", "mock_get_azure_pf_client")
def test_upload_flex_flow_run_with_global_azureml(self, pf: PFClient, randstr: Callable[[str], str]):
with patch("promptflow._sdk._configuration.Configuration.get_config", return_value="azureml"):
name = randstr("flex_run_name_with_global_azureml_for_upload")
Expand Down
2 changes: 1 addition & 1 deletion src/promptflow-devkit/promptflow/_sdk/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,13 +483,13 @@ class Local2CloudProperties:
"""Run properties that server needs when uploading local run to cloud."""

TOTAL_TOKENS = "azureml.promptflow.total_tokens"
EVAL_ARTIFACTS = "_azureml.evaluate_artifacts"


class Local2CloudUserProperties:
"""Run properties that user can specify when uploading local run to cloud."""

RUN_TYPE = "runType"
EVAL_ARTIFACTS = "_azureml.evaluate_artifacts"

@staticmethod
def get_all_values():
Expand Down
6 changes: 5 additions & 1 deletion src/promptflow-devkit/promptflow/_sdk/entities/_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,11 @@ def _to_rest_object_for_local_to_cloud(self, local_to_cloud_info: dict, variant_

# extract properties that needs to be passed to the request
total_tokens = self.properties[FlowRunProperties.SYSTEM_METRICS].get("total_tokens", 0)
properties = {Local2CloudProperties.TOTAL_TOKENS: total_tokens}
properties = {
Local2CloudProperties.TOTAL_TOKENS: total_tokens,
# add instance_results.jsonl path to run properties, which is required by UI feature.
Local2CloudProperties.EVAL_ARTIFACTS: '[{"path": "instance_results.jsonl", "type": "table"}]',
}
for property_key in Local2CloudUserProperties.get_all_values():
value = self.properties.get(property_key, None)
if value is not None:
Expand Down
Loading