[CLI-729][WB-5833] Made Sweep Runs Paginated
@@ -836,14 +836,11 @@ class Runs(Paginator):
if sweep is None:
continue
run.sweep = sweep
- if run.id not in sweep.runs_by_id:
- sweep.runs_by_id[run.id] = run
- sweep.runs.append(run)
return objs
def __repr__(self):
- return "<Runs {}/{} ({})>".format(self.entity, self.project, len(self))
+ return "<Runs {}/{}>".format(self.entity, self.project)
class Run(Attrs):
@@ -1008,7 +1005,6 @@ class Run(Attrs):
# TODO: Older runs don't always have sweeps when sweep_name is set
if self.sweep:
self.sweep.runs.append(self)
- self.sweep.runs_by_id[self.id] = self
self._attrs["summaryMetrics"] = (
json.loads(self._attrs["summaryMetrics"])
@@ -1427,32 +1423,17 @@ class Sweep(Attrs):
QUERY = gql(
"""
- query Sweep($project: String!, $entity: String, $name: String!, $withRuns: Boolean!, $order: String) {
+ query Sweep($project: String!, $entity: String, $name: String!) {
project(name: $project, entityName: $entity) {
sweep(sweepName: $name) {
id
name
bestLoss
config
- runs(order: $order) @include(if: $withRuns) {
- edges {
- node {
- ...RunFragment
- }
- cursor
- }
- pageInfo {
- endCursor
- hasNextPage
- }
- }
- state
}
}
}
- %s
"""
- % RUN_FRAGMENT
)
def __init__(self, client, entity, project, sweep_id, attrs={}):
@@ -1463,7 +1444,6 @@ class Sweep(Attrs):
self.project = project
self.id = sweep_id
self.runs = []
- self.runs_by_id = {}
self.load(force=not attrs)
@@ -1487,7 +1467,6 @@ class Sweep(Attrs):
raise ValueError("Could not find sweep %s" % self)
self._attrs = sweep._attrs
self.runs = sweep.runs
- self.runs_by_id = sweep.runs_by_id
return self._attrs
@@ -1546,7 +1525,6 @@ class Sweep(Attrs):
entity=None,
project=None,
sid=None,
- withRuns=True, # noqa: N803
order=None,
query=None,
**kwargs
@@ -1559,8 +1537,6 @@ class Sweep(Attrs):
"entity": entity,
"project": project,
"name": sid,
- "order": order,
- "withRuns": withRuns,
}
variables.update(kwargs)
@@ -1571,23 +1547,15 @@ class Sweep(Attrs):
return None
sweep_response = response["project"]["sweep"]
-
- # TODO: make this paginate
- runs_response = sweep_response.get("runs")
- runs = []
- if runs_response:
- for r in runs_response["edges"]:
- run = Run(client, entity, project, r["node"]["name"], r["node"])
- runs.append(run)
-
- del sweep_response["runs"]
-
sweep = cls(client, entity, project, sid, attrs=sweep_response)
- sweep.runs = runs
-
- for run in runs:
- sweep.runs_by_id[run.id] = run
- run.sweep = sweep
+ sweep.runs = Runs(
+ client,
+ entity,
+ project,
+ order=order,
+ per_page=10,
+ filters={"$and": [{"sweep": sweep.id}]},
+ )
return sweep
