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

Adjusts local_context_data #185

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open
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
11 changes: 7 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ on: # yamllint disable

jobs:
tests:
runs-on: "ubuntu-20.04"
runs-on: "ubuntu-24.04"
strategy:
fail-fast: true
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
nautobot-version: ["2.0", "2.1", "2.2", "2.3", "stable"]
env:
PYTHON_VER: "${{ matrix.python-version }}"
Expand All @@ -20,14 +20,17 @@ jobs:
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
with:
poetry-version: "1.8.5"
python-version: "3.12"
- name: "Set up Docker Buildx"
id: "buildx"
uses: "docker/setup-buildx-action@v3"
- name: "Tests"
run: "poetry run invoke tests"
publish_pypi:
name: "Push Package to PyPI"
runs-on: "ubuntu-20.04"
runs-on: "ubuntu-24.04"
if: "startsWith(github.ref, 'refs/tags/v')"
steps:
- name: "Check out repository code"
Expand All @@ -37,7 +40,7 @@ jobs:
with:
python-version: "3.9"
- name: "Install Python Packages"
run: "pip install poetry"
run: "pip install poetry==1.8.5"
- name: "Set env"
run: "echo RELEASE_VERSION=${GITHUB_REF:10} >> $GITHUB_ENV"
- name: "Run Poetry Version"
Expand Down
5 changes: 3 additions & 2 deletions development/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ RUN apt-get -y update && apt-get -y install --no-install-recommends \
git \
&& rm -rf /var/lib/apt/lists/*

RUN curl -sSL https://install.python-poetry.org | python3 - && \
# Install specific version of Poetry (1.8.5)
RUN curl -sSL https://install.python-poetry.org | POETRY_VERSION=1.8.5 python3 - && \
/root/.local/bin/poetry config virtualenvs.create false

WORKDIR /source
COPY pyproject.toml poetry.lock /source/
COPY pyproject.toml poetry.lock README.md /source/

RUN git config --global --add safe.directory /source

Expand Down
1 change: 1 addition & 0 deletions development/Dockerfile.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

!/pyproject.toml
!/poetry.lock
!/README.md
2 changes: 1 addition & 1 deletion pynautobot/core/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def list_parser(list_item):
for k, v in values.items():
if isinstance(v, dict):
lookup = getattr(self.__class__, k, None)
if k in ["custom_fields", "local_context_data"] or hasattr(lookup, "_json_field"):
if k in ["custom_fields", "local_config_context_data"] or hasattr(lookup, "_json_field"):
self._add_cache((k, v.copy()))
setattr(self, k, v)
continue
Expand Down
4 changes: 2 additions & 2 deletions pynautobot/models/ipam.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __str__(self):
return parent_record_string or str(self.prefix)

@property
def available_ips(self):
def available_ips(self) -> DetailEndpoint:
"""
Represents the ``available-ips`` detail endpoint.

Expand Down Expand Up @@ -69,7 +69,7 @@ def available_ips(self):
return DetailEndpoint(self, "available-ips", custom_return=IpAddresses)

@property
def available_prefixes(self):
def available_prefixes(self) -> DetailEndpoint:
"""
Represents the ``available-prefixes`` detail endpoint.

Expand Down
26 changes: 24 additions & 2 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import os
import sys
from distutils.util import strtobool
from invoke import task

try:
Expand All @@ -19,6 +18,29 @@
PYTHON_VER = os.getenv("INVOKE_PYNAUTOBOT_PYTHON_VER", os.getenv("PYTHON_VER", "3.8"))


def is_truthy(arg):
"""Convert "truthy" strings into Booleans.

Examples
--------
>>> is_truthy('yes')
True
Args:
arg (str): Truthy string (True values are y, yes, t, true, on and 1; false values are n, no,
f, false, off and 0. Raises ValueError if val is anything else.
"""
if isinstance(arg, bool):
return arg

val = str(arg).lower()
if val in ("y", "yes", "t", "true", "on", "1"):
return True
elif val in ("n", "no", "f", "false", "off", "0"):
return False
else:
raise ValueError(f"Invalid truthy value: `{arg}`")


def _get_image_name_and_tag():
"""Return image name and tag. Necessary to avoid double build in upstream testing"""

Expand All @@ -37,7 +59,7 @@ def _get_image_name_and_tag():
# Gather current working directory for Docker commands
PWD = os.getcwd()
# Local or Docker execution provide "local" to run locally without docker execution
INVOKE_LOCAL = strtobool(os.getenv("INVOKE_LOCAL", "False"))
INVOKE_LOCAL = is_truthy(os.getenv("INVOKE_LOCAL", "False"))

_DEFAULT_SERVICE = "pynautobot-dev"
_DOCKER_COMPOSE_ENV = {
Expand Down
Loading