text stringlengths 185 73.3k | repo stringlengths 7 100 | path stringlengths 4 146 | language stringclasses 7
values | hash stringlengths 16 16 | score float64 7 8.5 | stars int64 0 237k |
|---|---|---|---|---|---|---|
"""Is the acronym expansion actually IN the source? (#423 follow-up)
Reads the stored `runs-*.json` under `evals/` and makes ZERO model calls:
every emitted title is already on disk. Same move as
`measure_acronym_fabrication.py` and `extraction_collapse/measure_single_object_rate.py`.
## The hole this closes
`measur... | jasonssdev/openkos | evals/extraction_cap/measure_expansion_grounding.py | .py | 9710913dc13962a4 | 7.24 | 2 |
"""What share of a whole ingest is the window fan-out?
#739's lever touches only the per-window extraction calls. A speedup on that
loop is worth what the loop is worth as a share of the run, and nothing more --
so the speedup table beside this file is unreadable without this number.
`extract_concept_union` reports e... | jasonssdev/openkos | evals/ingest_concurrency/probe_fanout_share.py | .py | da8363e10921cc22 | 7.24 | 2 |
"""What the Ollama SERVER does with concurrent requests, and what it costs.
Two questions the main probe's speedup table cannot answer about itself, both
about the process openkos talks to rather than openkos itself:
1. **Does a default server run concurrent requests in parallel at all?** If it
queues them, then t... | jasonssdev/openkos | evals/ingest_concurrency/probe_server_capacity.py | .py | 2421087573a38b52 | 7.24 | 2 |
"""Measures whether issuing ingest's independent per-window extraction calls
CONCURRENTLY buys wall clock, and whether it costs extraction quality.
Issue #739, split out of #700 as lever 4 -- the last of that budget's five
levers still unmeasured. Levers 1 and 2 were measured and rejected (#728,
#699) and lever 3 was ... | jasonssdev/openkos | evals/ingest_concurrency/run_ingest_concurrency_probe.py | .py | 4deceda631962a9b | 7.24 | 2 |
"""What does the unbounded near-duplicate scan cost per `query --save`? (#764)
MANUAL eval tool (NOT pytest, NOT part of the shipped package). Needs Ollama
for the EMBEDDING model only -- zero chat calls. Every question it embeds was
already generated and stored by `evals/query_title/`.
## The question
#764 asks for... | jasonssdev/openkos | evals/insight_scan_bound/run_insight_scan_bound_probe.py | .py | 3e22e2a8d91c70a7 | 7.24 | 2 |
"""D9: the pair-nomination gate for chunk-backed retrieval vectors (#888).
MANUAL eval tool (NOT pytest, NOT part of the shipped package). Needs a
workspace already indexed by `openkos reindex` (real Ollama embeddings
already spent, not spent again here) -- `measure()` reads `vectors.db`
directly and issues ZERO embed... | jasonssdev/openkos | evals/pair_nomination/run_pair_nomination_probe.py | .py | d625d863f7fca251 | 7.24 | 2 |
"""
Code dataset module for code-based subliminal learning experiments.
Loads code completion prompts from the Hubinger et al. (2024) Sleeper Agents
dataset and reformats them for use as a medium for subliminal trait transmission.
Reference: Appendix D.3 of the subliminal learning paper.
"""
import json
import re
fr... | BrendanGho/liminal-training | sl/datasets/code_dataset.py | .py | 93cc4fcdf8ec7204 | 7.15 | 1 |
from dataclasses import dataclass, field
from typing import Callable, cast, Optional
import re
import numpy as np
from pathlib import Path
from loguru import logger
from datasets import load_dataset, Dataset
from sl.datasets.nums_dataset import PromptGenerator as NumsPromptGenerator, extract_format_suffix, format_numbe... | BrendanGho/liminal-training | sl/datasets/services.py | .py | 84b73c3c284fd0df | 7.15 | 1 |
"""
Run-name construction shared by the training scripts and the pipeline.
Both ``scripts/finetune_normal.py`` and ``scripts/finetune_liminal.py`` derive
their output directory (and the HuggingFace repo ID that follows from it) with
these helpers, and ``pipelines/finetune_pipeline.py`` reconstructs the same
names to l... | BrendanGho/liminal-training | sl/training/naming.py | .py | f06f9aad584c353c | 7.15 | 1 |
from typing import TypeVar, List, Literal, Union
from pathlib import Path
from pydantic import BaseModel
import json
def read_jsonl(fname: str) -> list[dict]:
"""
Read a JSONL file and return a list of dictionaries.
Args:
fname: Path to the JSONL file
Returns:
A list of dictionaries,... | BrendanGho/liminal-training | sl/utils/file_utils.py | .py | c7e6d0909c96db06 | 7.15 | 1 |
from dataclasses import dataclass, asdict
from scipy import stats
import numpy as np
import pandas as pd
@dataclass
class CI:
mean: float
lower_bound: float
upper_bound: float
count: int
confidence: float
def compute_ci(values, confidence: float) -> CI:
n = len(values)
mean = values.mean... | BrendanGho/liminal-training | sl/utils/stats_utils.py | .py | 637153bccf08a54b | 7.15 | 1 |
"""TorchRL-backed replay buffer with cached RSSM initial states.
The Dreamer trainer samples ``(B, T+1)``-shaped trajectory slices: the first
timestep supplies the latent ``(stoch, deter)`` used as the RSSM initial
state, and the remaining ``T`` timesteps are the actual training window.
After each world-model update ... | oliver-sommer/dreamer-arm | src/dreamer_arm/core/buffer.py | .py | a241dcd5b1bd8d88 | 7 | 0 |
"""Custom torch distributions used by the world model and actor-critic.
Includes:
- :class:`OneHotDist` — straight-through Gumbel-softmax discrete distribution
with uniform mixing (``unimix_ratio``) for entropy regularisation.
- :class:`MultiOneHotDist` — product of independent ``OneHotDist`` factors
(used for mul... | oliver-sommer/dreamer-arm | src/dreamer_arm/core/distributions.py | .py | b1f4ed5f724480ec | 7 | 0 |
"""Pure-function loss components used by the Dreamer agent.
Keeping these here (rather than as methods on ``Dreamer``) makes them
trivial to unit-test on synthetic inputs without spinning up the full
world model.
"""
from __future__ import annotations
import torch
from dreamer_arm.utils.tensor import to_f32
def b... | oliver-sommer/dreamer-arm | src/dreamer_arm/core/losses.py | .py | 5a2c4473066186de | 7 | 0 |
"""Dreamer agent — composition root wiring a world model + actor-critic + optimiser.
The world model is selected by ``config.wm`` (``"rssm"`` default, or
``"dinowm"``; see :mod:`dreamer_arm.core.world_model`). For the RSSM, the
representation loss is further selected by ``config.rep_loss``:
- ``"r2dreamer"``: decoder... | oliver-sommer/dreamer-arm | src/dreamer_arm/core/model.py | .py | 1f442112a699ab17 | 7 | 0 |
"""Primitive neural-network layers and shared initialization."""
from __future__ import annotations
import numpy as np
import torch
import torch.nn.functional as F
from torch import nn
from torch.nn import init as nn_init
def weight_init_(module: nn.Module, fan_type: str = "in") -> None:
"""Initialize weights w... | oliver-sommer/dreamer-arm | src/dreamer_arm/core/networks/layers.py | .py | b9158d924f64f228 | 7 | 0 |
"""LaProp optimizer.
Original implementation © 2020 Wang, T. Zhikang (MIT licence); ported here
with PyTorch 2.x-compatible call signatures for in-place tensor ops
(`addcmul_(t1, t2, value=alpha)` rather than the removed positional form).
Reference: "LaProp: Separating Momentum and Adaptivity in Adam"
(https://github... | oliver-sommer/dreamer-arm | src/dreamer_arm/core/optim/laprop.py | .py | 41e52165dae97649 | 7 | 0 |
"""One training step's optimiser plumbing: LaProp + AGC + non-finite guard + LR warmup.
Bundled into a single object so :meth:`~dreamer_arm.core.model.Dreamer.update`
reads as "compute the loss, then take a step" instead of interleaving that
with unscale / clip / guard / schedule bookkeeping.
"""
from __future__ impo... | oliver-sommer/dreamer-arm | src/dreamer_arm/core/optim/step.py | .py | 6c089d719d79a326 | 7 | 0 |
"""Builds the world model named by ``config.wm``.
Each world model is a (trainable modules, live adapter, frozen adapter)
bundle:
- ``trainable_modules`` -- handed to the agent's optimiser.
- ``all_modules`` -- every module that must be registered on the agent for
``state_dict()`` / ``.to()`` / parameter counting, ... | oliver-sommer/dreamer-arm | src/dreamer_arm/core/world_model/factory.py | .py | 1bd54fc462259434 | 7 | 0 |
"""Structural contract the agent needs from a world model.
Three world models (categorical RSSM, DINO-WM, Dreamer 4) share the same
imagination-rollout and rollout-inference code in
:class:`~dreamer_arm.core.model.Dreamer` but differ completely in how they
represent state and compute their own representation loss. Thi... | oliver-sommer/dreamer-arm | src/dreamer_arm/core/world_model/protocol.py | .py | c0c1e34e1ecaeba7 | 7 | 0 |
"""Backend-neutral policy action contract for simulation and hardware."""
from __future__ import annotations
from dataclasses import dataclass
from typing import Any, ClassVar
import numpy as np
from gymnasium import spaces
@dataclass(frozen=True, slots=True)
class ActionSpec:
"""Shared normalized Cartesian-ra... | oliver-sommer/dreamer-arm | src/dreamer_arm/envs/action.py | .py | 2285da93fb3439c2 | 7 | 0 |
"""Backend-independent damped-least-squares operational-space IK solver.
Pure-numpy, zero Meta-World coupling — importable in unit tests without MuJoCo.
All arrays are plain NumPy arrays; the caller supplies the Jacobian obtained
from ``mujoco.mj_jacSite``.
Design rationale (from the pitfall analysis):
- Constant-λ D... | oliver-sommer/dreamer-arm | src/dreamer_arm/envs/control/ik.py | .py | 72a00bffb0192c5b | 7 | 0 |
"""Backend-independent controller state and per-episode tracking metrics."""
from __future__ import annotations
from collections import deque
from collections.abc import Mapping
from dataclasses import dataclass
from typing import Any
import numpy as np
@dataclass(frozen=True)
class ServoState:
"""Resolved YAM... | oliver-sommer/dreamer-arm | src/dreamer_arm/envs/control/metrics.py | .py | 59cab195fbfc9480 | 7 | 0 |
"""Backend-neutral policy observation contract for simulation and hardware."""
from __future__ import annotations
from dataclasses import dataclass
from typing import Any, ClassVar
import numpy as np
from gymnasium import spaces
@dataclass(frozen=True, slots=True)
class ObservationSpec:
"""Shared non-privilege... | oliver-sommer/dreamer-arm | src/dreamer_arm/envs/observation.py | .py | f66c572629faeb1c | 7 | 0 |
"""Arm protocol and factory.
Each ``Arm`` implementation installs Meta-World's two injectable hooks
(``_external_actuation`` / ``_external_reset_hand``) on a task env instance.
The hook API is a fixed contract defined by the fork:
* ``_external_actuation(env, action) -> None``: fully advances physics.
* ``_external_r... | oliver-sommer/dreamer-arm | src/dreamer_arm/envs/sim/arms/base.py | .py | a52fdb11b51da2d8 | 7 | 0 |
"""Sawyer arm — no-op control seam.
Sawyer uses Meta-World's default mocap (kinematic) actuation.
Leaving ``_external_actuation`` and ``_external_reset_hand`` unset lets the
upstream code run: ``set_xyz_action + do_simulation`` for actuation and the
default ``_reset_hand`` mocap-servo for resets.
This class exists on... | oliver-sommer/dreamer-arm | src/dreamer_arm/envs/sim/arms/sawyer.py | .py | 34b0fd265afa50a7 | 7 | 0 |
"""YAM arm control seam — retained Cartesian target and DLS-IK actuation.
The YAM arm has 6 position-actuated joints (``joint1``…``joint6``) plus a
``gripper`` actuator driving the ``left_finger`` slide joint (``right_finger``
is mirrored via an equality constraint).
Control contract:
- XYZ actions are bounded Cartes... | oliver-sommer/dreamer-arm | src/dreamer_arm/envs/sim/arms/yam.py | .py | 2d02a35ed9a03e94 | 7 | 0 |
"""Environment factory for dreamer-arm.
Parses the env_name string and returns a ``SyncVectorEnv`` ready for the
online trainer.
Name format
-----------
``"metaworld:<task>"`` - single-task MT1 (all envs share the task type)
``"metaworld:MT10"`` - multi-task MT10 (10 tasks, one pinned per env)
``"metaworld:MT25... | oliver-sommer/dreamer-arm | src/dreamer_arm/envs/sim/factory.py | .py | 2f79cec0e3a8d92a | 7 | 0 |
"""Gymnasium Dict-obs adapter wrapping a single Meta-World task env.
Converts Meta-World's 39-dim flat ``state`` observation into a Dict of
non-privileged modalities that the Dreamer encoder can consume:
``scene`` - uint8 RGB (H, W, 3) from our own ``mujoco.Renderer``
``wrist_image``- uint8 RGB (H, W, 3) fro... | oliver-sommer/dreamer-arm | src/dreamer_arm/envs/sim/metaworld.py | .py | 772a77c5bd22f6d3 | 7 | 0 |
"""Route MuJoCo simulation warnings through the project logger."""
from __future__ import annotations
import logging
import re
import mujoco
log = logging.getLogger(__name__)
_WARNING_TIME_SUFFIX = re.compile(r"\s*Time\s*=\s*[-\d.]+\.?\s*$")
_warning_counts: dict[str, int] = {}
def _forward_mujoco_warning(messag... | oliver-sommer/dreamer-arm | src/dreamer_arm/envs/sim/mujoco_logging.py | .py | e825176dc582a3fb | 7 | 0 |
"""MuJoCo camera rendering and visual randomisation for simulated environments."""
from __future__ import annotations
from typing import Any
import mujoco
import numpy as np
_CAM_LOOKAT = np.array([0.0, 0.55, 0.15])
_CAM_AZIMUTH_RANGE = (100.0, 200.0)
_CAM_ELEVATION_RANGE = (-50.0, -15.0)
_CAM_DISTANCE_RANGE = (0.8... | oliver-sommer/dreamer-arm | src/dreamer_arm/envs/sim/rendering.py | .py | dae05723fd17435e | 7 | 0 |
"""Composition root for online Dreamer training.
Turns a resolved config into the objects a run needs -- envs, agent, buffer,
logger -- then hands them to :class:`~dreamer_arm.training.trainer.OnlineTrainer`.
Named to mirror ``configs/training/dreamer.yaml``, which points its
``entrypoint._target_`` at :func:`_run`.
"... | oliver-sommer/dreamer-arm | src/dreamer_arm/training/dreamer.py | .py | 6c0b3bfd0623d3d1 | 7 | 0 |
"""Hydra config discovery, validation and entrypoint dispatch.
Every command shares one shape: :func:`run_hydra` composes a config from
``configs/``, then hands it to :func:`dispatch`, which validates it and calls
whatever ``entrypoint._target_`` names. A config therefore fully determines
which code runs, and adding ... | oliver-sommer/dreamer-arm | src/dreamer_arm/utils/config.py | .py | d166143988db4d14 | 7 | 0 |
"""Console logging configuration for dreamer-arm.
One place to set up human-readable stdout logging so every line carries a
time, level, run phase and source logger, e.g.::
[12:34:56] INFO train training.trainer prefill complete at step 520
[12:35:26] INFO train utils.tracking step 1000 fps 123.... | oliver-sommer/dreamer-arm | src/dreamer_arm/utils/logging.py | .py | 8a955804877bc166 | 7 | 0 |
"""Reproducibility helpers."""
from __future__ import annotations
import os
import random
import numpy as np
import torch
def set_seed_everywhere(seed: int) -> None:
"""Seed Python's ``random``, NumPy, and PyTorch (CPU + all CUDA devices)."""
torch.manual_seed(seed)
if torch.cuda.is_available():
... | oliver-sommer/dreamer-arm | src/dreamer_arm/utils/seed.py | .py | 6d70d0116a4c9457 | 7 | 0 |
"""Tensor primitives shared across the agent: symlog / symexp, dtype helpers, padding."""
from __future__ import annotations
import numpy as np
import torch
def symlog(x: torch.Tensor) -> torch.Tensor:
"""Sign-preserving log: sign(x) * log(1 + |x|). Stable for large |x|."""
return torch.sign(x) * torch.log1... | oliver-sommer/dreamer-arm | src/dreamer_arm/utils/tensor.py | .py | 372402edf800aa25 | 7 | 0 |
"""Narrow policy for verified events announced beyond the planner window."""
from __future__ import annotations
from datetime import timedelta
from typing import Mapping
from urllib.parse import urlsplit, urlunsplit
from . import common
from .normalization import comparison_text
PUETZCHENS_MARKT_SOURCE_ID = "touri... | randomsnowflake/nrw-events | scripts/nrw_events/early_publication.py | .py | b36d1a7aa09c9db9 | 7.15 | 1 |
"""Shared editorial vocabulary used across filtering and classification."""
from dataclasses import dataclass
import json
from pathlib import Path
@dataclass(frozen=True)
class TermPolicy:
"""Declare each independent use of a vocabulary term explicitly."""
term: str
classify_as_market: bool = False
... | randomsnowflake/nrw-events | scripts/nrw_events/event_vocabulary.py | .py | 1488ef6a3eac4db2 | 7.15 | 1 |
"""Per-source health data used by the import runner and its metadata export."""
from __future__ import annotations
from dataclasses import dataclass, field
from enum import Enum
import json
import re
from typing import Any, Mapping, Optional
from .models import RawEvent, normalize_source_id
_NO_REJECTION_SAMPLE = ... | randomsnowflake/nrw-events | scripts/nrw_events/health.py | .py | 3ebf3e4fdbb9478f | 7.15 | 1 |
"""Stable public identifiers for a single event occurrence.
The website turns ``event_id`` into a permanent URL, so the value must survive
everything that legitimately changes about an event between two imports:
* feed order (an id derived from a list index is not an id),
* which source won deduplication for this occ... | randomsnowflake/nrw-events | scripts/nrw_events/identity.py | .py | 8d2be9909c9a47e8 | 7.15 | 1 |
"""Location normalization, resolution, and distance calculations."""
from __future__ import annotations
import math
import re
from html import unescape
from typing import Optional
from . import config
from .normalization import comparison_text
BONN_LAT, BONN_LON = config.BONN_LAT, config.BONN_LON
MAX_RADIUS_KM = c... | randomsnowflake/nrw-events | scripts/nrw_events/location.py | .py | d6618f0dff450555 | 7.15 | 1 |
"""Ranking functions independent from source-specific parsing."""
import re
from . import config
def distance_score(km: float, radius_km: float | None = None) -> float:
"""Score 0.1–1.0 by distance from Bonn."""
if km <= 0:
return 1.0
radius = radius_km or config.MAX_RADIUS_KM
return max(0.1... | randomsnowflake/nrw-events | scripts/nrw_events/scoring.py | .py | f01ad95d7e441072 | 7.15 | 1 |
"""Literary programme in Bonn: readings, book premieres and author talks."""
import re
from .. import common
from ..category_taxonomy import CATEGORY_BY_KEY
from . import regional_common as rc
LITERATURHAUS_ICAL = "https://literaturhaus-bonn.de/veranstaltungen/?ical=1"
PARKBUCHHANDLUNG_URL = "https://www.parkbuchha... | randomsnowflake/nrw-events | scripts/nrw_events/sources/bonn_literature.py | .py | bdba69d47e717420 | 7.15 | 1 |
"""Shared plumbing: build a filled store, time things, record results to disk.
Every bench writes a JSON blob to ``bench/results/<name>.json`` with its
parameters, environment and measurements, so findings survive the session that
produced them. Results are append-only per run: each file carries a ``runs``
list, newes... | Die-Namic-Systems/Nestor | bench/harness.py | .py | 28d426ce357a4e07 | 7.15 | 1 |
#!/usr/bin/env python3
"""Precision and recall for the decision matcher — the rate the gate turns on.
python bench/matcher_precision.py # precision/recall at the knee
python bench/matcher_precision.py --sweep # the trade-off across a bar ladder
The house already measures most of this. ``bench_de... | Die-Namic-Systems/Nestor | bench/matcher_precision.py | .py | 236863ed0640179d | 7.15 | 1 |
#!/usr/bin/env python3
"""Token matchers for the seam — the cheap option nobody measured.
Stage 3 of IDEAS.md §3.4 reported 0.000 recall at every shipped threshold on a
real human corpus. Every one of those zeros came from :class:`StringMatcher`,
which is character difflib, and the matcher was held fixed for all three... | Die-Namic-Systems/Nestor | bench/token_matchers.py | .py | cd2015f69df00756 | 7.15 | 1 |
"""Self-grant tripwire — the one authority in Nestor is the power to seal.
Nestor's covenant is narrower than a permission system: an agent may **propose**
and may not **confirm**. There is exactly one thing to protect — the power to
write a ``status="sealed"`` row, or a ``verifier=`` a serving path will honour —
beca... | Die-Namic-Systems/Nestor | hooks/before_authority.py | .py | a873c1335ff8ad40 | 7.15 | 1 |
"""SPARQL UPDATE path tests — verify the big-data-const override."""
# Tests legitimately reach into the sink's private API: the directive
# behaviour we want to lock down sits on _sparql_update and _client.
# pylint: disable=protected-access,redefined-outer-name,import-outside-toplevel
from __future__ import annotatio... | fontem-eu/fontem-virtuoso-sink | tests/test_sink_update.py | .py | 479d301bb34c80ee | 7.5 | 0 |
"""Canonical mapping order and YAML serialization for semantic metadata."""
from __future__ import annotations
from collections.abc import Mapping
import json
from typing import Any, cast
from dump_things_service.utils import json2yaml, order_dict
import yaml
def _strict_json_value(value: Any) -> Any:
"""Retur... | ORINOCO-Lite/orinoco-lite-dev | packages/orinoco-lite/src/orinoco_lite/canonical.py | .py | af0aca9bbef8e1a5 | 7 | 0 |
"""Database migration script."""
from pathlib import Path
def migrate() -> bool:
"""Run database migrations.
Returns:
True if migration successful, False otherwise
"""
raise NotImplementedError
def rollback() -> bool:
"""Rollback database migrations.
Returns:
True if rollb... | Codeby-Sameer/agentJ | scripts/migrate.py | .py | 3ea5961939075194 | 7 | 0 |
"""Daily update script for job listings."""
from pathlib import Path
def update_daily() -> bool:
"""Run daily job search and update cache.
Returns:
True if update successful, False otherwise
"""
raise NotImplementedError
def refresh_jobs() -> bool:
"""Refresh job listings from all plat... | Codeby-Sameer/agentJ | scripts/update_daily.py | .py | 207b3da17732fbcf | 7 | 0 |
"""Configuration management for AgentJ."""
from pathlib import Path
from typing import Any
from pydantic import BaseModel, Field
class AIConfig(BaseModel):
provider: str = "openrouter"
api_key: str = ""
base_url: str = "https://openrouter.ai/api/v1"
model: str = "openai/gpt-5-mini"
class LogCon... | Codeby-Sameer/agentJ | src/agentj/core/config.py | .py | 4a74a599a84f0a4d | 7 | 0 |
"""Retry mechanism for failed requests."""
import functools
import time
import random
import logging
from typing import Callable, TypeVar
T = TypeVar("T")
logger = logging.getLogger(__name__)
# Retry configuration constants from NopeRi
RETRY_MAX_ATTEMPTS = 5 # total attempts (1 original + 4 retries)
RETRY_BASE... | Codeby-Sameer/agentJ | src/agentj/core/retry.py | .py | fce3617adbc9273f | 7 | 0 |
"""Application data model."""
from datetime import datetime
from typing import Any, Dict, Optional
from pydantic import BaseModel, Field
class Application(BaseModel):
"""Represents a job application.
Attributes:
application_id: Unique application identifier
job_id: Job ID
platform: ... | Codeby-Sameer/agentJ | src/agentj/models/application.py | .py | 9629daae93810339 | 7 | 0 |
"""Company data model."""
from typing import Any, Dict, Optional
from pydantic import BaseModel, Field
class Company(BaseModel):
"""Represents a company.
Attributes:
company_id: Unique company identifier
name: Company name
website: Company website URL
description: Company de... | Codeby-Sameer/agentJ | src/agentj/models/company.py | .py | cfd3f4d4c91ec76e | 7 | 0 |
"""Job data model."""
from datetime import datetime
from typing import Any, Dict, Optional
from pydantic import BaseModel, Field
class Job(BaseModel):
"""Represents a job listing.
Attributes:
job_id: Unique job identifier
platform: Job platform (naukri, wellfound, yc, etc.)
title: J... | Codeby-Sameer/agentJ | src/agentj/models/job.py | .py | 7a701014c822f0c1 | 7 | 0 |
"""User profile data model."""
from typing import Any, Dict, Optional
from pydantic import BaseModel, Field
class Profile(BaseModel):
"""Represents a user profile.
Attributes:
profile_id: Unique profile identifier
first_name: First name
last_name: Last name
email: Email addr... | Codeby-Sameer/agentJ | src/agentj/models/profile.py | .py | 67868ad1ee2ae1cf | 7 | 0 |
"""Naukri API endpoints."""
# Endpoint URLs from NopeRi
LOGIN_URL = "https://www.naukri.com/central-login-services/v1/login"
OTP_VERIFY_URL = "https://www.naukri.com/central-login-services/v0/otp-login"
OTP_SEND_URL = "https://www.naukri.com/central-login-services/v1/otp"
PROFILE_URL = "https://www.naukri.com/mnjuser... | Codeby-Sameer/agentJ | src/agentj/platforms/naukri/endpoints.py | .py | dfce2d01c8f1a68f | 7 | 0 |
"""Naukri job search functionality."""
import logging
import json
from datetime import datetime
from typing import Any, Dict, List
from agentj.platforms.naukri.auth import NaukriLoginClient
from agentj.platforms.naukri.parser import Job, parse_job, format_jobs
from agentj.core.exceptions import NaukriAuthError, Naukr... | Codeby-Sameer/agentJ | src/agentj/platforms/naukri/search.py | .py | c18019a28f726c61 | 7 | 0 |
"""Naukri CSS/XPath selectors and constants."""
import re
# Selectors & headers from NopeRi
DEFAULT_HEADERS = {
"accept": "application/json",
"appid": "105",
"clientid": "d3skt0p",
"content-type": "application/json",
"referer": "https://www.naukri.com/nlogin/login",
"systemid": "jobseeker",
... | Codeby-Sameer/agentJ | src/agentj/platforms/naukri/selectors.py | .py | 68aa1bb74beb2cf3 | 7 | 0 |
"""Wellfound job application functionality."""
from typing import Dict
class WellfoundApply:
"""Handles job applications on Wellfound platform."""
def __init__(self) -> None:
"""Initialize Wellfound apply."""
pass
def apply(self, job_id: str, application_data: Dict) -> bool:
"""... | Codeby-Sameer/agentJ | src/agentj/platforms/wellfound/apply.py | .py | 63e35fad58d35496 | 7 | 0 |
"""Wellfound API endpoints."""
class WellfoundEndpoints:
"""Wellfound API endpoint definitions."""
BASE_URL = "https://www.wellfound.com"
API_BASE_URL = "https://api.wellfound.com/v1"
# Authentication endpoints
LOGIN = f"{API_BASE_URL}/auth/login"
LOGOUT = f"{API_BASE_URL}/auth/logout"
... | Codeby-Sameer/agentJ | src/agentj/platforms/wellfound/endpoints.py | .py | 45ef7b4e1f3f7cb7 | 7 | 0 |
"""How much of a real city's population the surname table can speak to at all.
Uses instate's 2017 electoral-roll surname counts. instate is not a hard
dependency: if its table is not on disk this returns None and the build says so
rather than failing.
"""
from __future__ import annotations
import csv
import gzip
i... | in-rolls/last-name-basis | analyses/01_surname_to_category/coverage.py | .py | e76fd85bd75251c3 | 7.24 | 2 |
"""Load the outkast SECC table and pool it into one row per surname.
The only input is the shipped, disclosure-limited artifact:
``state x birth_year x last_name -> n_sc, n_st, n_other``, cells with at least
100 reference records. Everything downstream reads the frame this module
returns; probabilities live as column... | in-rolls/last-name-basis | analyses/01_surname_to_category/data.py | .py | 15ff15c52f492c16 | 7.24 | 2 |
"""Per-name informativeness measures.
Three questions get three columns, because they disagree and the disagreement
is the finding:
``err`` how often the name-based guess is wrong.
``gain`` how many of those errors the name actually saved you, versus
ignoring it and always naming the commones... | in-rolls/last-name-basis | analyses/01_surname_to_category/metrics.py | .py | a65b803ced105bf9 | 7.24 | 2 |
"""Render note/note.md from the generated tables.
Every number is read from out/tab, so nothing is hand-copied and the prose
cannot drift from the build.
"""
from __future__ import annotations
import json
import textwrap
from pathlib import Path
import pandas as pd
HERE = Path(__file__).resolve().parent
TAB = HER... | in-rolls/last-name-basis | analyses/01_surname_to_category/note.py | .py | 5122dd7e923860d1 | 7.24 | 2 |
"""Build every table and figure. Single entry point: `make all`."""
from __future__ import annotations
import json
from pathlib import Path
import coverage as cov
import figures
import pandas as pd
import report
from data import base_rates, load_cells, per_name
from metrics import (
add_metrics,
by_frequency... | in-rolls/last-name-basis | analyses/01_surname_to_category/pipeline.py | .py | c03d8270551f0941 | 7.24 | 2 |
"""Tables for the note. Every number here comes from the per-name frame."""
from __future__ import annotations
import pandas as pd
from data import PROB_COLS, load_cells, per_name
from metrics import add_metrics, headline
# Names a reader is likely to try, including two the table cannot answer.
LOOKUP = [
"sood"... | in-rolls/last-name-basis | analyses/01_surname_to_category/report.py | .py | 63ec47e598d2e68b | 7.24 | 2 |
"""Bihar ladders: what a surname buys you at successively coarser geographies.
Two ready-made ladders ship inside the `naampata` package in the `jati` repo.
Both are already aggregated to (level, cell, group) counts, so nothing here
touches the individual-level files in `land/data/derived/`, which run to a
gigabyte ap... | in-rolls/last-name-basis | analyses/02_jati_by_geography/data.py | .py | 2b58b43b606dbf99 | 7.24 | 2 |
"""The Bihar Mahadalit census, scored one rung finer than the shipped ladder.
`naampata`'s `census_ladder` stops at the village. The raw district files carry
a level below it -- `tola_basti`, the hamlet -- which is the finest geography in
any of this data and has never been scored.
Everything here is Scheduled Caste ... | in-rolls/last-name-basis | analyses/02_jati_by_geography/mahadalit.py | .py | 1ebf5ef5b7db6e87 | 7.24 | 2 |
"""Render this analysis's note from its generated tables."""
from __future__ import annotations
import json
import textwrap
from pathlib import Path
import pandas as pd
HERE = Path(__file__).resolve().parent
TAB = HERE / "out/tab"
FIG = "out/fig"
def reflow(md: str, width: int = 80) -> str:
def fill(text: str... | in-rolls/last-name-basis | analyses/02_jati_by_geography/note.py | .py | 7fad2522c1fa580d | 7.24 | 2 |
"""Score the Bihar ladders: how fast caste information atrophies with distance.
Single entry point: `make a02`.
"""
from __future__ import annotations
import json
from pathlib import Path
import data as source
import mahadalit
import pandas as pd
from last_name_basis import leave_one_out_ladder, score_ladder
HERE... | in-rolls/last-name-basis | analyses/02_jati_by_geography/pipeline.py | .py | 755322d7c6f51cd1 | 7.24 | 2 |
"""Surname frequencies from instate's 2017 electoral rolls.
Two floors in the shipped table bound everything built on it, and both are
stated in the note rather than left for a reader to discover:
``total_n >= 3`` names appearing once or twice are absent, so the real tail is
longer than any curve... | in-rolls/last-name-basis | analyses/03_how_few_names/data.py | .py | d545111831e67578 | 7.24 | 2 |
"""How concentrated are Indian surnames, and what counts as one?
Entry point: `make a03`.
"""
from __future__ import annotations
import importlib.util
import json
from pathlib import Path
import data as source
import figures
import pandas as pd
import titles
import variants
HERE = Path(__file__).resolve().parent
T... | in-rolls/last-name-basis | analyses/03_how_few_names/pipeline.py | .py | e304094732a774a9 | 7.24 | 2 |
"""Assign rare spellings to the common name they are probably a variant of.
Assignment, not clustering. Edit-distance components chain -- `a` links to `b`
links to `c` while `a` and `c` are unrelated -- so any partition of them would
be arbitrary. Each tail name gets mapped to its nearest head name or to nothing,
whic... | in-rolls/last-name-basis | analyses/03_how_few_names/variants.py | .py | 91482047f0f28381 | 7.24 | 2 |
"""Which position holds the surname, for every state.
Analysis 04 found Maharashtra writes the surname first by matching against the
father's name. That test cannot run where the roll records the relative as a
bare given name -- Gujarat, Tamil Nadu, Kerala -- which is exactly where the
question also matters.
This is ... | in-rolls/last-name-basis | analyses/04_which_token_is_the_surname/position.py | .py | c86e5e0f5049d109 | 7.24 | 2 |
"""Find the family name by asking which token passed between two relatives.
Indian electoral rolls record, for every elector, the name of their father or
husband. A token appearing in both names is a token that moved between two
family members, which is what a family name is. Everything else in the name --
an honorifi... | in-rolls/last-name-basis | analyses/04_which_token_is_the_surname/transmission.py | .py | 7e98ae702ca57d08 | 7.24 | 2 |
"""Whose name tells you nothing, and whether that group is random.
The other analyses report a population average: a name saves about nine
mistakes per hundred, and for most people it changes nothing. This asks who the
"most people" are, because if the uninformative names are not evenly spread then
every name-based ca... | in-rolls/last-name-basis | analyses/05_who_has_an_uninformative_name/data.py | .py | ff04506e431b6026 | 7.24 | 2 |
"""Whose name tells you nothing. Entry point: `make a05`."""
from __future__ import annotations
import importlib.util
import json
from pathlib import Path
import data as source
import pandas as pd
HERE = Path(__file__).resolve().parent
TAB, FIG = HERE / "out/tab", HERE / "out/fig"
SEX_STATES = ["bihar", "rajasthan"... | in-rolls/last-name-basis | analyses/05_who_has_an_uninformative_name/pipeline.py | .py | a4ebe6117e551d0c | 7.24 | 2 |
"""How well could someone do with everything the electoral roll prints?
The rest of this repo measures a floor: what a surname alone gives away. This
measures the other end. Every cue used here -- the name, the father's or
husband's name, and the hamlet -- is printed on a public roll page.
The trap, and it cost two w... | in-rolls/last-name-basis | analyses/06_neighbours/ceiling.py | .py | 412b6ff4b76f6f9e | 7.24 | 2 |
"""Does knowing who lives around you rescue an uninformative surname?
Analysis 02 shows surname plus village is far better than surname alone. That
comparison memorises the village: it learns the jati mix of every particular
village and looks yours up. It says nothing about a stranger in a village you
have never seen,... | in-rolls/last-name-basis | analyses/06_neighbours/neighbours.py | .py | 0fdffcf312bcdba0 | 7.24 | 2 |
"""Render this analysis's note from its generated tables."""
from __future__ import annotations
import textwrap
from pathlib import Path
import pandas as pd
HERE = Path(__file__).resolve().parent
TAB = HERE / "out/tab"
FIG = "out/fig"
def reflow(md: str, width: int = 80) -> str:
out = []
for block in md.s... | in-rolls/last-name-basis | analyses/06_neighbours/note.py | .py | 6e3028001241a2c1 | 7.24 | 2 |
"""Do neighbours rescue an uninformative surname? Entry point: `make a06`."""
from __future__ import annotations
import importlib.util
import json
import sys
from pathlib import Path
import ceiling as C
import neighbours as nb
import pandas as pd
HERE = Path(__file__).resolve().parent
TAB, FIG = HERE / "out/tab", H... | in-rolls/last-name-basis | analyses/06_neighbours/pipeline.py | .py | edaa189e79290b63 | 7.24 | 2 |
"""Where a surname works, state by state.
Analyses 01 and 05 report one national number and its split by caste. Neither
says *where* the name works, and the range across states is far wider than the
national figure suggests.
Everything comes from the same source as analysis 01 -- outkast's SECC extract,
`state x birt... | in-rolls/last-name-basis | analyses/07_where_the_name_works/data.py | .py | 7dcc1eadd0397f5d | 7.24 | 2 |
"""Render analysis 07's note from its outputs."""
from __future__ import annotations
import json
from pathlib import Path
import pandas as pd
HERE = Path(__file__).resolve().parent
TAB, FIG = HERE / "out/tab", "out/fig"
def main() -> None:
s = json.loads((TAB / "summary.json").read_text())
t = pd.read_csv... | in-rolls/last-name-basis | analyses/07_where_the_name_works/note.py | .py | bcc8dda9c3ec9fac | 7.24 | 2 |
"""Karnataka recruitment lists: when the last token is not a surname.
Analysis 04 found that Maharashtra writes the surname first, so instate's
last-token column held a given name there. Karnataka fails the same assumption
by a different route: its commonest last tokens are single initials.
S 772 R 550 K 534 ... | in-rolls/last-name-basis | analyses/08_karnataka_initials/data.py | .py | ba2da4a530cd36d7 | 7.24 | 2 |
"""Shared scoring. One measure, used by every analysis: mistakes per hundred.
Guess the commonest category in whatever group you can place someone in, and
count how often you are wrong. It needs no gloss, it is bounded, and it ranks
names by how *certain* they leave you rather than by how much they surprise you
-- whi... | in-rolls/last-name-basis | src/last_name_basis/scoring.py | .py | 72437a877b48fe9b | 7.24 | 2 |
"""Shared drawing vocabulary, so the analyses read as one argument.
Everything is expressed in mistakes per hundred -- the unit the question is
actually asked in -- and the hundred-square grid is the recurring device.
"""
from __future__ import annotations
import matplotlib
matplotlib.use("Agg")
import matplotlib.p... | in-rolls/last-name-basis | src/last_name_basis/style.py | .py | 3d4bb57542e506ae | 7.24 | 2 |
"""Validated reader for Upnaam's aggregate electoral-roll outputs."""
from __future__ import annotations
import os
from collections.abc import Iterator
from pathlib import Path
import numpy as np
import pandas as pd
import pyarrow.parquet as pq
RESOLVER_REVISION = "resolver-v1"
ROLL_COLUMNS = (
"source_row",
... | in-rolls/last-name-basis | src/last_name_basis/upnaam.py | .py | b830c94cbfa80b7a | 7.24 | 2 |
"""Invariants for the surname-concentration analysis."""
from __future__ import annotations
import numpy as np
import pytest
from conftest import load
source = load("03_how_few_names", "data")
titles = load("03_how_few_names", "titles")
variants = load("03_how_few_names", "variants")
@pytest.fixture(scope="module"... | in-rolls/last-name-basis | tests/test_how_few_names.py | .py | 362f3684dfc12c64 | 7.74 | 2 |
"""Invariants for the Bihar ladders."""
from __future__ import annotations
import pytest
from conftest import load
source = load("02_jati_by_geography", "data")
from last_name_basis import leave_one_out_ladder, score_ladder # noqa: E402
RUNGS = ["surname+village", "surname+zone", "surname+district", "surname"]
... | in-rolls/last-name-basis | tests/test_jati_by_geography.py | .py | aa5e0dbdedd365f3 | 7.74 | 2 |
"""Invariants for the held-out neighbours test."""
from __future__ import annotations
import numpy as np
import pandas as pd
import pytest
from conftest import load
nb = load("06_neighbours", "neighbours")
def test_the_split_is_by_village_and_disjoint():
"""Leakage here would manufacture the finding."""
vi... | in-rolls/last-name-basis | tests/test_neighbours.py | .py | e8b359fbf54d59d1 | 7.74 | 2 |
"""Every headline number on the front page must match the output it came from.
The failure this guards against has happened four times: an analysis is re-run,
its note is regenerated automatically, and the README -- which is written by
hand -- keeps the old number. Nobody notices, because nothing compares the two.
Ea... | in-rolls/last-name-basis | tests/test_readme_numbers.py | .py | e97a67327c8b3047 | 7.74 | 2 |
"""Reconciliation and regression checks on the per-name table."""
from __future__ import annotations
import numpy as np
import pandas as pd
import pytest
from conftest import load
from last_name_basis import entropy_bits
data = load("01_surname_to_category", "data")
metrics = load("01_surname_to_category", "metrics... | in-rolls/last-name-basis | tests/test_surname_to_category.py | .py | 0dce884b1e746123 | 7.74 | 2 |
"""Analysis 07: where a surname works, and analysis 08's Karnataka null."""
from __future__ import annotations
import json
import pathlib
import pandas as pd
import pytest
ROOT = pathlib.Path(__file__).resolve().parent.parent
A07 = ROOT / "analyses/07_where_the_name_works/out/tab"
A08 = ROOT / "analyses/08_karnatak... | in-rolls/last-name-basis | tests/test_where_the_name_works.py | .py | c1fe199da62bb0ea | 7.74 | 2 |
"""Invariants for the surname-transmission scorer."""
from __future__ import annotations
from pathlib import Path
import pandas as pd
import pytest
from conftest import load
tr = load("04_which_token_is_the_surname", "transmission")
TAB = Path(__file__).resolve().parent.parent / (
"analyses/04_which_token_is_t... | in-rolls/last-name-basis | tests/test_which_token.py | .py | 5f07bc538e20f948 | 7.74 | 2 |
# backend/auth/google_auth.py
import os
import json
import requests
from google_auth_oauthlib.flow import Flow
from google.oauth2.credentials import Credentials
from google.oauth2 import id_token as google_id_token
from google.auth.transport.requests import Request
SCOPES = [
"openid",
"https://www.googleapis.... | ANewProfile/breadcrumbs | backend/auth/google_auth.py | .py | 66b054e137859885 | 7 | 0 |
from fastapi import HTTPException, Request
from limits import parse
from limits.storage import MemoryStorage
from limits.strategies import MovingWindowRateLimiter
from auth.session import SESSION_COOKIE_NAME
# In-memory: fine for Railway's single-instance Hobby deployment. If this ever
# runs multiple instances, count... | ANewProfile/breadcrumbs | backend/rate_limit.py | .py | 16e3ba3f34ff7256 | 7 | 0 |
import re
from datetime import date, datetime, time, timedelta, timezone
from typing import Literal
from zoneinfo import ZoneInfo
from fastapi import APIRouter, HTTPException, Depends
from pydantic import BaseModel, field_validator, model_validator
from database import school_schedule_collection, settings_collection, u... | ANewProfile/breadcrumbs | backend/routers/school_schedule.py | .py | 280af3e9214a1364 | 7 | 0 |
from datetime import datetime, timezone
from auth.google_auth import get_credentials_for_user, revoke_credentials
from services.calendar_write import delete_gcal_event
def cleanup_future_gcal_events(tasks_collection, users_collection, user: dict) -> None:
"""
Before wiping a user's tasks, remove the real cale... | ANewProfile/breadcrumbs | backend/services/account_service.py | .py | e212693981910808 | 7 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.