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

lint core #3339

Merged
merged 1 commit into from
Jun 21, 2023
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
1 change: 1 addition & 0 deletions .github/workflow_scripts/lint_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function lint_check_all {
lint_check multimodal 119
lint_check timeseries 119
lint_check common 160
lint_check core 160
}

bandit -r multimodal/src -ll
Expand Down
85 changes: 44 additions & 41 deletions core/setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/usr/bin/env python
###########################
# This code block is a HACK (!), but is necessary to avoid code duplication. Do NOT alter these lines.
import importlib.util
import os

from setuptools import setup
import importlib.util

filepath = os.path.abspath(os.path.dirname(__file__))
filepath_import = os.path.join(filepath, '..', 'core', 'src', 'autogluon', 'core', '_setup_utils.py')
filepath_import = os.path.join(filepath, "..", "core", "src", "autogluon", "core", "_setup_utils.py")
spec = importlib.util.spec_from_file_location("ag_min_dependencies", filepath_import)
ag = importlib.util.module_from_spec(spec)
# Identical to `from autogluon.core import _setup_utils as ag`, but works without `autogluon.core` being installed.
Expand All @@ -15,65 +17,66 @@
version = ag.load_version_file()
version = ag.update_version(version)

submodule = 'core'
install_requires = [
# version ranges added in ag.get_dependency_version_ranges()
'numpy',
'scipy',
'scikit-learn',
'networkx',
'pandas',
'tqdm',

'requests',
'matplotlib',
'boto3',

f'autogluon.common=={version}',
] if not ag.LITE_MODE else [
# version ranges added in ag.get_dependency_version_ranges()
'numpy',
'scipy',
'scikit-learn',
'pandas',
'tqdm',
'matplotlib',

f'{ag.PACKAGE_NAME}.common=={version}',
]
submodule = "core"
install_requires = (
[
# version ranges added in ag.get_dependency_version_ranges()
"numpy",
"scipy",
"scikit-learn",
"networkx",
"pandas",
"tqdm",
"requests",
"matplotlib",
"boto3",
f"autogluon.common=={version}",
]
if not ag.LITE_MODE
else [
# version ranges added in ag.get_dependency_version_ranges()
"numpy",
"scipy",
"scikit-learn",
"pandas",
"tqdm",
"matplotlib",
f"{ag.PACKAGE_NAME}.common=={version}",
]
)

extras_require = {
'ray': [
"ray": [
"ray[default]>=2.3,<2.4",
],
'raytune': [
'ray[tune]>=2.3,<2.4',
"raytune": [
"ray[tune]>=2.3,<2.4",
# TODO: consider alternatives as hyperopt is not actively maintained.
'hyperopt>=0.2.7,<0.2.8', # This is needed for the bayes search to work.
"hyperopt>=0.2.7,<0.2.8", # This is needed for the bayes search to work.
# 'GPy>=1.10.0,<1.11.0' # TODO: Enable this once PBT/PB2 are supported by ray lightning
]
],
}

tests_require = [
'pytest',
'types-requests',
'types-setuptools',
'pytest-mypy',
"pytest",
"types-requests",
"types-setuptools",
"pytest-mypy",
# TODO(Re-enable ray_lightning once it released 0.3.0) 'ray_lightning>=0.2.0,<0.3.0'
]

all_requires = []

for extra_package in ['ray', 'raytune']:
for extra_package in ["ray", "raytune"]:
all_requires += extras_require[extra_package]
tests_require = list(set(tests_require))
all_requires = list(set(all_requires))
extras_require['tests'] = tests_require
extras_require['all'] = all_requires
extras_require["tests"] = tests_require
extras_require["all"] = all_requires

install_requires = ag.get_dependency_version_ranges(install_requires)

if __name__ == '__main__':
if __name__ == "__main__":
ag.create_version_file(version=version, submodule=submodule)
setup_args = ag.default_setup_args(version=version, submodule=submodule)
setup(
Expand Down
11 changes: 5 additions & 6 deletions core/src/autogluon/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
from typing import Any
import warnings
from typing import Any

from autogluon.common.utils.log_utils import _add_stream_handler

from . import constants, metrics
from .dataset import TabularDataset
from . import metrics
from . import constants
from .space import Space, Categorical, Real, Int, Bool, spaces
from .space import Bool, Categorical, Int, Real, Space, spaces
from .version import __version__


import warnings

# TODO: Remove deprecation warning for v1.0
class DeprecatedSpacesWrapper:
def __getattr__(self, attr: str) -> Any:
Expand Down
98 changes: 48 additions & 50 deletions core/src/autogluon/core/_setup_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,43 @@

import os

AUTOGLUON = 'autogluon'
PACKAGE_NAME = os.getenv('AUTOGLUON_PACKAGE_NAME', AUTOGLUON)
AUTOGLUON = "autogluon"
PACKAGE_NAME = os.getenv("AUTOGLUON_PACKAGE_NAME", AUTOGLUON)
# TODO: make it more explicit, maybe use another env variable
LITE_MODE = 'lite' in PACKAGE_NAME
LITE_MODE = "lite" in PACKAGE_NAME

AUTOGLUON_ROOT_PATH = os.path.abspath(
os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..', '..', '..')
)
AUTOGLUON_ROOT_PATH = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "..", ".."))

