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

Processing feedback #130

Merged
merged 9 commits into from
Apr 18, 2022
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
23 changes: 10 additions & 13 deletions .github/workflows/check-test-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ on:
schedule:
- cron: '0 7 * * 1' # M H d m w (Mondays at 7:00)

env:
MLEM_TESTS: "true"

jobs:
check:
if: startsWith(github.ref, 'refs/tags') || github.event_name == 'pull_request' || github.event_name == 'schedule' || github.repository_owner != 'iterative'
Expand Down Expand Up @@ -99,13 +96,13 @@ jobs:
run: |
echo ::set-output name=tag::${GITHUB_REF#refs/tags/}
git log --pretty='format:%d%n- %s%n%b---' $(git tag --sort=v:refname | tail -n2 | head -n1)..HEAD > _CHANGES.md
- if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
name: gto ${{ steps.meta.outputs.tag }} alpha
body_path: _CHANGES.md
draft: true
files: |
dist/${{ steps.dist.outputs.whl }}
# - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
# uses: softprops/action-gh-release@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
# with:
# name: gto ${{ steps.meta.outputs.tag }} alpha
# body_path: _CHANGES.md
# draft: true
# files: |
# dist/${{ steps.dist.outputs.whl }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,5 @@ dmypy.json
cython_debug/

.idea

gto/_gto_version.py
13 changes: 13 additions & 0 deletions gto/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
try:
from ._gto_version import version as __version__
from ._gto_version import version_tuple
except ImportError:
try:
from setuptools_scm import get_version

__version__ = get_version(root="..", relative_to=__file__)
except (LookupError, ImportError):
__version__ = "UNKNOWN"
version_tuple = () # type: ignore

__all__ = ["__version__", "version_tuple"]
16 changes: 12 additions & 4 deletions gto/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def annotate(
type: Optional[str] = None,
path: Optional[str] = None,
must_exist: bool = False,
tags: List[str] = None,
labels: List[str] = None,
description: str = "",
# update: bool = False,
):
Expand All @@ -54,7 +54,7 @@ def annotate(
type=type,
path=path,
must_exist=must_exist,
tags=tags,
labels=labels,
description=description,
update=True,
)
Expand All @@ -70,15 +70,19 @@ def register(
name: str,
ref: str,
version: str = None,
bump: str = None,
bump_major: bool = False,
bump_minor: bool = False,
bump_patch: bool = False,
stdout: bool = False,
):
"""Register new artifact version"""
return GitRegistry.from_repo(repo).register(
name=name,
ref=ref,
version=version,
bump=bump,
bump_major=bump_major,
bump_minor=bump_minor,
bump_patch=bump_patch,
stdout=stdout,
)

Expand All @@ -91,6 +95,8 @@ def promote(
promote_ref: str = None,
name_version: str = None,
simple: bool = False,
force: bool = False,
skip_registration: bool = False,
stdout: bool = False,
):
"""Assign stage to specific artifact version"""
Expand All @@ -101,6 +107,8 @@ def promote(
promote_ref,
name_version,
simple=simple,
force=force,
skip_registration=skip_registration,
stdout=stdout,
)

Expand Down
62 changes: 47 additions & 15 deletions gto/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import gto
from gto.exceptions import GTOException, WrongArgs
from gto.ui import EMOJI_FAIL, EMOJI_MLEM, bold, cli_echo, color, echo
from gto.ui import EMOJI_FAIL, EMOJI_GTO, bold, cli_echo, color, echo
from gto.utils import format_echo, make_ready_to_serialize

TABLE = "table"
Expand Down Expand Up @@ -182,7 +182,7 @@ def get_command(self, ctx: Context, cmd_name: str) -> Optional[Command]:
return None


def MlemGroupSection(section):
def GTOGroupSection(section):
return partial(GtoGroup, section=section)


Expand Down Expand Up @@ -299,7 +299,7 @@ def gto_callback(
"""
if ctx.invoked_subcommand is None and show_version:
with cli_echo():
echo(f"{EMOJI_MLEM} GTO Version: {gto.__version__}")
echo(f"{EMOJI_GTO} GTO Version: {gto.__version__}")
if verbose:
logger = logging.getLogger("gto")
logger.handlers[0].setLevel(logging.DEBUG)
Expand Down Expand Up @@ -382,7 +382,7 @@ def annotate(
is_flag=True,
help="Verify artifact is committed to Git",
),
tag: List[str] = Option(None, "--tag", help="Tags to add to artifact"),
label: List[str] = Option(None, "--label", help="Labels to add to artifact"),
description: str = Option("", "-d", "--description", help="Artifact description"),
# update: bool = Option(
# False, "-u", "--update", is_flag=True, help="Update artifact if it exists"
Expand All @@ -399,7 +399,7 @@ def annotate(
type=type,
path=path,
must_exist=must_exist,
tags=tag,
labels=label,
description=description,
# update=update,
)
Expand All @@ -423,8 +423,14 @@ def register(
version: Optional[str] = Option(
None, "--version", "--ver", help="Version name in SemVer format"
),
bump: Optional[str] = Option(
None, "--bump", "-b", help="The exact part to increment when bumping a version"
bump_major: bool = Option(
False, "--bump-major", is_flag=True, help="Bump major version"
),
bump_minor: bool = Option(
False, "--bump-minor", is_flag=True, help="Bump minor version"
),
bump_patch: bool = Option(
False, "--bump-patch", is_flag=True, help="Bump patch version"
),
):
"""Create git tag that marks the important artifact version
Expand All @@ -443,7 +449,14 @@ def register(
$ gto register nn --bump minor
"""
gto.api.register(
repo=repo, name=name, ref=ref or "HEAD", version=version, bump=bump, stdout=True
repo=repo,
name=name,
ref=ref or "HEAD",
version=version,
bump_major=bump_major,
bump_minor=bump_minor,
bump_patch=bump_patch,
stdout=True,
)


Expand All @@ -452,37 +465,54 @@ def promote(
repo: str = option_repo,
name: str = arg_name,
stage: str = arg_stage,
ref: Optional[str] = Argument(None, help="Git reference to promote"),
version: Optional[str] = Option(
None,
"--version",
help="If you provide --ref, this will be used to name new version",
help="If you provide REF, this will be used to name new version",
),
ref: Optional[str] = Option(None, "--ref", help="Git reference to promote"),
simple: bool = Option(
False,
"--simple",
is_flag=True,
help="Use simple notation, e.g. rf#prod instead of rf#prod-5",
),
force: bool = Option(
False, help="Promote even if version is already in required Stage"
),
skip_registration: bool = Option(
False,
"--sr",
"--skip-registration",
is_flag=True,
help="Don't register a version at specified commit",
),
):
"""Assign stage to specific artifact version

Examples:
Promote HEAD:
$ gto promote nn prod --ref HEAD
Promote "nn" to "prod" at specific ref:
$ gto promote nn prod abcd123

Promote specific version:
$ gto promote nn prod --version v1.0.0

Promote at specific ref and name version explicitly:
$ gto promote nn prod abcd123 --version v1.0.0

Promote without increment
$ gto promote nn prod --ref HEAD --simple
"""
if ref is not None:
name_version = version
promote_version = None
else:
elif version is not None:
name_version = None
promote_version = version
else:
ref = "HEAD"
name_version = None
promote_version = None
gto.api.promote(
repo,
name,
Expand All @@ -491,6 +521,8 @@ def promote(
ref,
name_version,
simple=simple,
force=force,
skip_registration=skip_registration,
stdout=True,
)

Expand Down Expand Up @@ -683,12 +715,12 @@ def history(
),
format="table",
format_table="plain" if plain else "fancy_outline",
if_empty="No history found",
if_empty="Nothing found in the current workspace",
)


@gto_command(section=COMMANDS.REGISTRY)
def print_stages(
def stages(
repo: str = option_repo,
in_use: bool = Option(
False,
Expand Down
6 changes: 0 additions & 6 deletions gto/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,3 @@
class Action(Enum):
REGISTER = "register"
PROMOTE = "promote"


class VersionPart(Enum):
MAJOR = "major"
MINOR = "minor"
PATCH = "patch"
2 changes: 1 addition & 1 deletion gto/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def __init__(self, ref) -> None:


class InvalidVersion(GTOException):
_message = "Supplied version '{version}' doesn't look like '{cls}' version"
_message = "Supplied version '{version}' doesn't look like valid {cls} version"

def __init__(self, version, cls) -> None:
self.message = self._message.format(version=version, cls=cls)
Expand Down
Loading