Skip to content

Commit

Permalink
refactor: rename tasks to cli (argilla-io#3723)
Browse files Browse the repository at this point in the history
# Description

This PR renames the `tasks` subpackage to `cli`. 

Closes argilla-io#3722

**Type of change**

- [x] Refactor (change restructuring the codebase without changing
functionality)

**How Has This Been Tested**



**Checklist**

- [ ] I added relevant documentation
- [x] I followed the style guidelines of this project
- [x] I did a self-review of my code
- [ ] I made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [ ] I filled out [the contributor form](https://tally.so/r/n9XrxK)
(see text above)
- [x] I have added relevant notes to the `CHANGELOG.md` file (See
https://keepachangelog.com/)
  • Loading branch information
gabrielmbmb authored Sep 7, 2023
1 parent 116878d commit fceabd6
Show file tree
Hide file tree
Showing 90 changed files with 171 additions and 154 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ These are the section headers that we use:
- `server` commands only included in the CLI app when `server` extra requirements are installed ([#3710](https://github.com/argilla-io/argilla/pull/3710)).
- Updated `PUT /api/v1/responses/{response_id}` to replace `values` stored with received `values` in request ([#3711](https://github.com/argilla-io/argilla/pull/3711)).
- Display a `UserWarning` when the `user_id` in `Workspace.add_user` and `Workspace.delete_user` is the ID of an user with the owner role as they don't require explicit permissions ([#3716](https://github.com/argilla-io/argilla/issues/3716)).
- Rename `tasks` sub-package to `cli` ([#3723](https://github.com/argilla-io/argilla/pull/3723)).

### Fixed

Expand Down
2 changes: 1 addition & 1 deletion src/argilla/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from argilla.tasks.app import app
from argilla.cli.app import app

if __name__ == "__main__":
app()
File renamed without changes.
8 changes: 4 additions & 4 deletions src/argilla/tasks/app.py → src/argilla/cli/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import warnings

from argilla.tasks import (
from argilla.cli import (
datasets_app,
info_app,
login_app,
Expand All @@ -24,7 +24,7 @@
whoami_app,
workspaces_app,
)
from argilla.tasks.typer_ext import ArgillaTyper
from argilla.cli.typer_ext import ArgillaTyper
from argilla.utils.dependency import is_package_with_extras_installed

warnings.simplefilter("ignore", UserWarning)
Expand All @@ -38,7 +38,7 @@ def handler_permission_error(e: PermissionError) -> None:

from rich.console import Console

from argilla.tasks.rich import get_argilla_themed_panel
from argilla.cli.rich import get_argilla_themed_panel

panel = get_argilla_themed_panel(
"Logged in user doesn't have enough permissions to execute this command",
Expand All @@ -61,7 +61,7 @@ def handler_permission_error(e: PermissionError) -> None:
app.add_typer(workspaces_app, name="workspaces")

if is_package_with_extras_installed("argilla", ["server"]):
from argilla.tasks.server import app as server_app
from argilla.cli.server import app as server_app

app.add_typer(server_app, name="server")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

import typer

from argilla.cli.rich import echo_in_panel
from argilla.client.api import init
from argilla.client.login import ArgillaCredentials
from argilla.tasks.rich import echo_in_panel


def init_callback() -> None:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

import typer

from argilla.tasks.callback import init_callback
from argilla.tasks.datasets.delete import delete_dataset
from argilla.tasks.datasets.list import list_datasets
from argilla.tasks.datasets.push import push_to_huggingface
from argilla.cli.callback import init_callback
from argilla.cli.datasets.delete import delete_dataset
from argilla.cli.datasets.list import list_datasets
from argilla.cli.datasets.push import push_to_huggingface

_COMMANDS_REQUIRING_DATASET = ["delete", "push-to-huggingface"]

Expand All @@ -31,8 +31,8 @@ def callback(
) -> None:
init_callback()

from argilla.cli.rich import echo_in_panel
from argilla.client.feedback.dataset.local import FeedbackDataset
from argilla.tasks.rich import echo_in_panel

if ctx.invoked_subcommand not in _COMMANDS_REQUIRING_DATASET:
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@


def delete_dataset(ctx: typer.Context) -> None:
from argilla.tasks.rich import echo_in_panel
from argilla.cli.rich import echo_in_panel

dataset: "RemoteFeedbackDataset" = ctx.obj

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import typer

from argilla.tasks.datasets.enums import DatasetType
from argilla.cli.datasets.enums import DatasetType


def list_datasets(
Expand All @@ -29,10 +29,10 @@ def list_datasets(
) -> None:
from rich.console import Console

from argilla.cli.rich import echo_in_panel, get_argilla_themed_table
from argilla.client.api import list_datasets as list_datasets_api
from argilla.client.feedback.dataset.local import FeedbackDataset
from argilla.client.workspaces import Workspace
from argilla.tasks.rich import echo_in_panel, get_argilla_themed_table

console = Console()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def push_to_huggingface(
from rich.live import Live
from rich.spinner import Spinner

from argilla.cli.rich import echo_in_panel
from argilla.client.feedback.dataset.local import FeedbackDataset
from argilla.tasks.rich import echo_in_panel

dataset: "FeedbackDataset" = ctx.obj

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import typer

from argilla.tasks.callback import init_callback
from argilla.cli.callback import init_callback

app = typer.Typer(invoke_without_command=True)

Expand All @@ -25,9 +25,9 @@ def info() -> None:
from rich.markdown import Markdown

from argilla._version import version
from argilla.cli.rich import get_argilla_themed_panel
from argilla.client.api import active_client
from argilla.client.apis.status import Status
from argilla.tasks.rich import get_argilla_themed_panel

init_callback()

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def login(
):
import json

from argilla.cli.rich import echo_in_panel
from argilla.client.login import login as login_func
from argilla.tasks.rich import echo_in_panel

try:
if extra_headers:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

@app.callback(help="Logout from an Argilla Server.")
def logout(force: bool = typer.Option(False, help="Force the logout even if the server cannot be reached")) -> None:
from argilla.cli.callback import init_callback
from argilla.cli.rich import echo_in_panel
from argilla.client.login import ArgillaCredentials
from argilla.tasks.callback import init_callback
from argilla.tasks.rich import echo_in_panel

if not force:
init_callback()
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
from alembic.script import ScriptDirectory
from alembic.util import CommandError

from argilla.cli import typer_ext
from argilla.cli.server.database import utils
from argilla.server.database import ALEMBIC_CONFIG_FILE, TAGGED_REVISIONS
from argilla.tasks import typer_ext
from argilla.tasks.server.database import utils


def migrate_db(revision: Optional[str] = typer.Option(default="head", help="DB Revision to migrate to")):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
import alembic.config
import typer

from argilla.cli import typer_ext
from argilla.cli.server.database import utils
from argilla.server.database import ALEMBIC_CONFIG_FILE, TAGGED_REVISIONS
from argilla.tasks import typer_ext
from argilla.tasks.server.database import utils


def revisions():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from argilla.tasks.typer_ext import ArgillaTyper
from argilla.cli.typer_ext import ArgillaTyper

from .create import create
from .create_default import create_default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import typer
from pydantic import constr

from argilla.cli import typer_ext
from argilla.cli.server.database.users.utils import get_or_new_workspace
from argilla.server.contexts import accounts
from argilla.server.database import AsyncSessionLocal
from argilla.server.models import User, UserRole
Expand All @@ -25,8 +27,6 @@
UserCreate,
WorkspaceCreate,
)
from argilla.tasks import typer_ext
from argilla.tasks.server.database.users.utils import get_or_new_workspace

USER_API_KEY_MIN_LENGTH = 8

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
import typer

from argilla._constants import DEFAULT_API_KEY, DEFAULT_PASSWORD, DEFAULT_USERNAME
from argilla.cli import typer_ext
from argilla.server.contexts import accounts
from argilla.server.database import AsyncSessionLocal
from argilla.server.models import User, UserRole, Workspace
from argilla.tasks import typer_ext


async def create_default(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
import yaml
from pydantic import BaseModel, constr

from argilla.cli import typer_ext
from argilla.cli.server.database.users.utils import get_or_new_workspace
from argilla.server.database import AsyncSessionLocal
from argilla.server.models import User, UserRole
from argilla.server.security.auth_provider.local.settings import settings
from argilla.server.security.model import USER_USERNAME_REGEX, WORKSPACE_NAME_REGEX
from argilla.tasks import typer_ext
from argilla.tasks.server.database.users.utils import get_or_new_workspace

if TYPE_CHECKING:
from sqlalchemy.ext.asyncio import AsyncSession
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

import typer

from argilla.cli import typer_ext
from argilla.server.contexts import accounts
from argilla.server.database import AsyncSessionLocal
from argilla.server.models import UserRole
from argilla.tasks import typer_ext


async def update(
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def train(
):
import json

from argilla.cli.callback import init_callback
from argilla.client.api import init
from argilla.tasks.callback import init_callback
from argilla.training import ArgillaTrainer

init_callback()
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import typer

from argilla.tasks.callback import init_callback
from argilla.cli.callback import init_callback

from .create import create_user
from .delete import delete_user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def create_user(
from rich.console import Console
from rich.markdown import Markdown

from argilla.cli.rich import echo_in_panel
from argilla.client.users import User
from argilla.tasks.rich import echo_in_panel

try:
user = User.create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@


def delete_user(username: str = typer.Argument(..., help="The username of the user to be removed")) -> None:
from argilla.cli.rich import echo_in_panel
from argilla.client.users import User
from argilla.tasks.rich import echo_in_panel

try:
User.from_name(username).delete()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ def list_users(
) -> None:
from rich.console import Console

from argilla.cli.rich import echo_in_panel, get_argilla_themed_table
from argilla.client.sdk.v1.workspaces.models import WorkspaceModel
from argilla.client.users import User
from argilla.client.workspaces import Workspace
from argilla.tasks.rich import echo_in_panel, get_argilla_themed_table

def build_workspaces_text(workspaces: Union[List[str], List[WorkspaceModel], None]) -> str:
text = ""
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
def whoami() -> None:
from rich.markdown import Markdown

from argilla.cli.callback import init_callback
from argilla.cli.rich import echo_in_panel
from argilla.client.api import active_client
from argilla.tasks.callback import init_callback
from argilla.tasks.rich import echo_in_panel

init_callback()
user = active_client()._user
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import typer

from argilla.tasks.callback import init_callback
from argilla.cli.callback import init_callback

from .add_user import add_user
from .create import create_workspace
Expand All @@ -39,8 +39,8 @@ def callback(
if name is None:
raise typer.BadParameter("The command requires a workspace name provided using '--name' option")

from argilla.cli.rich import echo_in_panel
from argilla.client.workspaces import Workspace
from argilla.tasks.rich import echo_in_panel

try:
workspace = Workspace.from_name(name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ def add_user(
ctx: typer.Context,
username: str = typer.Argument(..., help="The username of the user to be added to the workspace"),
) -> None:
from argilla.cli.rich import echo_in_panel
from argilla.cli.workspaces.utils import get_user
from argilla.client.users import User
from argilla.tasks.rich import echo_in_panel
from argilla.tasks.workspaces.utils import get_user

workspace: "Workspace" = ctx.obj

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def create_workspace(
)
) -> None:
"""Creates a workspace for the logged user in Argilla"""
from argilla.tasks.rich import echo_in_panel
from argilla.cli.rich import echo_in_panel

try:
Workspace.create(name=name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ def delete_user(
ctx: typer.Context,
username: str = typer.Argument(..., help="The username of the user to be removed from the workspace"),
) -> None:
from argilla.tasks.rich import echo_in_panel
from argilla.tasks.workspaces.utils import get_user
from argilla.cli.rich import echo_in_panel
from argilla.cli.workspaces.utils import get_user

workspace: "Workspace" = ctx.obj

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def list_workspaces() -> None:
from rich.console import Console

from argilla import Workspace
from argilla.tasks.rich import get_argilla_themed_table
from argilla.cli.rich import get_argilla_themed_table

workspaces = Workspace.list()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

import typer

from argilla.cli.rich import echo_in_panel
from argilla.client.users import User
from argilla.tasks.rich import echo_in_panel


def get_user(username: str) -> User:
Expand Down
Loading

0 comments on commit fceabd6

Please sign in to comment.