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
3 changes: 2 additions & 1 deletion agents/anyplot/briefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
from collections.abc import Iterator, Sequence
from typing import Any

from .data.roles import DataRole
from core.spec_roles import DataRole

from .policy import fence
from .schemas import MAX_TOP_VALUES, Binding, DatasetProfile
from .session_state import SessionView
Expand Down
20 changes: 2 additions & 18 deletions agents/anyplot/code/readiness.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@
from dataclasses import dataclass, field
from typing import Literal

from core.adaptability import CRITICAL_VALUES
from core.palette import IMPRINT
from core.spec_roles import MAP_SPECS

from ..schemas import MAX_NOTE_CHARS
from .normalise import SUPPORTED_LIBRARIES, measure_canvas
Expand All @@ -84,25 +86,7 @@

ReadinessStatus = Literal["blocked", "coupled", "clean"]

MAP_SPECS = frozenset(
{
"bubble-map-geographic",
"cartogram-area-distortion",
"choropleth-basic",
"contour-map-geographic",
"flowmap-origin-destination",
"heatmap-geographic",
"map-connection-lines",
"map-marker-clustered",
"map-projections",
"map-route-path",
"map-tile-background",
"map-tilegrid",
"scatter-map-geographic",
}
)
MIN_PALETTE_ENTRIES = 6
CRITICAL_VALUES = frozenset({1.645, 1.96, 2.326, 2.576, 3.291})
MAX_SECURITY_REASONS = 5
MAX_SNIPPET_CHARS = 48
MAX_LINE_SNIPPET_CHARS = 2 * MAX_SNIPPET_CHARS
Expand Down
3 changes: 2 additions & 1 deletion agents/anyplot/data/bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@
from dataclasses import dataclass, field
from difflib import SequenceMatcher

from core.spec_roles import DataRole, RoleKind

from ..schemas import Binding, ColumnDtype, ColumnProfile, DatasetProfile
from .computed import match_score, window_line, window_rank
from .parse import value_like
from .roles import DataRole, RoleKind
from .shape import long_suggestion, takes_labels
from .signs import has_negative, sign_line
from .temporal import CAMEL as _CAMEL
Expand Down
2 changes: 1 addition & 1 deletion agents/anyplot/data/computed.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from collections.abc import Iterable
from dataclasses import replace

from .roles import DataRole
from core.spec_roles import DataRole


COMPUTED_ROLES: dict[str, frozenset[str]] = {
Expand Down
3 changes: 2 additions & 1 deletion agents/anyplot/data/shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,13 @@
from dataclasses import dataclass
from typing import Any

from core.spec_roles import DataRole

from ..language import DEFAULT_LANGUAGE, canonical
from ..schemas import MAX_ROWS, Binding, ColumnProfile, DatasetProfile
from .months import fold, named_months
from .parse import ID_WORDS
from .prepare import MAX_LONGER_COLUMNS
from .roles import DataRole
from .temporal import WORDS, time_keys


Expand Down
3 changes: 2 additions & 1 deletion agents/anyplot/data/signs.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
from collections.abc import Iterable
from dataclasses import replace

from core.spec_roles import DataRole

from ..schemas import ColumnProfile
from .roles import DataRole


NON_NEGATIVE_ROLES: frozenset[str] = frozenset(
Expand Down
7 changes: 3 additions & 4 deletions agents/anyplot/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
model_validator,
)

from core.spec_roles import ROLE_PATTERN

from .language import DEFAULT_LANGUAGE, LANGUAGE_PATTERN


Expand Down Expand Up @@ -158,10 +160,7 @@ def artifact_names(themes: Iterable[str]) -> list[ArtifactName]:
return names + code_and_data


# A role is matched against the spec's `## Data` bullets later; the pattern only keeps
# arbitrary text out. Digits and capitals are allowed because 21 of 325 specs name
# roles such as `log2_fold_change`, `lower_95` or `temperature_K`.
ROLE_PATTERN = r"^[A-Za-z_][A-Za-z0-9_]{0,31}$"
# ROLE_PATTERN (imported above) lives with the role parser in core/spec_roles.py.
RENDER_ID_PATTERN = r"^[A-Za-z0-9_-]{1,64}$"

_WHITESPACE = re.compile(r"\s+")
Expand Down
3 changes: 2 additions & 1 deletion agents/anyplot/session_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@

from pydantic import BaseModel, ConfigDict, Field, model_validator

from core.spec_roles import DataRole, parse_roles

from .data.bindings import BindingCheck, check_bindings, resolve_role
from .data.computed import mark_computed
from .data.roles import DataRole, parse_roles
from .data.signs import mark_non_negative
from .language import DEFAULT_LANGUAGE, SOURCES, LanguageSource, is_valid
from .schemas import MAX_CODE_CHARS, Binding, DatasetProfile
Expand Down
3 changes: 1 addition & 2 deletions agents/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@

from agents.anyplot import agent as agent_module
from agents.anyplot import telemetry
from agents.anyplot.code.readiness import MAP_SPECS
from agents.anyplot.data.bindings import check_bindings, label_siblings
from agents.anyplot.data.classify import classify_paste
from agents.anyplot.data.parse import (
Expand All @@ -149,7 +148,6 @@
without_context,
)
from agents.anyplot.data.prepare import Operation, PrepareError, apply_operations, with_date_notes
from agents.anyplot.data.roles import DataRole
from agents.anyplot.data.shape import long_suggestion
from agents.anyplot.data.store import StoreFull
from agents.anyplot.data.transcribe import (
Expand Down Expand Up @@ -238,6 +236,7 @@
)
from agents.stream import MAX_DONE_ROLES, Translator
from core.constants import SUPPORTED_LIBRARIES
from core.spec_roles import MAP_SPECS, DataRole


logger = logging.getLogger("anyplot.agents")
Expand Down
Loading
Loading