Repository: pytorch/ignite

Issue:
Polyaxon logger internal update
## 🚀 Feature

A cross-reposting of https://github.com/polyaxon/polyaxon/issues/787

Polyaxon logger internal update
## 🚀 Feature

A cross-reposting of https://github.com/polyaxon/polyaxon/issues/787



Discussion:

Resolving patch:
diff --git a/examples/references/classification/imagenet/code/utils/exp_tracking.py b/examples/references/classification/imagenet/code/utils/exp_tracking.py
--- a/examples/references/classification/imagenet/code/utils/exp_tracking.py
+++ b/examples/references/classification/imagenet/code/utils/exp_tracking.py
@@ -10,15 +10,19 @@
 from ignite.contrib.engines import common
 
 try:
-    import polyaxon_client.tracking  # noqa: F401
-
-    if "POLYAXON_RUN_OUTPUTS_PATH" not in os.environ:
-        raise ImportError("Not in Polyaxon cluster")
+    import polyaxon.tracking  # noqa: F401
 
     has_plx = True
 except ImportError:
-    has_plx = False
+    try:
+        import polyaxon_client.tracking  # noqa: F401
 
+        if "POLYAXON_RUN_OUTPUTS_PATH" not in os.environ:
+            raise ImportError("Not in Polyaxon cluster")
+
+        has_plx = True
+    except ImportError:
+        has_plx = False
 
 try:
     import mlflow
diff --git a/examples/references/segmentation/pascal_voc2012/code/utils/exp_tracking.py b/examples/references/segmentation/pascal_voc2012/code/utils/exp_tracking.py
--- a/examples/references/segmentation/pascal_voc2012/code/utils/exp_tracking.py
+++ b/examples/references/segmentation/pascal_voc2012/code/utils/exp_tracking.py
@@ -10,14 +10,19 @@
 from ignite.contrib.engines import common
 
 try:
-    import polyaxon_client.tracking  # noqa: F401
-
-    if "POLYAXON_RUN_OUTPUTS_PATH" not in os.environ:
-        raise ImportError("Not in Polyaxon cluster")
+    import polyaxon.tracking  # noqa: F401
 
     has_plx = True
 except ImportError:
-    has_plx = False
+    try:
+        import polyaxon_client.tracking  # noqa: F401
+
+        if "POLYAXON_RUN_OUTPUTS_PATH" not in os.environ:
+            raise ImportError("Not in Polyaxon cluster")
+
+        has_plx = True
+    except ImportError:
+        has_plx = False
 
 
 try:
diff --git a/ignite/contrib/handlers/polyaxon_logger.py b/ignite/contrib/handlers/polyaxon_logger.py
--- a/ignite/contrib/handlers/polyaxon_logger.py
+++ b/ignite/contrib/handlers/polyaxon_logger.py
@@ -17,10 +17,14 @@ class PolyaxonLogger(BaseLogger):
     `Polyaxon <https://polyaxon.com/>`_ tracking client handler to log parameters and metrics during the training
     and validation.
 
-    This class requires `polyaxon-client <https://github.com/polyaxon/polyaxon-client/>`_ package to be installed:
+    This class requires `polyaxon <https://github.com/polyaxon/polyaxon/>`_ package to be installed:
 
     .. code-block:: bash
 
+        pip install polyaxon
+
+        // If you are using polyaxon v0.x
+
         pip install polyaxon-client
 
 
@@ -85,22 +89,28 @@ class PolyaxonLogger(BaseLogger):
 
     Args:
         args: Positional arguments accepted from
-            `Experiment <https://docs.polyaxon.com/references/polyaxon-tracking-api/experiments/>`_.
+            `Experiment <https://polyaxon.com/docs/experimentation/tracking/client/>`_.
         kwargs: Keyword arguments accepted from
-            `Experiment <https://docs.polyaxon.com/references/polyaxon-tracking-api/experiments/>`_.
+            `Experiment <https://polyaxon.com/docs/experimentation/tracking/client/>`_.
 
     """
 
     def __init__(self, *args: Any, **kwargs: Any):
         try:
-            from polyaxon_client.tracking import Experiment
-        except ImportError:
-            raise RuntimeError(
-                "This contrib module requires polyaxon-client to be installed. "
-                "Please install it with command: \n pip install polyaxon-client"
-            )
+            from polyaxon.tracking import Run
 
-        self.experiment = Experiment(*args, **kwargs)
+            self.experiment = Run(*args, **kwargs)
+        except ImportError:
+            try:
+                from polyaxon_client.tracking import Experiment
+
+                self.experiment = Experiment(*args, **kwargs)
+            except ImportError:
+                raise RuntimeError(
+                    "This contrib module requires polyaxon to be installed.\n"
+                    "For Polyaxon v1.x please install it with command: \n pip install polyaxon\n"
+                    "For Polyaxon v0.x please install it with command: \n pip install polyaxon-client"
+                )
 
     def __getattr__(self, attr: Any) -> Any:
         return getattr(self.experiment, attr)


Test patch:
diff --git a/tests/ignite/contrib/handlers/test_polyaxon_logger.py b/tests/ignite/contrib/handlers/test_polyaxon_logger.py
--- a/tests/ignite/contrib/handlers/test_polyaxon_logger.py
+++ b/tests/ignite/contrib/handlers/test_polyaxon_logger.py
@@ -301,5 +301,7 @@ def no_site_packages():
 
 def test_no_polyaxon_client(no_site_packages):
 
-    with pytest.raises(RuntimeError, match=r"This contrib module requires polyaxon-client to be installed"):
+    with pytest.raises(
+        RuntimeError, match=r"This contrib module requires polyaxon",
+    ):
         PolyaxonLogger()