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

Convert module to a package directory with a py.typed file #102

Merged
merged 1 commit into from
Jun 11, 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
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ commit = True
message = [skip ci] Bump version: {current_version} → {new_version}
tag = False

[bumpversion:file:src/duct.py]
[bumpversion:file:src/duct/__init__.py]
7 changes: 5 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,18 @@ project_urls =
Bug Tracker = https://github.com/con/duct/issues

[options]
py_modules = duct
packages = find_namespace:
package_dir =
=src
include_package_data = True
python_requires = >= 3.8

[options.packages.find]
where = src

[options.entry_points]
console_scripts =
duct = duct:main
duct = duct.__main__:main

[mypy]
allow_incomplete_defs = False
Expand Down
1 change: 1 addition & 0 deletions src/duct/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.0.1"
2 changes: 1 addition & 1 deletion src/duct.py → src/duct/__main__.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import threading
import time
from typing import IO, Any, TextIO
from . import __version__

__version__ = "0.0.1"
ENV_PREFIXES = ("PBS_", "SLURM_", "OSG")


Expand Down
Empty file added src/duct/py.typed
Empty file.
2 changes: 1 addition & 1 deletion test/test_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from unittest import mock
import pytest
from utils import assert_files
from duct import Arguments, Outputs, RecordTypes, execute
from duct.__main__ import Arguments, Outputs, RecordTypes, execute

TEST_SCRIPT = str(Path(__file__).with_name("data") / "test_script.py")

Expand Down
8 changes: 4 additions & 4 deletions test/test_helpers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations
from unittest import mock
import pytest
from duct import ensure_directories
from duct.__main__ import ensure_directories


@pytest.mark.parametrize(
Expand All @@ -12,19 +12,19 @@
"/abs/path/",
],
)
@mock.patch("duct.os.makedirs")
@mock.patch("duct.__main__.os.makedirs")
def test_ensure_directories_with_dirs(mock_mkdir: mock.MagicMock, path: str) -> None:
ensure_directories(path)
mock_mkdir.assert_called_once_with(path, exist_ok=True)


@mock.patch("duct.os.makedirs")
@mock.patch("duct.__main__.os.makedirs")
def test_ensure_directories_with_file(mock_mkdir: mock.MagicMock) -> None:
ensure_directories("just_a_file_name")
mock_mkdir.assert_not_called()


@mock.patch("duct.os.makedirs")
@mock.patch("duct.__main__.os.makedirs")
def test_ensure_directories_with_filepart_and_directory_part(
mock_mkdir: mock.MagicMock,
) -> None:
Expand Down
8 changes: 4 additions & 4 deletions test/test_prepare_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
import subprocess
from unittest.mock import MagicMock, call, patch
from utils import MockStream
from duct import Outputs, prepare_outputs
from duct.__main__ import Outputs, prepare_outputs


@patch("sys.stdout", new_callable=MockStream)
def test_prepare_outputs_all_stdout(mock_stdout: MockStream) -> None:
output_prefix = "test_outputs_"
with patch("duct.TailPipe") as mock_tee_stream, patch(
with patch("duct.__main__.TailPipe") as mock_tee_stream, patch(
"builtins.open", new_callable=MagicMock
) as mock_open:
mock_tee_stream.return_value.start = MagicMock()
Expand All @@ -23,7 +23,7 @@ def test_prepare_outputs_all_stdout(mock_stdout: MockStream) -> None:
@patch("sys.stderr", new_callable=MockStream)
def test_prepare_outputs_all_stderr(mock_stderr: MockStream) -> None:
output_prefix = "test_outputs_"
with patch("duct.TailPipe") as mock_tee_stream, patch(
with patch("duct.__main__.TailPipe") as mock_tee_stream, patch(
"builtins.open", new_callable=MagicMock
) as mock_open:
mock_tee_stream.return_value.start = MagicMock()
Expand Down Expand Up @@ -68,7 +68,7 @@ def test_prepare_outputs_all_all(
mock_stdout: MockStream, mock_stderr: MockStream
) -> None:
output_prefix = "test_outputs_"
with patch("duct.TailPipe") as mock_tee_stream:
with patch("duct.__main__.TailPipe") as mock_tee_stream:
mock_tee_stream.return_value.start = MagicMock()
stdout, stderr = prepare_outputs(Outputs.ALL, Outputs.ALL, output_prefix)
assert stdout == mock_tee_stream.return_value
Expand Down
2 changes: 1 addition & 1 deletion test/test_report.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from __future__ import annotations
from duct import ProcessStats, Sample
from duct.__main__ import ProcessStats, Sample

stat0 = ProcessStats(
pcpu=0.0, pmem=0, rss=0, vsz=0, timestamp="2024-06-11T10:09:37-04:00"
Expand Down
2 changes: 1 addition & 1 deletion test/test_tailpipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from unittest.mock import patch
import pytest
from utils import MockStream
from duct import TailPipe
from duct.__main__ import TailPipe

# 10^7 line fixture is about 70MB
FIXTURE_LIST = [f"ten_{i}" for i in range(1, 8)]
Expand Down
Loading