Skip to content

Commit

Permalink
fix: fixed appending entrypoints to experiments for get all
Browse files Browse the repository at this point in the history
Keith Manville <[email protected]>
  • Loading branch information
andrewhand authored Jul 5, 2024
1 parent 929fa72 commit ae0b4a9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 27 deletions.
11 changes: 8 additions & 3 deletions src/dioptra/restapi/v1/experiments/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ def get(
entrypoints = self._entrypoint_ids_service.get(
list(entrypoint_ids.keys()), error_if_not_found=True, log=log
)
entrypoints_dict = {
entrypoint.resource_id: entrypoint for entrypoint in entrypoints
}

drafts_stmt = select(
models.DraftResource.payload["resource_id"].as_string().cast(Integer)
Expand All @@ -243,9 +246,11 @@ def get(
}
for resource_id in db.session.scalars(drafts_stmt):
experiments_dict[resource_id]["has_draft"] = True
for entrypoint in entrypoints:
experiment_id = entrypoint_ids[entrypoint.resource_id]
experiments_dict[experiment_id]["entrypoints"].append(entrypoint)
for experiment_dict in experiments_dict.values():
for resource in experiment_dict["experiment"].children:
if resource.resource_type == "entry_point":
entrypoint = entrypoints_dict[resource.resource_id]
experiment_dict["entrypoints"].append(entrypoint)

return list(experiments_dict.values()), total_num_experiments

Expand Down
24 changes: 0 additions & 24 deletions tests/unit/restapi/v1/test_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,14 +338,6 @@ def test_create_experiment(
)


@pytest.mark.skip(
reason=(
"Flask testing client isn't working correctly with GET /experiments/:id. "
"Entrypoints are being dropped in the test response. However, the full Flask "
"app returns the expected list. Disabling until a workaround can be figured "
"out."
)
)
def test_experiment_get_all(
client: FlaskClient,
db: SQLAlchemy,
Expand Down Expand Up @@ -374,14 +366,6 @@ def test_experiment_get_all(
assert_retrieving_all_experiments_works(client, expected=experiment_expected_list)


@pytest.mark.skip(
reason=(
"Flask testing client isn't working correctly with GET /experiments/:id. "
"Entrypoints are being dropped in the test response. However, the full Flask "
"app returns the expected list. Disabling until a workaround can be figured "
"out."
)
)
def test_experiment_search_query(
client: FlaskClient,
db: SQLAlchemy,
Expand Down Expand Up @@ -425,14 +409,6 @@ def test_experiment_search_query(
)


@pytest.mark.skip(
reason=(
"Flask testing client isn't working correctly with GET /experiments/:id. "
"Entrypoints are being dropped in the test response. However, the full Flask "
"app returns the expected list. Disabling until a workaround can be figured "
"out."
)
)
def test_experiment_group_query(
client: FlaskClient,
db: SQLAlchemy,
Expand Down

0 comments on commit ae0b4a9

Please sign in to comment.