PYTHON_REQUIRES = '>=3.8, <3.11'
PYTHON_REQUIRES = ">=3.8, <3.11"


# Only put packages here that would otherwise appear multiple times across different module's setup.py files.
DEPENDENT_PACKAGES = {
# note: if python 3.7 is used, the open CVEs are present: CVE-2021-41496 | CVE-2021-34141; fixes are available in 1.22.x, but python 3.8 only
'boto3': '>=1.10,<2', # <2 because unlikely to introduce breaking changes in minor releases. >=1.10 because 1.10 is 3 years old, no need to support older
'numpy': '>=1.21,<1.27', # "<{N+3}" upper cap, where N is the latest released minor version, assuming no warnings using N
'pandas': '>=1.4.1,<1.6', # "<{N+1}" upper cap
'scikit-learn': '>=1.0,<1.3', # "<{N+1}" upper cap
'scipy': '>=1.5.4,<1.12', # "<{N+2}" upper cap
'psutil': '>=5.7.3,<6', # Major version cap
'networkx': '>=3.0,<4', # Major version cap
'tqdm': '>=4.38,<5', # Major version cap
'Pillow': '>=9.3,<9.6', # "<{N+2}" upper cap
"boto3": ">=1.10,<2", # <2 because unlikely to introduce breaking changes in minor releases. >=1.10 because 1.10 is 3 years old, no need to support older
"numpy": ">=1.21,<1.27", # "<{N+3}" upper cap, where N is the latest released minor version, assuming no warnings using N
"pandas": ">=1.4.1,<1.6", # "<{N+1}" upper cap
"scikit-learn": ">=1.0,<1.3", # "<{N+1}" upper cap
"scipy": ">=1.5.4,<1.12", # "<{N+2}" upper cap
"psutil": ">=5.7.3,<6", # Major version cap
"networkx": ">=3.0,<4", # Major version cap
"tqdm": ">=4.38,<5", # Major version cap
"Pillow": ">=9.3,<9.6", # "<{N+2}" upper cap
}
if LITE_MODE:
DEPENDENT_PACKAGES = {
package: version for package, version in DEPENDENT_PACKAGES.items()
if package not in ['psutil', 'Pillow', 'timm']
}
DEPENDENT_PACKAGES = {package: version for package, version in DEPENDENT_PACKAGES.items() if package not in ["psutil", "Pillow", "timm"]}

DEPENDENT_PACKAGES = {package: package + version for package, version in DEPENDENT_PACKAGES.items()}
# TODO: Use DOCS_PACKAGES and TEST_PACKAGES
DOCS_PACKAGES = []
TEST_PACKAGES = [
'flake8',
'pytest',
"flake8",
"pytest",
]


def load_version_file():
with open(os.path.join(AUTOGLUON_ROOT_PATH, 'VERSION')) as version_file:
with open(os.path.join(AUTOGLUON_ROOT_PATH, "VERSION")) as version_file:
version = version_file.read().strip()
return version

