Skip to content

Commit c1589ba

Browse files
committed
Fixed API exposed by package
1 parent 5798ac5 commit c1589ba

File tree

4 files changed

+56
-47
lines changed

4 files changed

+56
-47
lines changed

pyproject.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ dependencies = [
3333
"multivolumefile",
3434
"opencv-python",
3535
"pillow",
36-
"pip",
3736
"psutil",
3837
"pyarrow",
3938
"pyyaml",
@@ -44,7 +43,6 @@ dependencies = [
4443
"python-dotenv",
4544
"pyzstd",
4645
"requests",
47-
"setuptools",
4846
"texttable",
4947
"typing-extensions",
5048
"wheel"
Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,5 @@
1-
from logging import Logger
2-
from typing import Optional
1+
from .core import download_images
2+
from .tools import apply_tools
33

4-
from distributed_downloader.core.main import DistributedDownloader
5-
from distributed_downloader.tools.main import Tools
64

7-
8-
def download_images(config_path: str, logger: Optional[Logger] = None) -> None:
9-
"""
10-
Initiates the download of images based on a given configuration.
11-
12-
This function creates an instance of `DistributedDownloader` using a configuration file path,
13-
optionally sets a logger for the downloader, and then starts the image downloading process.
14-
15-
Parameters:
16-
- config_path (str): The file path to the configuration file required to initialize the downloader.
17-
- logger (Logger, optional): An instance of a logger to be used by the downloader. Defaults to None.
18-
19-
Returns:
20-
- None
21-
"""
22-
dd = DistributedDownloader.from_path(config_path)
23-
if logger is not None:
24-
dd.logger = logger
25-
dd.download_images()
26-
27-
28-
def apply_tools(config_path: str, tool_name: str, logger: Optional[Logger] = None) -> None:
29-
"""
30-
Applies a tool to the images downloaded by the DistributedDownloader.
31-
32-
This function creates an instance of `DistributedDownloader` using a configuration file path,
33-
optionally sets a logger for the downloader, and then applies the specified tool to the downloaded images.
34-
35-
Parameters:
36-
- config_path (str): The file path to the configuration file required to initialize the downloader.
37-
- tool_name (str): The name of the tool to be applied to the downloaded images.
38-
- logger (Logger, optional): An instance of a logger to be used by the downloader. Defaults to None.
39-
40-
Returns:
41-
- None
42-
"""
43-
dd_tools = Tools.from_path(config_path, tool_name)
44-
if logger is not None:
45-
dd_tools.logger = logger
46-
dd_tools.apply_tool()
5+
__all__ = ["download_images", "apply_tools"]
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from logging import Logger
2+
from typing import Optional
3+
4+
from .main import DistributedDownloader
5+
6+
7+
def download_images(config_path: str, logger: Optional[Logger] = None) -> None:
8+
"""
9+
Initiates the download of images based on a given configuration.
10+
11+
This function creates an instance of `DistributedDownloader` using a configuration file path,
12+
optionally sets a logger for the downloader, and then starts the image downloading process.
13+
14+
Parameters:
15+
- config_path (str): The file path to the configuration file required to initialize the downloader.
16+
- logger (Logger, optional): An instance of a logger to be used by the downloader. Defaults to None.
17+
18+
Returns:
19+
- None
20+
"""
21+
dd = DistributedDownloader.from_path(config_path)
22+
if logger is not None:
23+
dd.logger = logger
24+
dd.download_images()
Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,29 @@
1-
import distributed_downloader.tools.schedulers
1+
from logging import Logger
2+
from typing import Optional
3+
4+
from .config import Config
5+
from .checkpoint import Checkpoint
6+
from .registry import ToolsRegistryBase
7+
from .main import Tools
8+
from .utils import load_dataframe, ensure_created, truncate_paths, get_id, init_logger, submit_job, preprocess_dep_ids
9+
10+
11+
def apply_tools(config_path: str, tool_name: str, logger: Optional[Logger] = None) -> None:
12+
"""
13+
Applies a tool to the images downloaded by the DistributedDownloader.
14+
15+
This function creates an instance of `DistributedDownloader` using a configuration file path,
16+
optionally sets a logger for the downloader, and then applies the specified tool to the downloaded images.
17+
18+
Parameters:
19+
- config_path (str): The file path to the configuration file required to initialize the downloader.
20+
- tool_name (str): The name of the tool to be applied to the downloaded images.
21+
- logger (Logger, optional): An instance of a logger to be used by the downloader. Defaults to None.
22+
23+
Returns:
24+
- None
25+
"""
26+
dd_tools = Tools.from_path(config_path, tool_name)
27+
if logger is not None:
28+
dd_tools.logger = logger
29+
dd_tools.apply_tool()

0 commit comments

Comments
 (0)