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

Support pydantic v1 and v2 #118

Merged
merged 4 commits into from
Jan 7, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.10']
galaxy-branch: ['release_22.01', 'dev']
python-version: ['3.8', '3.11']
galaxy-branch: ['release_23.0', 'dev']
exclude:
# this results in lengthy and expensive numpy wheel builds
- python-version: '3.10'
Expand Down
10 changes: 5 additions & 5 deletions gravity/config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
import xml.etree.ElementTree as elementtree
from typing import Union

from pydantic import ValidationError
try:
from pydantic.v1 import ValidationError
except ImportError:
from pydantic import ValidationError
from yaml import safe_load

import gravity.io
from gravity.settings import Settings
from gravity.state import (
ConfigFile,
service_for_service_type,
)
from gravity.state import ConfigFile, service_for_service_type
from gravity.util import recursive_update

log = logging.getLogger(__name__)
Expand Down
14 changes: 6 additions & 8 deletions gravity/settings.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import os
from enum import Enum
from typing import (
Any,
Dict,
List,
Optional,
Union,
)
from pydantic import BaseModel, BaseSettings, Extra, Field, validator
from typing import Any, Dict, List, Optional, Union

try:
from pydantic.v1 import BaseModel, BaseSettings, Extra, Field, validator
except ImportError:
from pydantic import BaseModel, BaseSettings, Extra, Field, validator

DEFAULT_INSTANCE_NAME = "_default_"
GX_IT_PROXY_MIN_VERSION = "0.0.6"
Expand Down
13 changes: 6 additions & 7 deletions gravity/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,23 @@
state data.
"""
from __future__ import annotations

import enum
import hashlib
import os
import sys
import time
from typing import Any, Dict, List, Optional

from pydantic import BaseModel, validator
try:
from pydantic.v1 import BaseModel, validator
except ImportError:
from pydantic import BaseModel, validator

import gravity.io
from gravity.settings import (
AppServer,
ProcessManager,
ServiceCommandStyle,
)
from gravity.settings import AppServer, ProcessManager, ServiceCommandStyle
from gravity.util import http_check


DEFAULT_GALAXY_ENVIRONMENT = {
"PYTHONPATH": "lib",
"GALAXY_CONFIG_FILE": "{galaxy_conf}",
Expand Down
11 changes: 5 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import os
import re

from setuptools import setup, find_packages

from setuptools import find_packages, setup

with open("README.rst") as file:
long_description = file.read()
Expand Down Expand Up @@ -36,13 +35,13 @@ def get_var(var_name):
author_email="[email protected]",
license="MIT",
keywords="gravity galaxy",
python_requires=">=3.6",
python_requires=">=3.7",
install_requires=[
"Click",
"supervisor",
"pyyaml",
"packaging",
"pydantic<2",
"pydantic<3", # pydantic.v1 import will be removed in v3
"jsonref",
"requests",
"requests-unixsocket",
Expand All @@ -57,10 +56,10 @@ def get_var(var_name):
"Natural Language :: English",
"Operating System :: POSIX",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
],
zip_safe=False,
)
Loading