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

Cleaning setup #890

Merged
merged 4 commits into from
Jul 1, 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
3 changes: 2 additions & 1 deletion GANDLF/data/augmentation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,12 @@ def get_augmentation_transforms(

if augmentation_type_lower in global_augs_dict:
current_augmentations.append(
global_augs_dict[augmentation_type_lower](**augmentation_params)
global_augs_dict[augmentation_type_lower](augmentation_params)
)
else:
warn(
f"Augmentation {augmentation_type} not found in the global augmentation dictionary.",
UserWarning,
)

return current_augmentations
49 changes: 5 additions & 44 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@

import sys, re, os
from setuptools import setup, find_packages
from setuptools.command.install import install
from setuptools.command.develop import develop
from setuptools.command.egg_info import egg_info

try:
with open("README.md") as readme_file:
Expand All @@ -17,21 +14,6 @@
sys.stderr.write("Warning: Could not open '%s' due %s\n" % ("README.md", error))


class CustomInstallCommand(install):
def run(self):
install.run(self)


class CustomDevelopCommand(develop):
def run(self):
develop.run(self)


class CustomEggInfoCommand(egg_info):
def run(self):
egg_info.run(self)


Comment on lines -20 to -34
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These commands are just not used (I mean, they does not differ from default ones)

try:
filepath = "GANDLF/version.py"
version_file = open(filepath)
Expand All @@ -47,26 +29,10 @@ def run(self):
for item in os.listdir(os.path.dirname(os.path.abspath(__file__)))
if (os.path.isfile(item) and item.startswith("Dockerfile-"))
]
setup_files = ["setup.py", ".dockerignore", "pyproject.toml", "MANIFEST.in"]
all_extra_files = dockerfiles + setup_files
all_extra_files_pathcorrected = [os.path.join("../", item) for item in all_extra_files]
Comment on lines -50 to -52
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After installement, user receives this files directly in site-packages/ folder. The reason is using ../ in the path; however, that is caused by the fact these files are located in repo root.

Good practice for building a wheel by setup.py (and, actually, the only possible one) is not to add these files to the wheel. Only files that are required for module should be added. Moreover, any file that should be added to user's site-packages/GANDLF module should be located in module source library also (./GANDLF/ in our case, not in a repo root).

So, there are two options:
(1) move necessary files to ./GANDLF/ module source folder;
(2) just don't include them to the wheel at all.

I chose the second solution.

# find_packages should only ever find these as subpackages of gandlf, not as top-level packages
# generate this dynamically?
# GANDLF.GANDLF is needed to prevent recursion madness in deployments
toplevel_package_excludes = [
"GANDLF.GANDLF",
"anonymize",
"cli",
"compute",
"data",
"grad_clipping",
"losses",
"metrics",
"models",
"optimizers",
"schedulers",
"utils",
]

# Any extra files should be located at `GANDLF` module folder (not in repo root)
extra_files = []
toplevel_package_excludes = ["testing*"]

# specifying version for `black` separately because it is also used to [check for lint](https://github.com/mlcommons/GaNDLF/blob/master/.github/workflows/black.yml)
black_version = "23.11.0"
Expand Down Expand Up @@ -127,11 +93,6 @@ def run(self):
where=os.path.dirname(os.path.abspath(__file__)),
exclude=toplevel_package_excludes,
),
cmdclass={
"install": CustomInstallCommand,
"develop": CustomDevelopCommand,
"egg_info": CustomEggInfoCommand,
},
entry_points={
"console_scripts": [
"gandlf=GANDLF.entrypoints.cli_tool:gandlf",
Expand Down Expand Up @@ -171,7 +132,7 @@ def run(self):
long_description=readme,
long_description_content_type="text/markdown",
include_package_data=True,
package_data={"GANDLF": all_extra_files_pathcorrected},
package_data={"GANDLF": extra_files},
keywords="semantic, segmentation, regression, classification, data-augmentation, medical-imaging, clinical-workflows, deep-learning, pytorch",
zip_safe=False,
)
Loading