Skip to content
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
2 changes: 0 additions & 2 deletions darwin/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,6 @@ def _run(args: Namespace, parser: ArgumentParser) -> None:
# Remove a project (remotely)
elif args.action == "remove":
f.remove_remote_dataset(args.dataset)
elif args.action == "report":
f.dataset_report(args.dataset, args.granularity or "day", args.pretty)
elif args.action == "export":
f.export_dataset(
args.dataset,
Expand Down
59 changes: 0 additions & 59 deletions darwin/cli_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,65 +300,6 @@ def url(dataset_slug: str) -> None:
_error(f"Dataset '{e.name}' does not exist.")


def dataset_report(dataset_slug: str, granularity: str, pretty: bool) -> None:
"""
Prints a dataset's report in CSV format.
Exits the application if no dataset is found.

Parameters
----------
dataset_slug : str
The dataset's slug.
granularity : str
Granularity of the report, can be 'day', 'week' or 'month'.
pretty : bool
If ``True``, it will print the output in a Rich formatted table.
"""
client: Client = _load_client()
console = Console(theme=_console_theme())
try:
remote_dataset: RemoteDataset = client.get_remote_dataset(
dataset_identifier=dataset_slug
)
report: str = remote_dataset.get_report(granularity)

if not pretty:
# if no one worked in the report, we print nothing
print(report)
return

lines: List[str] = report.split("\n")
lines.pop(0) # remove csv headers

if not lines:
console.print("No one has worked on this dataset yet!\n", style="success")
return

lines.pop() # remove last line, which is empty

table: Table = Table(show_header=True, header_style="bold cyan")
table.add_column("Date")
table.add_column("Dataset Id", justify="right")
table.add_column("Dataset Name", justify="right")
table.add_column("User Id", justify="right")
table.add_column("Email", justify="right")
table.add_column("First Name", justify="right")
table.add_column("Last Name", justify="right")
table.add_column("Annotation Time", justify="right")
table.add_column("Annotations Approved", justify="right")
table.add_column("Annotations Created", justify="right")
table.add_column("Images Annotated", justify="right")
table.add_column("Images Approved", justify="right")
table.add_column("Images Rejected", justify="right")

for row in lines:
table.add_row(*row.split(","))

console.print(table)
except NotFound:
_error(f"Dataset '{dataset_slug}' does not exist.")


def export_dataset(
dataset_slug: str,
include_url_token: bool,
Expand Down
37 changes: 0 additions & 37 deletions darwin/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,43 +615,6 @@ def annotation_types(self) -> List[Dict[str, UnknownType]]:
)
return response

def get_report(
self, dataset_id: int, granularity: str, team_slug: Optional[str] = None
) -> Response:
"""
Gets the report for the given dataset.

Parameters
----------
dataset_id: int
The id of the dataset.
granularity: str
Granularity of the report, can be 'day', 'week' or 'month'.
team_slug: Optional[str]
Team slug of the team the dataset will belong to. Defaults to None.

Returns
------
Response
The raw response of the report (CSV format) or None if the Team was not found.

Raises
------
ValueError
If no team was found.
"""
the_team: Optional[Team] = self.config.get_team(team_slug or self.default_team)

if not the_team:
raise ValueError("No team was found.")

the_team_slug: str = the_team.slug

return self._get_raw(
f"/reports/{the_team_slug}/annotation?group_by=dataset,user&dataset_ids={dataset_id}&granularity={granularity}&format=csv&include=dataset.name,user.first_name,user.last_name,user.email",
the_team_slug,
)

def get_annotators_report(
self,
dataset_ids: list[int],
Expand Down
16 changes: 0 additions & 16 deletions darwin/dataset/remote_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,22 +718,6 @@ def export(
Omit this option to get your team's default.
"""

@abstractmethod
def get_report(self, granularity: str = "day") -> str:
"""
Returns a String representation of a CSV report for this ``RemoteDataset``.

Parameters
----------
granularity : str, default: "day"
The granularity of the report, can be 'day', 'week' or 'month'.

Returns
-------
str
A CSV report.
"""

@abstractmethod
def get_releases(self, include_unavailable: bool = False) -> List["Release"]:
"""
Expand Down
20 changes: 0 additions & 20 deletions darwin/dataset/remote_dataset_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
Iterable,
)
from pydantic import ValidationError
from requests.models import Response

from darwin.dataset import RemoteDataset
from darwin.dataset.release import Release
Expand Down Expand Up @@ -504,25 +503,6 @@ def export(
team_slug=self.team,
)

def get_report(self, granularity: str = "day") -> str:
"""
Returns a String representation of a CSV report for this ``RemoteDataset``.

Parameters
----------
granularity : str, default: "day"
The granularity of the report, can be 'day', 'week' or 'month'.

Returns
-------
str
A CSV report.
"""
response: Response = self.client.get_report(
self.dataset_id, granularity, self.team
)
return response.text

def workview_url_for_item(self, item: DatasetItem) -> str:
"""
Returns the darwin URL for the given ``DatasetItem``.
Expand Down
20 changes: 0 additions & 20 deletions darwin/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,26 +199,6 @@ def __init__(self) -> None:
"dataset", type=str, help="Remote dataset name to delete."
)

# Report
parser_report = dataset_action.add_parser(
"report", help="Report about the annotators."
)
parser_report.add_argument(
"dataset", type=str, help="Remote dataset name to report on."
)
parser_report.add_argument(
"-g",
"--granularity",
choices=["day", "week", "month", "total"],
help="Granularity of the report.",
)
parser_report.add_argument(
"-r",
"--pretty",
action="store_true",
default=False,
help="Prints the results formatted in a rich table.",
)
# Export
parser_export = dataset_action.add_parser(
"export", help="Export a version of a dataset."
Expand Down