Repository: OptimalFoundation/nadir (language: python)

Issue:
pip install and import have an error
![image](https://user-images.githubusercontent.com/11348086/221343705-c474db98-aec2-4335-a246-75bd856bf2dd.png)


### Note for the future

We need to conduct better testing before we publish a release
pip install and import have an error
![image](https://user-images.githubusercontent.com/11348086/221343705-c474db98-aec2-4335-a246-75bd856bf2dd.png)


### Note for the future

We need to conduct better testing before we publish a release


Discussion / hints:

Fix patch:
diff --git a/.gitignore b/.gitignore
index f15cdc7..5f66781 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,4 +9,6 @@ data/*
 dist
 dist/*
 
+src/nadir.egg-info/*
+
 nadir.egg-info/*
\ No newline at end of file
diff --git a/README.md b/README.md
index 600badf..1045a86 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,10 @@
 # Nadir
 
+![PyPI - Downloads](https://img.shields.io/pypi/dm/nadir)
+![GitHub commit activity](https://img.shields.io/github/commit-activity/m/Dawn-Of-Eve/nadir)
+![GitHub Repo stars](https://img.shields.io/github/stars/Dawn-Of-Eve/nadir?style=social)
+![Twitter Follow](https://img.shields.io/twitter/follow/dawnofevehq?style=social)
+
 **Nadir** (pronounced _nay-di-ah_) is derived from the arabic word _nazir_, and means "the lowest point of a space". In optimisation problems, it is equivalent to the point of minimum. If you are a machine learning enthusiast, a data scientist or an AI practitioner, you know how important it is to use the best optimization algorithms to train your models. The purpose of this library is to help optimize machine learning models and enable them to reach the point of nadir in the appropriate context.
 
 PyTorch is a popular machine learning framework that provides a flexible and efficient way of building and training deep neural networks. This library, Nadir, is built on top of PyTorch to provide high-performing general-purpose optimisation algorithms.  
@@ -24,8 +29,13 @@ $ pip install nadir
 
 ## Usage
 
-```
+```python
 import nadir as nd
+
+# some model setup here...
+model = ...
+
+# set up your Nadir optimiser
 config = nd.SGDConfig(lr=learning_rate)
 optimizer = nd.SGD(model.parameters(), config)
 
diff --git a/assets/dawn_of_eve.png b/assets/dawn_of_eve.png
deleted file mode 100644
index b97a52b..0000000
Binary files a/assets/dawn_of_eve.png and /dev/null differ
diff --git a/assets/dawn_of_eve2.png b/assets/dawn_of_eve2.png
deleted file mode 100644
index 414c43d..0000000
Binary files a/assets/dawn_of_eve2.png and /dev/null differ
diff --git a/examples/example.ipynb b/examples/example.ipynb
index aa842a1..84f457c 100644
--- a/examples/example.ipynb
+++ b/examples/example.ipynb
@@ -2,9 +2,21 @@
  "cells": [
   {
    "cell_type": "code",
-   "execution_count": null,
+   "execution_count": 1,
    "metadata": {},
-   "outputs": [],
+   "outputs": [
+    {
+     "ename": "ModuleNotFoundError",
+     "evalue": "No module named 'torch'",
+     "output_type": "error",
+     "traceback": [
+      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
+      "\u001b[0;31mModuleNotFoundError\u001b[0m                       Traceback (most recent call last)",
+      "\u001b[1;32m/home/ec3dev/personal/github/nadir/examples/example.ipynb Cell 1\u001b[0m in \u001b[0;36m<cell line: 1>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> <a href='vscode-notebook-cell:/home/ec3dev/personal/github/nadir/examples/example.ipynb#W0sZmlsZQ%3D%3D?line=0'>1</a>\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mtorch\u001b[39;00m\n\u001b[1;32m      <a href='vscode-notebook-cell:/home/ec3dev/personal/github/nadir/examples/example.ipynb#W0sZmlsZQ%3D%3D?line=1'>2</a>\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39margparse\u001b[39;00m\n\u001b[1;32m      <a href='vscode-notebook-cell:/home/ec3dev/personal/github/nadir/examples/example.ipynb#W0sZmlsZQ%3D%3D?line=2'>3</a>\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mwandb\u001b[39;00m\n",
+      "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'torch'"
+     ]
+    }
+   ],
    "source": [
     "import torch\n",
     "import argparse\n",
@@ -126,7 +138,7 @@
  ],
  "metadata": {
   "kernelspec": {
-   "display_name": "dawn-of-eve",
+   "display_name": "Python 3",
    "language": "python",
    "name": "python3"
   },
@@ -140,12 +152,12 @@
    "name": "python",
    "nbconvert_exporter": "python",
    "pygments_lexer": "ipython3",
-   "version": "3.9.15"
+   "version": "3.8.10"
   },
   "orig_nbformat": 4,
   "vscode": {
    "interpreter": {
-    "hash": "c88e393621c53c0ff30a461fc3b3671d9e8061725bb4d4a0a2412852c522bd7c"
+    "hash": "916dbcbb3f70747c44a77c7bcd40155683ae19c65e1c03b4aa3499c5328201f1"
    }
   }
  },
diff --git a/pyproject.toml b/pyproject.toml
index 0459cc3..6851d7a 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,10 @@
+[build-system]
+requires = ["setuptools>=61.0"]
+build-backend = "setuptools.build_meta"
+
 [project]
 name = "nadir"
-version = "0.0.1"
+version = "0.0.1.dev1"
 authors = [
   { name="Bhavnick Minhas", email="bhavnicksm@gmail.com" },
 ]
@@ -16,11 +20,19 @@ classifiers = [
     "Operating System :: OS Independent",
     "Topic :: Scientific/Engineering :: Artificial Intelligence"
 ]
+license = { text = "Apache 2.0"}
+dependencies = [
+    "torch>=1.13.1",
+    "torchvision>=0.14.1",
+    "tqdm",
+    "wandb"
+]
 
 [project.urls]
 "Homepage" = "https://github.com/Dawn-Of-Eve/nadir"
 "Bug Tracker" = "https://github.com/Dawn-Of-Eve/nadir/issues"
 
-[build-system]
-requires = ["setuptools>=61.0"]
-build-backend = "setuptools.build_meta"
+
+[tools.setuptools]
+packages = ["nadir"]
+package-dir = {"" = "src"}
\ No newline at end of file
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..d15bba2
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,34 @@
+[metadata]
+name = nadir
+version = attr: nadir.__version__
+description = Nadir is a library of bleeding-edge optimisers built for speed and functionality in PyTorch for researchers
+long_description = file: README.md 
+keywords = 
+    machine learning
+    optimization
+    adam-optimizer
+license = Apache-2.0 License
+classifiers =
+    Programming Language :: Python :: 3
+    License :: OSI Approved :: Apache Software License
+    Operating System :: OS Independent
+    Topic :: Scientific/Engineering :: Artificial Intelligence
+
+[options]
+package_dir=
+    =src
+packages=find:
+python_requires = >=3.7
+install_requires =
+    torch == 1.13.1
+    torchvision == 0.14.1
+    tqdm == 4.64.1
+    wandb == 0.13.9
+
+[options.packages.find]
+where=src
+exclude =
+    examples*
+    tools*
+    docs*
+    tests*
\ No newline at end of file
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..fc1f76c
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,3 @@
+from setuptools import setup
+
+setup()
\ No newline at end of file
diff --git a/nadir/BaseOptimiser.py b/src/nadir/BaseOptimiser.py
similarity index 94%
rename from nadir/BaseOptimiser.py
rename to src/nadir/BaseOptimiser.py
index 4944de3..e18b524 100644
--- a/nadir/BaseOptimiser.py
+++ b/src/nadir/BaseOptimiser.py
@@ -22,7 +22,6 @@ class BaseConfig():
     pass
 
 
-
 class BaseOptimizer(Optimizer):
     def __init__(
         self, 
@@ -34,9 +33,4 @@ def __init__(
     ):
         defaults = config.__dict__
 
-        super().__init__(params, defaults)
-    
-    
-
-
-
+        super().__init__(params, defaults)
\ No newline at end of file
diff --git a/nadir/SGD.py b/src/nadir/SGD.py
similarity index 99%
rename from nadir/SGD.py
rename to src/nadir/SGD.py
index ab62095..a9b7812 100644
--- a/nadir/SGD.py
+++ b/src/nadir/SGD.py
@@ -12,7 +12,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-
 import torch
 from dataclasses import dataclass
 
diff --git a/nadir/__init__.py b/src/nadir/__init__.py
similarity index 90%
rename from nadir/__init__.py
rename to src/nadir/__init__.py
index 2f061cd..18aadc4 100644
--- a/nadir/__init__.py
+++ b/src/nadir/__init__.py
@@ -12,14 +12,13 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-
 from typing import Dict, List, Type
 from torch.optim.optimizer import Optimizer
-from .BaseOptimiser import BaseOptimizer, DoEConfig
+from .BaseOptimiser import BaseOptimizer, BaseConfig
 
 from .SGD import SGD, SGDConfig
 from .adam import Adam, AdamConfig
 
 __all__ = ('SGD', 'SGDConfig', 'Adam', 'AdamConfig')
 
-__version__ = "0.0.1"
\ No newline at end of file
+__version__ = "0.0.1.dev2"
\ No newline at end of file
diff --git a/nadir/adam.py b/src/nadir/adam.py
similarity index 97%
rename from nadir/adam.py
rename to src/nadir/adam.py
index be9ffe7..e87ed59 100644
--- a/nadir/adam.py
+++ b/src/nadir/adam.py
@@ -31,7 +31,7 @@ class AdamConfig(DoEConfig):
 
 
 class Adam(BaseOptimizer):
-    def __init__(self, params, config: DoEConfig, defaults: Optional[Dict[str, Any]] = None):
+    def __init__(self, params, config: AdamConfig, defaults: Optional[Dict[str, Any]] = None):
         if not 0.0 <= config.lr:
             raise ValueError(f"Invalid learning rate: {config.lr}")
         if not 0.0 <= config.eps:


Test patch:
diff --git a/requirements_test.txt b/requirements_test.txt
deleted file mode 100644
index b9441ec..0000000
--- a/requirements_test.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-torch==1.13.1
-torchvision==0.14.1
-tqdm==4.64.1
-wandb==0.13.9