Expand All @@ -61,9 +56,10 @@ def update_version(version, use_file_if_exists=True, create_file=False):
You need to increase the version number after stable release, so that the nightly pypi can work properly.
"""
try:
if not os.getenv('RELEASE'):
if not os.getenv("RELEASE"):
from datetime import date
minor_version_file_path = os.path.join(AUTOGLUON_ROOT_PATH, 'VERSION.minor')

minor_version_file_path = os.path.join(AUTOGLUON_ROOT_PATH, "VERSION.minor")
if use_file_if_exists and os.path.isfile(minor_version_file_path):
with open(minor_version_file_path) as f:
day = f.read().strip()
Expand All @@ -73,52 +69,54 @@ def update_version(version, use_file_if_exists=True, create_file=False):
version += day
except Exception:
pass
if create_file and not os.getenv('RELEASE'):
with open(os.path.join(AUTOGLUON_ROOT_PATH, 'VERSION.minor'), 'w') as f:
if create_file and not os.getenv("RELEASE"):
with open(os.path.join(AUTOGLUON_ROOT_PATH, "VERSION.minor"), "w") as f:
f.write(day)
return version


def create_version_file(*, version, submodule):
print('-- Building version ' + version)
print("-- Building version " + version)
if submodule is not None:
version_path = os.path.join(AUTOGLUON_ROOT_PATH, submodule, 'src', AUTOGLUON, submodule, 'version.py')
version_path = os.path.join(AUTOGLUON_ROOT_PATH, submodule, "src", AUTOGLUON, submodule, "version.py")
else:
version_path = os.path.join(AUTOGLUON_ROOT_PATH, AUTOGLUON, 'src', AUTOGLUON, 'version.py')
with open(version_path, 'w') as f:
version_path = os.path.join(AUTOGLUON_ROOT_PATH, AUTOGLUON, "src", AUTOGLUON, "version.py")
with open(version_path, "w") as f:
f.write(f'"""This is the {AUTOGLUON} version file."""\n')
f.write("__version__ = '{}'\n".format(version))
f.write("__lite__ = {}\n".format(LITE_MODE))


def default_setup_args(*, version, submodule):
from setuptools import find_namespace_packages
long_description = open(os.path.join(AUTOGLUON_ROOT_PATH, 'README.md')).read()

long_description = open(os.path.join(AUTOGLUON_ROOT_PATH, "README.md")).read()
if submodule is None:
name = PACKAGE_NAME
else:
name = f'{PACKAGE_NAME}.{submodule}'
name = f"{PACKAGE_NAME}.{submodule}"
setup_args = dict(
name=name,
version=version,
author='AutoGluon Community',
url='https://github.com/autogluon/autogluon',
description='AutoML for Image, Text, and Tabular Data',
author="AutoGluon Community",
url="https://github.com/autogluon/autogluon",
description="AutoML for Image, Text, and Tabular Data",
long_description=long_description,
long_description_content_type='text/markdown',
license='Apache-2.0',
license_files=('../LICENSE', '../NOTICE'),

long_description_content_type="text/markdown",
license="Apache-2.0",
license_files=("../LICENSE", "../NOTICE"),
# Package info
packages=find_namespace_packages('src', include=['autogluon.*']),
package_dir={'': 'src'},
packages=find_namespace_packages("src", include=["autogluon.*"]),
package_dir={"": "src"},
namespace_packages=[AUTOGLUON],
zip_safe=True,
include_package_data=True,
python_requires=PYTHON_REQUIRES,
package_data={AUTOGLUON: [
'LICENSE',
]},
package_data={
AUTOGLUON: [
"LICENSE",
]
},
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Education",
Expand All @@ -133,7 +131,7 @@ def default_setup_args(*, version, submodule):
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX",
"Operating System :: Unix",
'Programming Language :: Python :: 3',
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand All @@ -143,10 +141,10 @@ def default_setup_args(*, version, submodule):
"Topic :: Scientific/Engineering :: Image Recognition",
],
project_urls={
'Documentation': 'https://auto.gluon.ai',
'Bug Reports': 'https://github.com/autogluon/autogluon/issues',
'Source': 'https://github.com/autogluon/autogluon/',
'Contribute!': 'https://github.com/autogluon/autogluon/blob/master/CONTRIBUTING.md',
"Documentation": "https://auto.gluon.ai",
"Bug Reports": "https://github.com/autogluon/autogluon/issues",
"Source": "https://github.com/autogluon/autogluon/",
"Contribute!": "https://github.com/autogluon/autogluon/blob/master/CONTRIBUTING.md",
},
)
return setup_args
Loading
Loading