From 870f424a17f348ea2da8b849f29a4bd33e715a97 Mon Sep 17 00:00:00 2001 From: AndreFCruz Date: Wed, 12 Jun 2024 16:03:36 +0200 Subject: [PATCH] fixing pyproject.toml for multiple src directory levels --- MANIFEST.in | 1 + folktexts/cli/launch_acs_benchmarks.py | 23 +++++++++++++++++------ folktexts/cli/run_acs_benchmark.py | 6 +++++- pyproject.toml | 15 ++++++++++----- 4 files changed, 33 insertions(+), 12 deletions(-) create mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..a2aeea1 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +include folktexts/acs/data/*.txt \ No newline at end of file diff --git a/folktexts/cli/launch_acs_benchmarks.py b/folktexts/cli/launch_acs_benchmarks.py index a68e859..3c96865 100755 --- a/folktexts/cli/launch_acs_benchmarks.py +++ b/folktexts/cli/launch_acs_benchmarks.py @@ -31,8 +31,7 @@ ACS_DATA_DIR = ROOT_DIR / "data" # Directory to save results in (make sure it exists) -RESULTS_DIR = ROOT_DIR / "folktexts-results" / "acs-benchmarks" -RESULTS_DIR.mkdir(exist_ok=True, parents=False) +RESULTS_ROOT_DIR = ROOT_DIR / "folktexts-results" / "acs-benchmarks" # Models save directory MODELS_DIR = ROOT_DIR / "huggingface-models" @@ -84,6 +83,7 @@ def make_llm_as_clf_experiment( model_name: str, task_name: str, + results_root_dir: str = RESULTS_ROOT_DIR, **kwargs, ) -> Experiment: """Create an experiment object to run. @@ -125,8 +125,8 @@ def make_llm_as_clf_experiment( ) # Create LLM results directory - exp_results_dir = RESULTS_DIR / get_llm_results_folder(exp) - exp_results_dir.mkdir(exist_ok=True, parents=False) + exp_results_dir = results_root_dir / get_llm_results_folder(exp) + exp_results_dir.mkdir(exist_ok=True, parents=True) exp.kwargs["results_dir"] = exp_results_dir.as_posix() save_json( obj=exp.to_dict(), @@ -166,6 +166,14 @@ def setup_arg_parser() -> argparse.ArgumentParser: action="append", ) + parser.add_argument( + "--results-root-dir", + type=str, + help="[string] Directory under which results will be saved.", + required=False, + default=RESULTS_ROOT_DIR.as_posix(), + ) + parser.add_argument( "--dry-run", action="store_true", @@ -183,8 +191,7 @@ def setup_arg_parser() -> argparse.ArgumentParser: return parser -if __name__ == '__main__': - +def main(): # Parse command-line arguments parser = setup_arg_parser() args, extra_kwargs = parser.parse_known_args() @@ -218,3 +225,7 @@ def setup_arg_parser() -> argparse.ArgumentParser: cluster_id = launch_experiment_job(exp).cluster() if not args.dry_run else None print(f"{i:2}. cluster-id={cluster_id}") pprint(exp.to_dict(), indent=4) + + +if __name__ == "__main__": + main() diff --git a/folktexts/cli/run_acs_benchmark.py b/folktexts/cli/run_acs_benchmark.py index 950b33f..f4a9a61 100755 --- a/folktexts/cli/run_acs_benchmark.py +++ b/folktexts/cli/run_acs_benchmark.py @@ -100,7 +100,7 @@ def setup_arg_parser() -> ArgumentParser: return parser -if __name__ == '__main__': +def main(): """Prepare and launch the LLM-as-classifier experiment using ACS data.""" # Setup parser and process cmd-line args @@ -163,3 +163,7 @@ def setup_arg_parser() -> ArgumentParser: # Finish from folktexts._utils import get_current_timestamp print(f"\nFinished experiment successfully at {get_current_timestamp()}\n") + + +if __name__ == "__main__": + main() diff --git a/pyproject.toml b/pyproject.toml index 77be7c7..3b98d4c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools"] +requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta" [project] @@ -32,7 +32,7 @@ classifiers = [ "Programming Language :: Python :: 3.12", ] -version = "0.0.7" +version = "0.0.8" requires-python = ">=3.8" dynamic = [ "readme", @@ -40,6 +40,11 @@ dynamic = [ "optional-dependencies", ] # these are defined below dynamically +[tool.setuptools] +# NOTE! If you have multiple source directories, you can specify them here: +packages = ["folktexts", "folktexts.acs", "folktexts.cli"] +include-package-data = true + [tool.setuptools.dynamic] readme = { file = "README.md", content-type="text/markdown" } @@ -53,11 +58,11 @@ optional-dependencies.cli = {file = "requirements/cli.txt"} [project.urls] homepage = "https://github.com/socialfoundations/folktexts" -documentation = "https://socialfoundations.github.io/folktexts/" repository = "https://github.com/socialfoundations/folktexts" +documentation = "https://socialfoundations.github.io/folktexts/" -[tool.setuptools.packages.find] -include = ["folktexts"] +[project.scripts] +run_acs_benchmark = "folktexts.cli.run_acs_benchmark:main" # flake8 [tool.flake8]