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

Use an external json schema for botconfig #1894

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
181 changes: 5 additions & 176 deletions conda_smithy/data/conda-forge.json
Original file line number Diff line number Diff line change
Expand Up @@ -250,183 +250,13 @@
"type": "object"
},
"BotConfig": {
"additionalProperties": false,
"description": "This dictates the behavior of the conda-forge auto-tick bot which issues\nautomatic version updates/migrations for feedstocks.",
"properties": {
"automerge": {
"anyOf": [
{
"type": "boolean"
},
{
"$ref": "#/$defs/BotConfigAutoMergeChoice"
},
{
"type": "null"
}
],
"default": false,
"description": "Automatically merge PRs if possible",
"title": "Automerge"
},
"check_solvable": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"default": true,
"description": "Open PRs only if resulting environment is solvable.",
"title": "Check Solvable"
},
"inspection": {
"anyOf": [
{
"$ref": "#/$defs/BotConfigInspectionChoice"
},
{
"type": "null"
}
],
"default": "hint",
"description": "Method for generating hints or updating recipe"
},
"abi_migration_branches": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"default": [],
"description": "List of branches for additional bot migration PRs. Make sure branch names are `str` by quoting the value.",
"title": "Abi Migration Branches"
},
"run_deps_from_wheel": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"default": false,
"description": "Update run dependencies from the pip wheel",
"title": "Run Deps From Wheel"
},
"version_updates": {
"anyOf": [
{
"$ref": "#/$defs/BotConfigVersionUpdates"
},
{
"type": "null"
}
],
"description": "Bot config for version update PRs"
}
},
"title": "BotConfig",
"type": "object"
},
"BotConfigAutoMergeChoice": {
"enum": [
"version",
"migration"
],
"title": "BotConfigAutoMergeChoice",
"type": "string"
},
"BotConfigInspectionChoice": {
"enum": [
"hint",
"hint-all",
"hint-source",
"hint-grayskull",
"update-all",
"update-source",
"update-grayskull",
"disabled"
],
"title": "BotConfigInspectionChoice",
"type": "string"
},
"BotConfigVersionUpdates": {
"additionalProperties": false,
"description": "This dictates the behavior of the conda-forge auto-tick bot for version\nupdates",
"properties": {
"random_fraction_to_keep": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"description": "Fraction of versions to keep for frequently updated packages",
"title": "Random Fraction To Keep"
},
"exclude": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"default": [],
"description": "List of versions to exclude. Make sure branch names are `str` by quoting the value.",
"title": "Exclude"
},
"sources": {
"anyOf": [
{
"items": {
"$ref": "#/$defs/BotConfigVersionUpdatesSourcesChoice"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "List of sources to use for version updates",
"title": "Sources"
"allOf": [
{
"$ref": "https://gist.githubusercontent.com/isuruf/7fbc5a6d53e6a3f5450b90a12c1ace5a/raw/ddb6054c8683ac302a567bd8b42e792a8d4bda30/conda-forge-bot-config.json"
}
},
"title": "BotConfigVersionUpdates",
"type": "object"
},
"BotConfigVersionUpdatesSourcesChoice": {
"enum": [
"cran",
"github",
"incrementalpharawurl",
"librariesio",
"npm",
"nvidia",
"pypi",
"rawurl",
"rosdistro"
],
"title": "BotConfigVersionUpdatesSourcesChoice",
"type": "string"
"description": "This dictates the behavior of the conda-forge auto-tick bot which issues\nautomatic version updates/migrations for feedstocks.",
"title": "BotConfig"
},
"CIservices": {
"enum": [
Expand Down Expand Up @@ -1677,7 +1507,6 @@
"type": "object"
}
},
"additionalProperties": false,
"description": "This model describes in detail the top-level fields in `conda-forge.yml`.\nGeneral configuration options are described below within the `Fields`\nspecifications. Additional examples are provided as part of the object\ndescription. Values and options are subject to change, and will be\nflagged as Deprecated as appropriate.",
"properties": {
"conda_build": {
Expand Down
11 changes: 1 addition & 10 deletions conda_smithy/data/conda-forge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,7 @@ azure:
store_build_artifacts: false
timeout_minutes: null
upload_packages: true
bot:
abi_migration_branches: []
automerge: false
check_solvable: true
inspection: hint
run_deps_from_wheel: false
version_updates:
exclude: []
random_fraction_to_keep: null
sources: null
bot: {}
build_platform:
emscripten_wasm32: emscripten_wasm32
freebsd_64: freebsd_64
Expand Down
105 changes: 21 additions & 84 deletions conda_smithy/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
from typing import Any, Dict, List, Literal, Optional, Union

import yaml
import orjson
from pydantic import BaseModel, Field, create_model, ConfigDict
from pydantic import HttpUrl

from conda.base.constants import KNOWN_SUBDIRS

Expand Down Expand Up @@ -59,34 +61,6 @@ class CIservices(StrEnum):
disable = "None"


class BotConfigAutoMergeChoice(StrEnum):
VERSION = "version"
MIGRATION = "migration"


class BotConfigInspectionChoice(StrEnum):
HINT = "hint"
HINT_ALL = "hint-all"
HINT_SOURCE = "hint-source"
HINT_GRAYSKULL = "hint-grayskull"
UPDATE_ALL = "update-all"
UPDATE_SOURCE = "update-source"
UPDATE_GRAYSKULL = "update-grayskull"
DISABLED = "disabled"


class BotConfigVersionUpdatesSourcesChoice(StrEnum):
CRAN = "cran"
GITHUB = "github"
INCREMENT_ALPHA_RAW_URL = "incrementalpharawurl"
LIBRARIES_IO = "librariesio"
NPM = "npm"
NVIDIA = "nvidia"
PYPI = "pypi"
RAW_URL = "rawurl"
ROS_DISTRO = "rosdistro"


##############################################
########## Model definitions #################
##############################################
Expand Down Expand Up @@ -311,29 +285,8 @@ class GithubActionsConfig(BaseModel):
)


class BotConfigVersionUpdates(BaseModel):
"""
This dictates the behavior of the conda-forge auto-tick bot for version
updates
"""

model_config: ConfigDict = ConfigDict(extra="forbid")

random_fraction_to_keep: Optional[float] = Field(
None,
description="Fraction of versions to keep for frequently updated packages",
)

exclude: Optional[List[str]] = Field(
default=[],
description="List of versions to exclude. "
"Make sure branch names are `str` by quoting the value.",
)

sources: Optional[List[BotConfigVersionUpdatesSourcesChoice]] = Field(
None,
description="List of sources to use for version updates",
)
class Url(HttpUrl):
pass


class BotConfig(BaseModel):
Expand All @@ -342,38 +295,12 @@ class BotConfig(BaseModel):
automatic version updates/migrations for feedstocks.
"""

model_config: ConfigDict = ConfigDict(extra="forbid")

automerge: Optional[Union[bool, BotConfigAutoMergeChoice]] = Field(
False,
description="Automatically merge PRs if possible",
)

check_solvable: Optional[bool] = Field(
default=True,
description="Open PRs only if resulting environment is solvable.",
)

inspection: Optional[BotConfigInspectionChoice] = Field(
default="hint",
description="Method for generating hints or updating recipe",
)

abi_migration_branches: Optional[List[str]] = Field(
default=[],
description="List of branches for additional bot migration PRs. "
"Make sure branch names are `str` by quoting the value.",
)

run_deps_from_wheel: Optional[bool] = Field(
default=False,
description="Update run dependencies from the pip wheel",
)

version_updates: Optional[BotConfigVersionUpdates] = Field(
default_factory=BotConfigVersionUpdates,
description="Bot config for version update PRs",
)
class Config:
json_schema_extra = {
"$ref": Url(
"https://gist.githubusercontent.com/isuruf/7fbc5a6d53e6a3f5450b90a12c1ace5a/raw/ddb6054c8683ac302a567bd8b42e792a8d4bda30/conda-forge-bot-config.json"
Copy link
Member Author

Choose a reason for hiding this comment

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

FIXME: change this

)
}


class CondaBuildConfig(BaseModel):
Expand Down Expand Up @@ -1260,9 +1187,19 @@ class ConfigModel(BaseModel):

model = ConfigModel()

def json_dumps_default(o):
if isinstance(o, Url):
return str(o)
raise TypeError

with CONDA_FORGE_YAML_SCHEMA_FILE.open(mode="w+") as f:
obj = model.model_json_schema()
f.write(json.dumps(obj, indent=2))

f.write(
orjson.dumps(
obj, default=json_dumps_default, option=orjson.OPT_INDENT_2
).decode("utf-8")
)
f.write("\n")

with CONDA_FORGE_YAML_DEFAULTS_FILE.open(mode="w+") as f:
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ dependencies:
- libarchive
- cirun >=0.30
- pydantic >=2,<3
- orjson
- jsonschema
- backports.strenum
- exceptiongroup
Loading