Skip to content

Commit

Permalink
Clean biapy package files and create binary for CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
danifranco committed Apr 28, 2024
1 parent 2a19d9d commit 3a0a035
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 106 deletions.
53 changes: 52 additions & 1 deletion biapy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,54 @@
__version__="3.2.0"
__version__="3.4.0"

import argparse
import os
import sys
from ._biapy import BiaPy


def main():

##########################
# ARGS COMPROBATION #
##########################

# Normal exec:
# python -u main.py \
# --config $input_job_cfg_file \
# --result_dir $result_dir \
# --name $job_name \
# --run_id $job_counter \
# --gpu 0
# Distributed:
# python -u -m torch.distributed.run \
# --nproc_per_node=2 \
# main.py \
# --config $input_job_cfg_file \
# --result_dir $result_dir \
# --name $job_name \
# --run_id $job_counter \
# --gpu 0,1

parser = argparse.ArgumentParser()
parser.add_argument("--config", required=True, help="Path to the configuration file")
parser.add_argument("--result_dir", help="Path to where the resulting output of the job will be stored",
default=os.getenv('HOME'))
parser.add_argument("--name", help="Job name", default="unknown_job")
parser.add_argument("--run_id", help="Run number of the same job", type=int, default=1)
parser.add_argument("--gpu", help="GPU number according to 'nvidia-smi' command", type=str)

# Distributed training parameters
parser.add_argument('--world_size', default=1, type=int,
help='number of distributed processes')
parser.add_argument('--local_rank', default=-1, type=int,
help='Node rank for distributed training. Necessary for using the torch.distributed.launch utility.')
parser.add_argument('--dist_on_itp', action='store_true')
parser.add_argument('--dist_url', default='env://',
help='url used to set up distributed training')
parser.add_argument('--dist_backend', type=str, default='nccl', choices=['nccl', 'gloo'],
help='Backend to use in distributed mode')
args = parser.parse_args()

_biapy = BiaPy(**vars(args))
_biapy.run_job()
sys.exit(0)
48 changes: 2 additions & 46 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,7 @@
import os
import sys

from biapy import BiaPy
from biapy import main

if __name__ == '__main__':

##########################
# ARGS COMPROBATION #
##########################

# Normal exec:
# python -u main.py \
# --config $input_job_cfg_file \
# --result_dir $result_dir \
# --name $job_name \
# --run_id $job_counter \
# --gpu 0
# Distributed:
# python -u -m torch.distributed.run \
# --nproc_per_node=2 \
# main.py \
# --config $input_job_cfg_file \
# --result_dir $result_dir \
# --name $job_name \
# --run_id $job_counter \
# --gpu 0,1

parser = argparse.ArgumentParser()
parser.add_argument("--config", required=True, help="Path to the configuration file")
parser.add_argument("--result_dir", help="Path to where the resulting output of the job will be stored",
default=os.getenv('HOME'))
parser.add_argument("--name", help="Job name", default="unknown_job")
parser.add_argument("--run_id", help="Run number of the same job", type=int, default=1)
parser.add_argument("--gpu", help="GPU number according to 'nvidia-smi' command", type=str)

# Distributed training parameters
parser.add_argument('--world_size', default=1, type=int,
help='number of distributed processes')
parser.add_argument('--local_rank', default=-1, type=int,
help='Node rank for distributed training. Necessary for using the torch.distributed.launch utility.')
parser.add_argument('--dist_on_itp', action='store_true')
parser.add_argument('--dist_url', default='env://',
help='url used to set up distributed training')
parser.add_argument('--dist_backend', type=str, default='nccl', choices=['nccl', 'gloo'],
help='Backend to use in distributed mode')
args = parser.parse_args()

_biapy = BiaPy(**vars(args))
_biapy.run_job()
sys.exit(0)
main()
22 changes: 16 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
[build-system]
requires = ["setuptools>=45", "wheel", "setuptools_scm>=6.2", "numpy>=1.24.3"]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "biapy"
version = "3.3.8"
version = "3.4.0"
description = "BiaPy: Bioimage analysis pipelines in Python"
readme = "README.md"
requires-python = ">=3.10"
authors = [{ name = "Daniel Franco-Barranco", email = "[email protected]" }]
license = { file = "LICENSE" }
maintainers = [{ name = "Daniel Franco-Barranco", email = "[email protected]" }]
license = { file = "LICENSE.md" }
classifiers = [
"License :: OSI Approved :: MIT License",
"Environment :: GPU :: NVIDIA CUDA :: 11.8",
Expand All @@ -34,11 +36,19 @@ dependencies = [
"bioimageio.core==0.5.9",
"imagecodecs>=2024.1.1",
"pytorch-msssim>=1.0.0",
"numpy>=1.26.4",
]
requires-python = ">=3.10"

[project.scripts]
spam-cli = "biapy:BiaPy"
biapy = "biapy:main"

[project.urls]
Homepage = "https://github.com/BiaPyX/BiaPy"
"Homepage" = "https://biapyx.github.io"
"Source" = "https://github.com/BiaPyX/BiaPy"
"Forum" = "https://forum.image.sc/tag/biapy"

[tool.setuptools]
include-package-data = true

[tool.setuptools.packages.find]
include = ['biapy*']
53 changes: 0 additions & 53 deletions setup.py

This file was deleted.

0 comments on commit 3a0a035

Please sign in to comment.