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

0.2.0 #130

Merged
merged 9 commits into from
Nov 20, 2024
Merged

0.2.0 #130

Show file tree
Hide file tree
Changes from 4 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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Changelog
Note: version releases in the 0.x.y range may introduce breaking changes.

## 0.2.0
- Add command percy recipe sync
- Download cbc when none is found.
- Remove previous parser tree code and depend on conda-recipe-manager instead.
- Remove `get_read_only_parser()` function.
- Add proper support for CDT packages.

## 0.1.7
- Revert exclusion of `clang-compiler-activation-feedstock` from locally loaded feedstocks since it's actually active and needed.

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ test-debug: ## runs test cases with debugging info enabled
$(PYTHON3) -m pytest -n auto -vv --capture=no percy/tests/

test-cov: ## checks test coverage requirements
$(PYTHON3) -m pytest -n auto --cov-config=.coveragerc --cov=percy percy/tests/ --cov-fail-under=45 --cov-report term-missing
$(PYTHON3) -m pytest -n auto --cov-config=.coveragerc --cov=percy percy/tests/ --cov-fail-under=20 --cov-report term-missing

lint: ## runs the linter against the project
pylint --rcfile=.pylintrc percy
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ From within a feedstock:
percy recipe render --help
percy recipe render -s linux-64 -p 3.10 -k blas_impl openblas

- Update the recipe

percy recipe sync

- Identify if the feedstock is pinned to the latest, compared to defautls:

percy recipe outdated --help
Expand Down
2 changes: 2 additions & 0 deletions environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ dependencies:
- requests
- types-requests
- ruamel.yaml
- ruamel.yaml.jinja2
- conda-build
- jsonschema
- types-jsonschema
- pre-commit
- conda-recipe-manager
3 changes: 2 additions & 1 deletion percy/commands/aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
File: aggregate.py
Description: CLI tool for performing operations against all of aggregate.
"""

from __future__ import annotations

import functools
Expand Down Expand Up @@ -111,7 +112,7 @@ def base_options(f: Callable):
"-p",
type=str,
multiple=False,
default="3.10",
default="3.12",
help="Python version. E.g. -p 3.10",
)
@click.option(
Expand Down
22 changes: 8 additions & 14 deletions percy/commands/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
File: convert.py
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should just delete this file, in favor of the one in CRM.

Description: CLI for converting an old recipe file to the "new" format.
"""

from __future__ import annotations

import os
Expand All @@ -10,12 +11,8 @@
from typing import Final

import click

from percy.parser.recipe_parser import RecipeParser
from percy.parser.types import MessageCategory, MessageTable

# Required file name for the recipe, specified in CEP-13
NEW_FORMAT_RECIPE_FILE_NAME: Final[str] = "recipe.yaml"
from conda_recipe_manager.parser.recipe_parser_convert import RecipeParserConvert
from conda_recipe_manager.types import MessageCategory, MessageTable


class ExitCode(IntEnum):
Expand Down Expand Up @@ -65,32 +62,29 @@ def convert(file: click.File, output: click.Path) -> None: # pylint: disable=re
"""
Recipe conversion CLI utility. By default, recipes print to STDOUT. Messages always print to STDERR.
"""
recipe_content: Final[str] = file.read()

parser: RecipeParser
try:
parser = RecipeParser(recipe_content)
recipe_content: Final[str] = RecipeParserConvert.pre_process_recipe_text(file.read())
recipe_converter = RecipeParserConvert(recipe_content)
except Exception as e: # pylint: disable=broad-exception-caught
print_err("An exception occurred while parsing the recipe file:")
print_err(e)
sys.exit(ExitCode.PARSE_EXCEPTION)

result: str
msg_tbl: MessageTable
try:
result, msg_tbl = parser.render_to_new_recipe_format()
v1_content, msg_tbl, _ = recipe_converter.render_to_v1_recipe_format()
except Exception as e: # pylint: disable=broad-exception-caught
print_err("An exception occurred while converting to the new recipe file:")
print_err(e)
sys.exit(ExitCode.RENDER_EXCEPTION)

