From: SUTER Frederic Date: Fri, 28 Jan 2022 11:49:54 +0000 (+0100) Subject: use property_readonly_static and update deprecation info X-Git-Tag: v3.30~13 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/d8560be1b1e110ce2ac939c46241d09776338690 use property_readonly_static and update deprecation info --- diff --git a/examples/python/actor-join/actor-join.py b/examples/python/actor-join/actor-join.py index 38f209a652..25dfab0f33 100644 --- a/examples/python/actor-join/actor-join.py +++ b/examples/python/actor-join/actor-join.py @@ -55,4 +55,4 @@ if __name__ == '__main__': e.run() - this_actor.info("Simulation time {}".format(e.clock())) + this_actor.info("Simulation time {}".format(e.clock)) diff --git a/examples/python/exec-dvfs/exec-dvfs.py b/examples/python/exec-dvfs/exec-dvfs.py index 6870b04feb..2b22bef6a4 100644 --- a/examples/python/exec-dvfs/exec-dvfs.py +++ b/examples/python/exec-dvfs/exec-dvfs.py @@ -20,7 +20,7 @@ class Dvfs: # Run a task this_actor.execute(workload) - task_time = Engine.clock() + task_time = Engine.clock this_actor.info("Task1 duration: {:.2f}".format(task_time)) # Change power peak @@ -35,7 +35,7 @@ class Dvfs: # Run a second task this_actor.execute(workload) - task_time = Engine.clock() - task_time + task_time = Engine.clock - task_time this_actor.info("Task2 duration: {:.2f}".format(task_time)) # Verify that the default pstate is set to 0 diff --git a/examples/python/io-degradation/io-degradation.py b/examples/python/io-degradation/io-degradation.py index 72895e5add..de16c34837 100644 --- a/examples/python/io-degradation/io-degradation.py +++ b/examples/python/io-degradation/io-degradation.py @@ -22,14 +22,14 @@ import functools def estimate_bw(disk: Disk, n_flows: int, read: bool): """ Calculates the bandwidth for disk doing async operations """ size = 100000 - cur_time = Engine.clock() + cur_time = Engine.clock activities = [disk.read_async(size) if read else disk.write_async( size) for _ in range(n_flows)] for act in activities: act.wait() - elapsed_time = Engine.clock() - cur_time + elapsed_time = Engine.clock - cur_time estimated_bw = float(size * n_flows) / elapsed_time this_actor.info("Disk: %s, concurrent %s: %d, estimated bandwidth: %f" % ( disk.name, "read" if read else "write", n_flows, estimated_bw)) @@ -115,7 +115,7 @@ if __name__ == '__main__': Actor.create("runner", bob, host) e.run() - this_actor.info("Simulated time: %g" % Engine.clock()) + this_actor.info("Simulated time: %g" % e.clock) # explicitly deleting Engine object to avoid segfault during cleanup phase. # During Engine destruction, the cleanup of std::function linked to non_linear callback is called. diff --git a/examples/python/platform-failures/platform-failures.py b/examples/python/platform-failures/platform-failures.py index e1aa136afd..d285aaf01c 100644 --- a/examples/python/platform-failures/platform-failures.py +++ b/examples/python/platform-failures/platform-failures.py @@ -109,4 +109,4 @@ if __name__ == '__main__': e.run() - this_actor.info(f"Simulation time {e.clock():.4f}") + this_actor.info(f"Simulation time {e.clock:.4f}") diff --git a/src/bindings/python/simgrid_python.cpp b/src/bindings/python/simgrid_python.cpp index 6c193c10f2..1153a250cc 100644 --- a/src/bindings/python/simgrid_python.cpp +++ b/src/bindings/python/simgrid_python.cpp @@ -147,48 +147,49 @@ PYBIND11_MODULE(simgrid, m) }), "The constructor should take the parameters from the command line, as is ") .def_static("get_clock", - [](pybind11::object& self) // XBT_ATTRIB_DEPRECATED_v333 + [](pybind11::object& self) // XBT_ATTRIB_DEPRECATED_v334 { PyErr_WarnEx(PyExc_DeprecationWarning, - "get_clock() is deprecated and will be dropped after v3.32, use clock() instead.", 1); + "get_clock() is deprecated and will be dropped after v3.33, use clock() instead.", 1); return self.attr("clock"); }) - .def_static("clock", &Engine::get_clock, - "The simulation time, ie the amount of simulated seconds since the simulation start.") - .def_static( - "instance", []() { return Engine::get_instance(); }, "Retrieve the simulation engine") + .def_property_readonly_static( + "clock", [](py::object /* self */) { return Engine::get_clock(); }, + "The simulation time, ie the amount of simulated seconds since the simulation start.") + .def_property_readonly_static( + "instance", [](py::object /* self */) { return Engine::get_instance(); }, "Retrieve the simulation engine") .def("get_all_hosts", - [](pybind11::object& self) // XBT_ATTRIB_DEPRECATED_v333 + [](pybind11::object& self) // XBT_ATTRIB_DEPRECATED_v334 { PyErr_WarnEx(PyExc_DeprecationWarning, - "get_all_hosts() is deprecated and will be dropped after v3.32, use all_host() instead.", 1); + "get_all_hosts() is deprecated and will be dropped after v3.33, use all_host() instead.", 1); return self.attr("all_hosts"); }) .def_property_readonly("all_hosts", &Engine::get_all_hosts, "Returns the list of all hosts found in the platform") .def("get_all_links", - [](pybind11::object& self) // XBT_ATTRIB_DEPRECATED_v333 + [](pybind11::object& self) // XBT_ATTRIB_DEPRECATED_v334 { PyErr_WarnEx(PyExc_DeprecationWarning, - "get_all_links() is deprecated and will be dropped after v3.32, use all_links() instead.", + "get_all_links() is deprecated and will be dropped after v3.33, use all_links() instead.", 1); return self.attr("all_links"); }) .def_property_readonly("all_links", &Engine::get_all_links, "Returns the list of all links found in the platform") .def("get_all_netpoints", - [](pybind11::object& self) // XBT_ATTRIB_DEPRECATED_v333 + [](pybind11::object& self) // XBT_ATTRIB_DEPRECATED_v334 { PyErr_WarnEx( PyExc_DeprecationWarning, - "get_all_netpoints() is deprecated and will be dropped after v3.32, use all_netpoints() instead.", 1); + "get_all_netpoints() is deprecated and will be dropped after v3.33, use all_netpoints() instead.", 1); return self.attr("all_netpoints"); }) .def_property_readonly("all_netpoints", &Engine::get_all_netpoints) .def("get_netzone_root", - [](pybind11::object& self) // XBT_ATTRIB_DEPRECATED_v333 + [](pybind11::object& self) // XBT_ATTRIB_DEPRECATED_v334 { PyErr_WarnEx( PyExc_DeprecationWarning, - "get_netzone_root() is deprecated and will be dropped after v3.32, use netzone_root() instead.", 1); + "get_netzone_root() is deprecated and will be dropped after v3.3, use netzone_root() instead.", 1); return self.attr("netzone_root"); }) .def_property_readonly("netzone_root", &Engine::get_netzone_root,