1. 27 Oct, 2023 4 commits
    • Kirill Smelkov's avatar
      promis/plugin/check_free_disk_space: np.float -> float · 5c1d2f76
      Kirill Smelkov authored
      Running tests with recent numpy (1.26.0) yields the following:
      
          slapos.toolbox$ python -m unittest discover -v   -s slapos/test/promise/plugin/ -t . -k test_display_prediction
          ...
          Enable to display disk space predictions: True
          module 'numpy' has no attribute 'float'.
          `np.float` was a deprecated alias for the builtin `float`. To avoid this error in existing code, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.
          The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
              https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
          Traceback (most recent call last):
            File "/home/kirr/src/wendelin/slapos/slapos.core/slapos/grid/promise/generic.py", line 500, in run
              self.sense()
            File "/home/kirr/src/wendelin/slapos/slapos.toolbox/slapos/promise/plugin/check_free_disk_space.py", line 327, in sense
              disk_space_prediction_tuple = self.diskSpacePrediction(
                                            ^^^^^^^^^^^^^^^^^^^^^^^^^
            File "/home/kirr/src/wendelin/slapos/slapos.toolbox/slapos/promise/plugin/check_free_disk_space.py", line 182, in diskSpacePrediction
              df = df.astype({'free': np.float})
                                      ^^^^^^^^
            File "/home/kirr/src/wendelin/venv/py3.venv/lib/python3.11/site-packages/numpy/__init__.py", line 324, in __getattr__
              raise AttributeError(__former_attrs__[attr])
          AttributeError: module 'numpy' has no attribute 'float'.
          `np.float` was a deprecated alias for the builtin `float`. To avoid this error in existing code, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.
          The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
              https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
          ERROR
      
      -> Replace np.float with float as the error says.
      
      /cc @Just1, @lu.xu, @jhuge, @tomo
      /reviewed-on !123
      5c1d2f76
    • Kirill Smelkov's avatar
      promis/plugin/check_free_disk_space: test: Fix unclosed file ResourceWarning · daf7820f
      Kirill Smelkov authored
      folder_disk_test.sql was opened to be read but was not closed:
      
          slapos.toolbox$ python -m unittest discover -v   -s slapos/test/promise/plugin/ -t . -k test_display_prediction
          test_display_prediction (slapos.test.promise.plugin.test_check_free_disk_space.testcheckfreediskspace.test_display_prediction) ...
          /usr/lib/python3.11/unittest/case.py:576: resourcewarning: unclosed file <_io.textiowrapper name='/home/kirr/src/wendelin/slapos/slapos.toolbox/slapos/test/promise/data/disktest.sql' mode='r' encoding='utf-8'>
            self.setup()
      
      /cc @Just1, @lu.xu, @jhuge, @tomo
      /reviewed-on !124
      daf7820f
    • Kirill Smelkov's avatar
      *: Compare integers by == or != instead of by `is` or `is not` · dfb32247
      Kirill Smelkov authored
      Same logic as in previous patch. Suggested by @jeorme in
      !122 (comment 193062) .
      
      /suggested-and-reviewed-by @jerome
      /reviewed-n !122
      dfb32247
    • Kirill Smelkov's avatar
      *: Compare strings by == or != instead of by `is` or `is not` · b1c4c044
      Kirill Smelkov authored
      In python `is` checks object identity, not content:
      
          In [1]: a = 'hello'
      
          In [2]: a += ' world'
      
          In [3]: b = 'hello world'
      
          In [4]: id(a)
          Out[4]: 139735676540976
      
          In [5]: id(b)
          Out[5]: 139735675829040
      
          In [6]: a is b              <-- NOTE
          Out[6]: False
      
          In [7]: a == b              <-- NOTE
          Out[7]: True
      
      So comparing strings by is is generally incorrect.
      
      -> Fix strings comparision to use == / != everywhere (at least in found
      places where string is compared wrt string literal)
      
      We already had similar fix in a8526f4e, but seems the story continues
      again.
      
      /cc @alain.takoudjou, @Just1, @lu.xu, @jhuge, @tomo
      /reviewed-by @jerome
      /reviewed-on !122
      b1c4c044
  2. 12 Oct, 2023 2 commits
  3. 11 Oct, 2023 4 commits
  4. 22 Sep, 2023 2 commits
  5. 21 Sep, 2023 4 commits
  6. 07 Aug, 2023 1 commit
  7. 15 Jun, 2023 1 commit
  8. 08 Jun, 2023 1 commit
  9. 16 May, 2023 3 commits
  10. 15 May, 2023 1 commit
  11. 31 Mar, 2023 1 commit
  12. 20 Mar, 2023 2 commits
  13. 09 Mar, 2023 13 commits
  14. 07 Mar, 2023 1 commit