if output is None:
print_out(result)
print(v1_content)
else:
if not os.path.basename(output) == "recipe.yaml":
print_err("WARNING: File is not called `recipe.yaml`.")
with open(output, "w", encoding="utf-8") as fptr:
fptr.write(result)
fptr.write(v1_content)

error_count: Final[int] = msg_tbl.get_message_count(MessageCategory.ERROR)
warn_count: Final[int] = msg_tbl.get_message_count(MessageCategory.WARNING)
Expand Down
1 change: 1 addition & 0 deletions percy/commands/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
File: main.py
Description: Primary execution point of the `click` command line interface
"""

from __future__ import annotations

import os
Expand Down
61 changes: 50 additions & 11 deletions percy/commands/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
File: recipe.py
Description: CLI for interacting with recipe files.
"""

from __future__ import annotations

import functools
Expand All @@ -16,6 +17,7 @@
import percy.render.dumper
import percy.render.recipe
from percy.render._renderer import RendererType
from percy.updater import grayskull_sync

# pylint: disable=line-too-long

Expand Down Expand Up @@ -63,30 +65,23 @@ def base_options(f: Callable):
"-s",
type=str,
multiple=True,
default=[
"linux-64",
"linux-aarch64",
"linux-ppc64le",
"linux-s390x",
"osx-arm64",
"osx-64",
"win-64",
],
default=None,
help="Architecture. E.g. -s linux-64 -s win-64",
)
@click.option(
"--python",
"-p",
type=str,
multiple=True,
default=None,
help="Python version. E.g. -p 3.9 -p 3.10",
)
@click.option(
"--others",
"-k",
type=(str, str),
multiple=True,
default={},
default=None,
help="Additional key values (e.g. -k blas_impl openblas)",
)
@functools.wraps(f)
Expand Down Expand Up @@ -222,7 +217,7 @@ def patch(
recipe: percy.render.recipe.Recipe # pylint: disable=redefined-outer-name
# Enables parse-tree mode
if parse_tree:
backend = RendererType.PERCY
backend = RendererType.CRM
op_mode = percy.render.recipe.OpMode.PARSE_TREE
recipe = percy.render.recipe.Recipe.from_file(
recipe_path,
Expand All @@ -244,3 +239,47 @@ def patch(
with open(patch_file, encoding="utf-8") as p:
recipe.patch(json.load(p), increment_build_number, op_mode=op_mode)
print("Done")


@recipe.command(short_help="Sync a recipe from pypi data")
@click.pass_obj
@click.option(
"--run_constrained",
type=bool,
is_flag=True,
show_default=True,
default=True,
multiple=False,
help="add run_constrained",
)
@click.option(
"--bump",
type=bool,
is_flag=True,
show_default=True,
default=True,
multiple=False,
help="bump build number if version is unchanged",
)
@click.option(
"--run_linter",
type=bool,
is_flag=True,
show_default=True,
default=True,
multiple=False,
help="run conda lint --fix after updating",
)
@click.option(
"--pypi_spec",
type=str,
multiple=False,
help="pypi_package spec",
)
def sync(obj, pypi_spec, run_constrained, bump, run_linter):
"""
Sync a recipe from pypi data
"""

recipe_path = obj["recipe_path"]
grayskull_sync.sync(recipe_path, pypi_spec, run_constrained, bump, run_linter)
2 changes: 1 addition & 1 deletion percy/examples/preinstall/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
_DEFAULT_AGGREGATE = "~/work/recipes/aggregate/"
_DEFAULT_PYTHON = ["3.8", "3.9", "3.10", "3.11"]
_DEFAULT_PYTHON = ["3.9", "3.10", "3.11", "3.12", "3.13"]
_DEFAULT_SUBDIRS = [
"linux-64",
"linux-ppc64le",
Expand Down
1 change: 0 additions & 1 deletion percy/parser/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
# This package contains supporting files for the `RecipeParser` class
Loading
Loading