stouputils 1.7.1__tar.gz → 1.7.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. {stouputils-1.7.1 → stouputils-1.7.3}/PKG-INFO +23 -22
  2. {stouputils-1.7.1 → stouputils-1.7.3}/README.md +22 -21
  3. {stouputils-1.7.1 → stouputils-1.7.3}/pyproject.toml +1 -1
  4. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/all_doctests.py +6 -2
  5. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/archive.py +3 -3
  6. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/collections.py +66 -7
  7. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/collections.pyi +13 -1
  8. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/continuous_delivery/cd_utils.py +7 -5
  9. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/continuous_delivery/github.py +10 -2
  10. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/continuous_delivery/pyproject.py +2 -2
  11. stouputils-1.7.3/stouputils/image.py +423 -0
  12. stouputils-1.7.3/stouputils/image.pyi +163 -0
  13. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/io.py +4 -1
  14. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/parallel.py +16 -9
  15. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/parallel.pyi +1 -1
  16. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/print.py +2 -3
  17. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/print.pyi +1 -1
  18. stouputils-1.7.1/stouputils/image.py +0 -95
  19. stouputils-1.7.1/stouputils/image.pyi +0 -44
  20. {stouputils-1.7.1 → stouputils-1.7.3}/.gitignore +0 -0
  21. {stouputils-1.7.1 → stouputils-1.7.3}/LICENSE +0 -0
  22. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/__init__.py +0 -0
  23. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/__init__.pyi +0 -0
  24. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/__main__.py +0 -0
  25. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/all_doctests.pyi +0 -0
  26. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/applications/__init__.py +0 -0
  27. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/applications/__init__.pyi +0 -0
  28. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/applications/automatic_docs.py +0 -0
  29. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/applications/automatic_docs.pyi +0 -0
  30. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/applications/upscaler/__init__.py +0 -0
  31. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/applications/upscaler/__init__.pyi +0 -0
  32. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/applications/upscaler/config.py +0 -0
  33. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/applications/upscaler/config.pyi +0 -0
  34. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/applications/upscaler/image.py +0 -0
  35. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/applications/upscaler/image.pyi +0 -0
  36. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/applications/upscaler/video.py +0 -0
  37. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/applications/upscaler/video.pyi +0 -0
  38. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/archive.pyi +0 -0
  39. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/backup.py +0 -0
  40. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/backup.pyi +0 -0
  41. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/continuous_delivery/__init__.py +0 -0
  42. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/continuous_delivery/__init__.pyi +0 -0
  43. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/continuous_delivery/cd_utils.pyi +0 -0
  44. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/continuous_delivery/github.pyi +0 -0
  45. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/continuous_delivery/pypi.py +0 -0
  46. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/continuous_delivery/pypi.pyi +0 -0
  47. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/continuous_delivery/pyproject.pyi +0 -0
  48. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/continuous_delivery/stubs.py +0 -0
  49. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/continuous_delivery/stubs.pyi +0 -0
  50. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/ctx.py +0 -0
  51. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/ctx.pyi +0 -0
  52. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/config/get.py +0 -0
  53. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/config/set.py +0 -0
  54. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/data_processing/image/__init__.py +0 -0
  55. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/data_processing/image/auto_contrast.py +0 -0
  56. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/data_processing/image/axis_flip.py +0 -0
  57. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/data_processing/image/bias_field_correction.py +0 -0
  58. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/data_processing/image/binary_threshold.py +0 -0
  59. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/data_processing/image/blur.py +0 -0
  60. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/data_processing/image/brightness.py +0 -0
  61. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/data_processing/image/canny.py +0 -0
  62. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/data_processing/image/clahe.py +0 -0
  63. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/data_processing/image/common.py +0 -0
  64. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/data_processing/image/contrast.py +0 -0
  65. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/data_processing/image/curvature_flow_filter.py +0 -0
  66. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/data_processing/image/denoise.py +0 -0
  67. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/data_processing/image/histogram_equalization.py +0 -0
  68. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/data_processing/image/invert.py +0 -0
  69. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/data_processing/image/laplacian.py +0 -0
  70. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/data_processing/image/median_blur.py +0 -0
  71. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/data_processing/image/noise.py +0 -0
  72. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/data_processing/image/normalize.py +0 -0
  73. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/data_processing/image/random_erase.py +0 -0
  74. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/data_processing/image/resize.py +0 -0
  75. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/data_processing/image/rotation.py +0 -0
  76. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/data_processing/image/salt_pepper.py +0 -0
  77. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/data_processing/image/sharpening.py +0 -0
  78. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/data_processing/image/shearing.py +0 -0
  79. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/data_processing/image/threshold.py +0 -0
  80. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/data_processing/image/translation.py +0 -0
  81. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/data_processing/image/zoom.py +0 -0
  82. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/data_processing/image_augmentation.py +0 -0
  83. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/data_processing/image_preprocess.py +0 -0
  84. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/data_processing/prosthesis_detection.py +0 -0
  85. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/data_processing/technique.py +0 -0
  86. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/dataset/__init__.py +0 -0
  87. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/dataset/dataset.py +0 -0
  88. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/dataset/dataset_loader.py +0 -0
  89. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/dataset/grouping_strategy.py +0 -0
  90. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/dataset/image_loader.py +0 -0
  91. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/dataset/xy_tuple.py +0 -0
  92. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/metric_dictionnary.py +0 -0
  93. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/metric_utils.py +0 -0
  94. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/mlflow_utils.py +0 -0
  95. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/models/abstract_model.py +0 -0
  96. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/models/all.py +0 -0
  97. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/models/base_keras.py +0 -0
  98. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/models/keras/all.py +0 -0
  99. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/models/keras/convnext.py +0 -0
  100. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/models/keras/densenet.py +0 -0
  101. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/models/keras/efficientnet.py +0 -0
  102. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/models/keras/mobilenet.py +0 -0
  103. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/models/keras/resnet.py +0 -0
  104. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/models/keras/squeezenet.py +0 -0
  105. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/models/keras/vgg.py +0 -0
  106. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/models/keras/xception.py +0 -0
  107. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/models/keras_utils/callbacks/__init__.py +0 -0
  108. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/models/keras_utils/callbacks/colored_progress_bar.py +0 -0
  109. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/models/keras_utils/callbacks/learning_rate_finder.py +0 -0
  110. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/models/keras_utils/callbacks/model_checkpoint_v2.py +0 -0
  111. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/models/keras_utils/callbacks/progressive_unfreezing.py +0 -0
  112. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/models/keras_utils/callbacks/warmup_scheduler.py +0 -0
  113. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/models/keras_utils/losses/__init__.py +0 -0
  114. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/models/keras_utils/losses/next_generation_loss.py +0 -0
  115. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/models/keras_utils/visualizations.py +0 -0
  116. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/models/model_interface.py +0 -0
  117. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/models/sandbox.py +0 -0
  118. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/range_tuple.py +0 -0
  119. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/scripts/augment_dataset.py +0 -0
  120. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/scripts/exhaustive_process.py +0 -0
  121. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/scripts/preprocess_dataset.py +0 -0
  122. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/scripts/routine.py +0 -0
  123. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/data_science/utils.py +0 -0
  124. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/decorators.py +0 -0
  125. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/decorators.pyi +0 -0
  126. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/installer/__init__.py +0 -0
  127. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/installer/__init__.pyi +0 -0
  128. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/installer/common.py +0 -0
  129. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/installer/common.pyi +0 -0
  130. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/installer/downloader.py +0 -0
  131. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/installer/downloader.pyi +0 -0
  132. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/installer/linux.py +0 -0
  133. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/installer/linux.pyi +0 -0
  134. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/installer/main.py +0 -0
  135. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/installer/main.pyi +0 -0
  136. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/installer/windows.py +0 -0
  137. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/installer/windows.pyi +0 -0
  138. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/io.pyi +0 -0
  139. {stouputils-1.7.1 → stouputils-1.7.3}/stouputils/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stouputils
3
- Version: 1.7.1
3
+ Version: 1.7.3
4
4
  Summary: Stouputils is a collection of utility modules designed to simplify and enhance the development process. It includes a range of tools for tasks such as execution of doctests, display utilities, decorators, as well as context managers, and many more.
5
5
  Project-URL: Homepage, https://github.com/Stoupy51/stouputils
6
6
  Project-URL: Issues, https://github.com/Stoupy51/stouputils/issues
@@ -86,10 +86,11 @@ It includes a range of tools for tasks such as execution of doctests, display ut
86
86
  │ └── ...
87
87
 
88
88
  ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.continuous_delivery.html">continuous_delivery/</a>
89
- │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.continuous_delivery.cd_utils.html">cd_utils.py</a> <span class="comment"># 🔧 Common utilities for continuous delivery</span>
90
- │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.continuous_delivery.github.html">github.py</a> <span class="comment"># 📦 GitHub utilities (upload_to_github)</span>
91
- │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.continuous_delivery.pypi.html">pypi.py</a> <span class="comment"># 📦 PyPI utilities (pypi_full_routine)</span>
92
- │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.continuous_delivery.pyproject.html">pyproject.py</a> <span class="comment"># 📝 Pyproject.toml utilities</span>
89
+ │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.continuous_delivery.cd_utils.html">cd_utils.py</a> <span class="comment"># 🔧 Utilities for continuous delivery</span>
90
+ │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.continuous_delivery.github.html">github.py</a> <span class="comment"># 📦 Utilities for continuous delivery on GitHub (upload_to_github)</span>
91
+ │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.continuous_delivery.pypi.html">pypi.py</a> <span class="comment"># 📦 Utilities for PyPI (pypi_full_routine)</span>
92
+ │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.continuous_delivery.pyproject.html">pyproject.py</a> <span class="comment"># 📝 Utilities for reading, writing and managing pyproject.toml files</span>
93
+ │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.continuous_delivery.stubs.html">stubs.py</a> <span class="comment"># 📝 Utilities for generating stub files using stubgen</span>
93
94
  │ └── ...
94
95
 
95
96
  ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.data_science.html">data_science/</a>
@@ -103,28 +104,28 @@ It includes a range of tools for tasks such as execution of doctests, display ut
103
104
  │ │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.data_science.models.keras_utils.html">keras_utils/</a> <span class="comment"># 🛠️ Keras utilities (callbacks, losses, visualizations)</span>
104
105
  │ │ └── ...
105
106
  │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.data_science.scripts.html">scripts/</a> <span class="comment"># 📜 Data science scripts (augment, preprocess, routine)</span>
106
- │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.data_science.metric_utils.html">metric_utils.py</a> <span class="comment"># 📏 Metrics utilities for ML/DL models</span>
107
- │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.data_science.mlflow_utils.html">mlflow_utils.py</a> <span class="comment"># 📊 MLflow integration utilities</span>
107
+ │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.data_science.metric_utils.html">metric_utils.py</a> <span class="comment"># 📏 Static methods for calculating various ML metrics</span>
108
+ │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.data_science.mlflow_utils.html">mlflow_utils.py</a> <span class="comment"># 📊 Utility functions for working with MLflow</span>
108
109
  │ └── ...
109
110
 
110
111
  ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.installer.html">installer/</a>
111
- │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.installer.common.html">common.py</a> <span class="comment"># 🔧 Common installer utilities</span>
112
- │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.installer.downloader.html">downloader.py</a> <span class="comment"># ⬇️ File download utilities</span>
113
- │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.installer.linux.html">linux.py</a> <span class="comment"># 🐧 Linux-specific installer utilities</span>
114
- │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.installer.main.html">main.py</a> <span class="comment"># 🚀 Main installer functionality</span>
115
- │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.installer.windows.html">windows.py</a> <span class="comment"># 💻 Windows-specific installer utilities</span>
112
+ │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.installer.common.html">common.py</a> <span class="comment"># 🔧 Common functions used by the Linux and Windows installers modules</span>
113
+ │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.installer.downloader.html">downloader.py</a> <span class="comment"># ⬇️ Functions for downloading and installing programs from URLs</span>
114
+ │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.installer.linux.html">linux.py</a> <span class="comment"># 🐧 Linux/macOS specific implementations for installation</span>
115
+ │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.installer.main.html">main.py</a> <span class="comment"># 🚀 Core installation functions for installing programs from zip files or URLs</span>
116
+ │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.installer.windows.html">windows.py</a> <span class="comment"># 💻 Windows specific implementations for installation</span>
116
117
  │ └── ...
117
118
 
118
- ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.all_doctests.html">all_doctests.py</a> <span class="comment"># ✅ Execution of all doctests for a given path</span>
119
- ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.archive.html">archive.py</a> <span class="comment"># 📦 Archive utilities (zip, repair_zip)</span>
120
- ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.backup.html">backup.py</a> <span class="comment"># 📦 Backup utilities (delta backup, consolidate)</span>
121
- ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.collections.html">collections.py</a> <span class="comment"># 🧰 Collection utilities (unique_list, sort_dict_keys, array_to_disk)</span>
122
- ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.ctx.html">ctx.py</a> <span class="comment"># 🚫 Context managers (Muffle, LogToFile)</span>
123
- ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.decorators.html">decorators.py</a> <span class="comment"># 🎯 Decorators (silent, measure_time, error_handler, simple_cache, retry)</span>
124
- ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.image.html">image.py</a> <span class="comment"># 🖼️ Image utilities (image_resize)</span>
125
- ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.io.html">io.py</a> <span class="comment"># 💻 I/O utilities (file management, json)</span>
126
- ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.parallel.html">parallel.py</a> <span class="comment"># 🧑‍🤝‍🧑 Parallel processing (multiprocessing, multithreading)</span>
127
- ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.print.html">print.py</a> <span class="comment"># 🖨️ Display utilities (info, debug, warning, error)</span>
119
+ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.all_doctests.html">all_doctests.py</a> <span class="comment"># ✅ Run all doctests for all modules in a given directory</span>
120
+ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.archive.html">archive.py</a> <span class="comment"># 📦 Functions for creating and managing archives</span>
121
+ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.backup.html">backup.py</a> <span class="comment"># 💾 Utilities for backup management (delta backup, consolidate)</span>
122
+ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.collections.html">collections.py</a> <span class="comment"># 🧰 Utilities for collection manipulation (unique_list, sort_dict_keys, upsert_in_dataframe, array_to_disk)</span>
123
+ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.ctx.html">ctx.py</a> <span class="comment"># 🔇 Context managers (Muffle, LogToFile, MeasureTime, DoNothing)</span>
124
+ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.decorators.html">decorators.py</a> <span class="comment"># 🎯 Decorators (measure_time, handle_error, simple_cache, retry, abstract, deprecated, silent)</span>
125
+ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.image.html">image.py</a> <span class="comment"># 🖼️ Little utilities for image processing (image_resize, auto_crop, numpy_to_gif, numpy_to_obj)</span>
126
+ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.io.html">io.py</a> <span class="comment"># 💾 Utilities for file management (super_json, super_csv, super_copy, super_open, clean_path)</span>
127
+ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.parallel.html">parallel.py</a> <span class="comment"># 🔀 Utility functions for parallel processing (multiprocessing, multithreading)</span>
128
+ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.print.html">print.py</a> <span class="comment"># 🖨️ Utility functions for printing messages with different levels of importance</span>
128
129
  └── ...
129
130
  </pre>
130
131
  </html>
@@ -45,10 +45,11 @@ It includes a range of tools for tasks such as execution of doctests, display ut
45
45
  │ └── ...
46
46
 
47
47
  ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.continuous_delivery.html">continuous_delivery/</a>
48
- │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.continuous_delivery.cd_utils.html">cd_utils.py</a> <span class="comment"># 🔧 Common utilities for continuous delivery</span>
49
- │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.continuous_delivery.github.html">github.py</a> <span class="comment"># 📦 GitHub utilities (upload_to_github)</span>
50
- │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.continuous_delivery.pypi.html">pypi.py</a> <span class="comment"># 📦 PyPI utilities (pypi_full_routine)</span>
51
- │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.continuous_delivery.pyproject.html">pyproject.py</a> <span class="comment"># 📝 Pyproject.toml utilities</span>
48
+ │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.continuous_delivery.cd_utils.html">cd_utils.py</a> <span class="comment"># 🔧 Utilities for continuous delivery</span>
49
+ │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.continuous_delivery.github.html">github.py</a> <span class="comment"># 📦 Utilities for continuous delivery on GitHub (upload_to_github)</span>
50
+ │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.continuous_delivery.pypi.html">pypi.py</a> <span class="comment"># 📦 Utilities for PyPI (pypi_full_routine)</span>
51
+ │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.continuous_delivery.pyproject.html">pyproject.py</a> <span class="comment"># 📝 Utilities for reading, writing and managing pyproject.toml files</span>
52
+ │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.continuous_delivery.stubs.html">stubs.py</a> <span class="comment"># 📝 Utilities for generating stub files using stubgen</span>
52
53
  │ └── ...
53
54
 
54
55
  ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.data_science.html">data_science/</a>
@@ -62,28 +63,28 @@ It includes a range of tools for tasks such as execution of doctests, display ut
62
63
  │ │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.data_science.models.keras_utils.html">keras_utils/</a> <span class="comment"># 🛠️ Keras utilities (callbacks, losses, visualizations)</span>
63
64
  │ │ └── ...
64
65
  │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.data_science.scripts.html">scripts/</a> <span class="comment"># 📜 Data science scripts (augment, preprocess, routine)</span>
65
- │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.data_science.metric_utils.html">metric_utils.py</a> <span class="comment"># 📏 Metrics utilities for ML/DL models</span>
66
- │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.data_science.mlflow_utils.html">mlflow_utils.py</a> <span class="comment"># 📊 MLflow integration utilities</span>
66
+ │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.data_science.metric_utils.html">metric_utils.py</a> <span class="comment"># 📏 Static methods for calculating various ML metrics</span>
67
+ │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.data_science.mlflow_utils.html">mlflow_utils.py</a> <span class="comment"># 📊 Utility functions for working with MLflow</span>
67
68
  │ └── ...
68
69
 
69
70
  ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.installer.html">installer/</a>
70
- │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.installer.common.html">common.py</a> <span class="comment"># 🔧 Common installer utilities</span>
71
- │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.installer.downloader.html">downloader.py</a> <span class="comment"># ⬇️ File download utilities</span>
72
- │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.installer.linux.html">linux.py</a> <span class="comment"># 🐧 Linux-specific installer utilities</span>
73
- │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.installer.main.html">main.py</a> <span class="comment"># 🚀 Main installer functionality</span>
74
- │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.installer.windows.html">windows.py</a> <span class="comment"># 💻 Windows-specific installer utilities</span>
71
+ │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.installer.common.html">common.py</a> <span class="comment"># 🔧 Common functions used by the Linux and Windows installers modules</span>
72
+ │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.installer.downloader.html">downloader.py</a> <span class="comment"># ⬇️ Functions for downloading and installing programs from URLs</span>
73
+ │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.installer.linux.html">linux.py</a> <span class="comment"># 🐧 Linux/macOS specific implementations for installation</span>
74
+ │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.installer.main.html">main.py</a> <span class="comment"># 🚀 Core installation functions for installing programs from zip files or URLs</span>
75
+ │ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.installer.windows.html">windows.py</a> <span class="comment"># 💻 Windows specific implementations for installation</span>
75
76
  │ └── ...
76
77
 
77
- ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.all_doctests.html">all_doctests.py</a> <span class="comment"># ✅ Execution of all doctests for a given path</span>
78
- ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.archive.html">archive.py</a> <span class="comment"># 📦 Archive utilities (zip, repair_zip)</span>
79
- ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.backup.html">backup.py</a> <span class="comment"># 📦 Backup utilities (delta backup, consolidate)</span>
80
- ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.collections.html">collections.py</a> <span class="comment"># 🧰 Collection utilities (unique_list, sort_dict_keys, array_to_disk)</span>
81
- ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.ctx.html">ctx.py</a> <span class="comment"># 🚫 Context managers (Muffle, LogToFile)</span>
82
- ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.decorators.html">decorators.py</a> <span class="comment"># 🎯 Decorators (silent, measure_time, error_handler, simple_cache, retry)</span>
83
- ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.image.html">image.py</a> <span class="comment"># 🖼️ Image utilities (image_resize)</span>
84
- ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.io.html">io.py</a> <span class="comment"># 💻 I/O utilities (file management, json)</span>
85
- ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.parallel.html">parallel.py</a> <span class="comment"># 🧑‍🤝‍🧑 Parallel processing (multiprocessing, multithreading)</span>
86
- ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.print.html">print.py</a> <span class="comment"># 🖨️ Display utilities (info, debug, warning, error)</span>
78
+ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.all_doctests.html">all_doctests.py</a> <span class="comment"># ✅ Run all doctests for all modules in a given directory</span>
79
+ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.archive.html">archive.py</a> <span class="comment"># 📦 Functions for creating and managing archives</span>
80
+ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.backup.html">backup.py</a> <span class="comment"># 💾 Utilities for backup management (delta backup, consolidate)</span>
81
+ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.collections.html">collections.py</a> <span class="comment"># 🧰 Utilities for collection manipulation (unique_list, sort_dict_keys, upsert_in_dataframe, array_to_disk)</span>
82
+ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.ctx.html">ctx.py</a> <span class="comment"># 🔇 Context managers (Muffle, LogToFile, MeasureTime, DoNothing)</span>
83
+ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.decorators.html">decorators.py</a> <span class="comment"># 🎯 Decorators (measure_time, handle_error, simple_cache, retry, abstract, deprecated, silent)</span>
84
+ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.image.html">image.py</a> <span class="comment"># 🖼️ Little utilities for image processing (image_resize, auto_crop, numpy_to_gif, numpy_to_obj)</span>
85
+ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.io.html">io.py</a> <span class="comment"># 💾 Utilities for file management (super_json, super_csv, super_copy, super_open, clean_path)</span>
86
+ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.parallel.html">parallel.py</a> <span class="comment"># 🔀 Utility functions for parallel processing (multiprocessing, multithreading)</span>
87
+ ├── <a href="https://stoupy51.github.io/stouputils/latest/modules/stouputils.print.html">print.py</a> <span class="comment"># 🖨️ Utility functions for printing messages with different levels of importance</span>
87
88
  └── ...
88
89
  </pre>
89
90
  </html>
@@ -5,7 +5,7 @@ build-backend = "hatchling.build"
5
5
 
6
6
  [project]
7
7
  name = "stouputils"
8
- version = "1.7.1"
8
+ version = "1.7.3"
9
9
  description = "Stouputils is a collection of utility modules designed to simplify and enhance the development process. It includes a range of tools for tasks such as execution of doctests, display utilities, decorators, as well as context managers, and many more."
10
10
  readme = "README.md"
11
11
  requires-python = ">=3.10"
@@ -13,14 +13,17 @@ import importlib
13
13
  import os
14
14
  import pkgutil
15
15
  import sys
16
- from doctest import TestResults, testmod
17
16
  from types import ModuleType
17
+ from typing import TYPE_CHECKING
18
18
 
19
19
  from . import decorators
20
20
  from .decorators import measure_time
21
21
  from .io import clean_path, relative_path
22
22
  from .print import error, info, progress, warning
23
23
 
24
+ if TYPE_CHECKING:
25
+ from doctest import TestResults
26
+
24
27
 
25
28
  # Main program
26
29
  def launch_tests(root_dir: str, strict: bool = True) -> int:
@@ -140,7 +143,7 @@ def launch_tests(root_dir: str, strict: bool = True) -> int:
140
143
  return total_failed
141
144
 
142
145
 
143
- def test_module_with_progress(module: ModuleType, separator: str) -> TestResults:
146
+ def test_module_with_progress(module: ModuleType, separator: str) -> "TestResults":
144
147
  """ Test a module with testmod and measure the time taken with progress printing.
145
148
 
146
149
  Args:
@@ -149,6 +152,7 @@ def test_module_with_progress(module: ModuleType, separator: str) -> TestResults
149
152
  Returns:
150
153
  TestResults: The results of the tests
151
154
  """
155
+ from doctest import TestResults, testmod
152
156
  @measure_time(progress, message=f"Testing module '{module.__name__}' {separator}took")
153
157
  def internal() -> TestResults:
154
158
  return testmod(m=module)
@@ -41,9 +41,6 @@ def repair_zip_file(file_path: str, destination: str) -> bool:
41
41
 
42
42
  > repair_zip_file("/path/to/source.zip", "/path/to/destination.zip")
43
43
  """
44
- import struct
45
- import zlib
46
-
47
44
  # Check
48
45
  if not os.path.exists(file_path):
49
46
  raise FileNotFoundError(f"File '{file_path}' not found")
@@ -51,6 +48,9 @@ def repair_zip_file(file_path: str, destination: str) -> bool:
51
48
  if dirname and not os.path.exists(dirname):
52
49
  raise FileNotFoundError(f"Directory '{dirname}' not found")
53
50
 
51
+ import struct
52
+ import zlib
53
+
54
54
  # Read the entire ZIP file into memory
55
55
  with open(file_path, 'rb') as f:
56
56
  data = f.read()
@@ -3,6 +3,7 @@ This module provides utilities for collection manipulation:
3
3
 
4
4
  - unique_list: Remove duplicates from a list while preserving order using object id, hash or str
5
5
  - sort_dict_keys: Sort dictionary keys using a given order list (ascending or descending)
6
+ - upsert_in_dataframe: Insert or update a row in a Polars DataFrame based on primary keys
6
7
  - array_to_disk: Easily handle large numpy arrays on disk using zarr for efficient storage and access.
7
8
 
8
9
  .. image:: https://raw.githubusercontent.com/Stoupy51/stouputils/refs/heads/main/assets/collections_module.gif
@@ -14,11 +15,14 @@ import atexit
14
15
  import os
15
16
  import shutil
16
17
  import tempfile
17
- from typing import Any, Literal, TypeVar
18
+ from typing import TYPE_CHECKING, Any, Literal, TypeVar
18
19
 
19
- import numpy as np
20
- import zarr # pyright: ignore[reportMissingTypeStubs]
21
- from numpy.typing import NDArray
20
+ # Lazy imports for typing
21
+ if TYPE_CHECKING:
22
+ import numpy as np
23
+ import polars as pl
24
+ import zarr # pyright: ignore[reportMissingTypeStubs]
25
+ from numpy.typing import NDArray
22
26
 
23
27
  # Typing
24
28
  T = TypeVar("T")
@@ -94,11 +98,62 @@ def sort_dict_keys(dictionary: dict[T, Any], order: list[T], reverse: bool = Fal
94
98
  """
95
99
  return dict(sorted(dictionary.items(), key=lambda x: order.index(x[0]) if x[0] in order else len(order), reverse=reverse))
96
100
 
101
+ def upsert_in_dataframe(
102
+ df: "pl.DataFrame",
103
+ new_entry: dict[str, Any],
104
+ primary_keys: dict[str, Any] | None = None
105
+ ) -> "pl.DataFrame":
106
+ """ Insert or update a row in the Polars DataFrame based on primary keys.
107
+
108
+ Args:
109
+ df (pl.DataFrame): The Polars DataFrame to update.
110
+ new_entry (dict[str, Any]): The new entry to insert or update.
111
+ primary_keys (dict[str, Any]): The primary keys to identify the row (default: empty).
112
+ Returns:
113
+ pl.DataFrame: The updated Polars DataFrame.
114
+ """
115
+ # Imports
116
+ import polars as pl
117
+
118
+ # Create new DataFrame if file doesn't exist or is invalid
119
+ if df.is_empty():
120
+ return pl.DataFrame([new_entry])
121
+
122
+ # If no primary keys provided, return DataFrame with new entry appended
123
+ if not primary_keys:
124
+ new_row_df = pl.DataFrame([new_entry])
125
+ return pl.concat([df, new_row_df], how="diagonal_relaxed")
126
+
127
+ # Build mask based on primary keys
128
+ mask: pl.Expr = pl.lit(True)
129
+ for key, value in primary_keys.items():
130
+ if key in df.columns:
131
+ mask = mask & (df[key] == value)
132
+ else:
133
+ # Primary key column doesn't exist, so no match possible
134
+ mask = pl.lit(False)
135
+ break
136
+
137
+ # Insert or update row based on primary keys
138
+ if df.select(mask).to_series().any():
139
+ # Update existing row
140
+ for key, value in new_entry.items():
141
+ if key in df.columns:
142
+ df = df.with_columns(pl.when(mask).then(pl.lit(value)).otherwise(pl.col(key)).alias(key))
143
+ else:
144
+ # Add new column if it doesn't exist
145
+ df = df.with_columns(pl.when(mask).then(pl.lit(value)).otherwise(None).alias(key))
146
+ return df
147
+ else:
148
+ # Insert new row
149
+ new_row_df = pl.DataFrame([new_entry])
150
+ return pl.concat([df, new_row_df], how="diagonal_relaxed")
151
+
97
152
  def array_to_disk(
98
- data: NDArray[Any] | zarr.Array,
153
+ data: "NDArray[Any] | zarr.Array",
99
154
  delete_input: bool = True,
100
- more_data: NDArray[Any] | zarr.Array | None = None
101
- ) -> tuple[zarr.Array, str, int]:
155
+ more_data: "NDArray[Any] | zarr.Array | None" = None
156
+ ) -> tuple["zarr.Array", str, int]:
102
157
  """ Easily handle large numpy arrays on disk using zarr for efficient storage and access.
103
158
 
104
159
  Zarr provides a simpler and more efficient alternative to np.memmap with better compression
@@ -112,6 +167,7 @@ def array_to_disk(
112
167
  tuple[zarr.Array, str, int]: The zarr array, the directory path, and the total size in bytes
113
168
 
114
169
  Examples:
170
+ >>> import numpy as np
115
171
  >>> data = np.random.rand(1000, 1000)
116
172
  >>> zarr_array = array_to_disk(data)[0]
117
173
  >>> zarr_array.shape
@@ -127,6 +183,9 @@ def array_to_disk(
127
183
  for filename in filenames
128
184
  )
129
185
 
186
+ # Imports
187
+ import zarr # pyright: ignore[reportMissingTypeStubs]
188
+
130
189
  # If data is already a zarr.Array and more_data is present, just append and return
131
190
  if isinstance(data, zarr.Array) and more_data is not None:
132
191
  original_size: int = data.shape[0]
@@ -1,3 +1,4 @@
1
+ import polars as pl
1
2
  import zarr
2
3
  from numpy.typing import NDArray as NDArray
3
4
  from typing import Any, Literal, TypeVar
@@ -49,7 +50,17 @@ def sort_dict_keys(dictionary: dict[T, Any], order: list[T], reverse: bool = Fal
49
50
  \t\t>>> sort_dict_keys({\'b\': 2, \'a\': 1, \'c\': 3, \'d\': 4}, order=["c", "b"])
50
51
  \t\t{\'c\': 3, \'b\': 2, \'a\': 1, \'d\': 4}
51
52
  \t'''
52
- def array_to_disk(data: NDArray[Any] | zarr.Array, delete_input: bool = True, more_data: NDArray[Any] | zarr.Array | None = None) -> tuple[zarr.Array, str, int]:
53
+ def upsert_in_dataframe(df: pl.DataFrame, new_entry: dict[str, Any], primary_keys: dict[str, Any] | None = None) -> pl.DataFrame:
54
+ """ Insert or update a row in the Polars DataFrame based on primary keys.
55
+
56
+ \tArgs:
57
+ \t\tdf\t\t\t\t(pl.DataFrame):\t\tThe Polars DataFrame to update.
58
+ \t\tnew_entry\t\t(dict[str, Any]):\tThe new entry to insert or update.
59
+ \t\tprimary_keys\t(dict[str, Any]):\tThe primary keys to identify the row (default: empty).
60
+ \tReturns:
61
+ \t\tpl.DataFrame: The updated Polars DataFrame.
62
+ \t"""
63
+ def array_to_disk(data: NDArray[Any] | zarr.Array, delete_input: bool = True, more_data: NDArray[Any] | zarr.Array | None = None) -> tuple['zarr.Array', str, int]:
53
64
  """ Easily handle large numpy arrays on disk using zarr for efficient storage and access.
54
65
 
55
66
  \tZarr provides a simpler and more efficient alternative to np.memmap with better compression
@@ -63,6 +74,7 @@ def array_to_disk(data: NDArray[Any] | zarr.Array, delete_input: bool = True, mo
63
74
  \t\ttuple[zarr.Array, str, int]: The zarr array, the directory path, and the total size in bytes
64
75
 
65
76
  \tExamples:
77
+ \t\t>>> import numpy as np
66
78
  \t\t>>> data = np.random.rand(1000, 1000)
67
79
  \t\t>>> zarr_array = array_to_disk(data)[0]
68
80
  \t\t>>> zarr_array.shape
@@ -4,15 +4,15 @@ It is mainly used by the `stouputils.continuous_delivery.github` module.
4
4
 
5
5
  # Imports
6
6
  import os
7
- from typing import Any
8
-
9
- import requests
10
- import yaml
7
+ from typing import TYPE_CHECKING, Any
11
8
 
12
9
  from ..decorators import handle_error
13
10
  from ..io import clean_path, super_json_load
14
11
  from ..print import warning
15
12
 
13
+ if TYPE_CHECKING:
14
+ import requests
15
+
16
16
 
17
17
  # Load credentials from file
18
18
  @handle_error()
@@ -63,6 +63,7 @@ def load_credentials(credentials_path: str) -> dict[str, Any]:
63
63
 
64
64
  # Else, load the file if it's a YAML file
65
65
  elif credentials_path.endswith((".yml", ".yaml")):
66
+ import yaml
66
67
  with open(credentials_path) as f:
67
68
  return yaml.safe_load(f)
68
69
 
@@ -71,7 +72,7 @@ def load_credentials(credentials_path: str) -> dict[str, Any]:
71
72
  raise ValueError("Credentials file must be .json or .yml format")
72
73
 
73
74
  # Handle a response
74
- def handle_response(response: requests.Response, error_message: str) -> None:
75
+ def handle_response(response: "requests.Response", error_message: str) -> None:
75
76
  """ Handle a response from the API by raising an error if the response is not successful (status code not in 200-299).
76
77
 
77
78
  Args:
@@ -79,6 +80,7 @@ def handle_response(response: requests.Response, error_message: str) -> None:
79
80
  error_message (str): The error message to raise if the response is not successful
80
81
  """
81
82
  if response.status_code < 200 or response.status_code >= 300:
83
+ import requests
82
84
  try:
83
85
  raise ValueError(f"{error_message}, response code {response.status_code} with response {response.json()}")
84
86
  except requests.exceptions.JSONDecodeError as e:
@@ -11,8 +11,6 @@
11
11
  import os
12
12
  from typing import Any
13
13
 
14
- import requests
15
-
16
14
  from ..decorators import handle_error, measure_time
17
15
  from ..io import clean_path
18
16
  from ..print import info, progress, warning
@@ -122,6 +120,7 @@ def handle_existing_tag(owner: str, project_name: str, version: str, headers: di
122
120
  bool: True if the tag was deleted or if it was not found, False otherwise
123
121
  """
124
122
  # Get the tag URL and check if it exists
123
+ import requests
125
124
  tag_url: str = f"{PROJECT_ENDPOINT}/{owner}/{project_name}/git/refs/tags/v{version}"
126
125
  response: requests.Response = requests.get(tag_url, headers=headers)
127
126
 
@@ -146,6 +145,7 @@ def delete_existing_release(owner: str, project_name: str, version: str, headers
146
145
  headers (dict[str, str]): Headers for GitHub API requests
147
146
  """
148
147
  # Get the release URL and check if it exists
148
+ import requests
149
149
  releases_url: str = f"{PROJECT_ENDPOINT}/{owner}/{project_name}/releases/tags/v{version}"
150
150
  release_response: requests.Response = requests.get(releases_url, headers=headers)
151
151
 
@@ -166,6 +166,7 @@ def delete_existing_tag(tag_url: str, headers: dict[str, str]) -> None:
166
166
  tag_url (str): URL of the tag to delete
167
167
  headers (dict[str, str]): Headers for GitHub API requests
168
168
  """
169
+ import requests
169
170
  delete_response: requests.Response = requests.delete(tag_url, headers=headers)
170
171
  handle_response(delete_response, "Failed to delete existing tag")
171
172
  info("Deleted existing tag")
@@ -185,6 +186,7 @@ def get_latest_tag(
185
186
  str|None: Version number of the latest tag, None if no tags exist
186
187
  """
187
188
  # Get the tags list
189
+ import requests
188
190
  tags_url: str = f"{PROJECT_ENDPOINT}/{owner}/{project_name}/tags"
189
191
  response = requests.get(tags_url, headers=headers)
190
192
  handle_response(response, "Failed to get tags")
@@ -214,6 +216,7 @@ def get_commits_since_tag(
214
216
  list[dict]: List of commits since the last tag
215
217
  """
216
218
  # Get the commits URL and parameters
219
+ import requests
217
220
  commits_url: str = f"{PROJECT_ENDPOINT}/{owner}/{project_name}/commits"
218
221
  commits_params: dict[str, str] = {"per_page": "100"}
219
222
 
@@ -358,6 +361,7 @@ def create_tag(owner: str, project_name: str, version: str, headers: dict[str, s
358
361
  headers (dict[str, str]): Headers for GitHub API requests
359
362
  """
360
363
  # Message and prepare urls
364
+ import requests
361
365
  progress(f"Creating tag v{version}")
362
366
  create_tag_url: str = f"{PROJECT_ENDPOINT}/{owner}/{project_name}/git/refs"
363
367
  latest_commit_url: str = f"{PROJECT_ENDPOINT}/{owner}/{project_name}/git/refs/heads/main"
@@ -388,6 +392,7 @@ def create_release(owner: str, project_name: str, version: str, changelog: str,
388
392
  int: ID of the created release
389
393
  """
390
394
  # Message and prepare urls
395
+ import requests
391
396
  progress(f"Creating release v{version}")
392
397
  release_url: str = f"{PROJECT_ENDPOINT}/{owner}/{project_name}/releases"
393
398
  release_data: dict[str, str|bool] = {
@@ -425,6 +430,7 @@ def upload_assets(
425
430
  progress("Uploading assets")
426
431
 
427
432
  # Get the release details
433
+ import requests
428
434
  release_url: str = f"{PROJECT_ENDPOINT}/{owner}/{project_name}/releases/{release_id}"
429
435
  response: requests.Response = requests.get(release_url, headers=headers)
430
436
  handle_response(response, "Failed to get release details")
@@ -483,6 +489,8 @@ def upload_to_github(credentials: dict[str, Any], github_config: dict[str, Any])
483
489
  }
484
490
  )
485
491
  """
492
+ import requests # type: ignore # noqa: F401
493
+
486
494
  # Validate credentials and configuration
487
495
  owner, headers = validate_credentials(credentials)
488
496
  project_name, version, build_folder, endswith = validate_config(github_config)
@@ -17,8 +17,6 @@ writing, version management and TOML formatting capabilities.
17
17
  # Imports
18
18
  from typing import Any
19
19
 
20
- import toml
21
-
22
20
  from ..io import super_open
23
21
 
24
22
 
@@ -31,6 +29,7 @@ def read_pyproject(pyproject_path: str) -> dict[str, Any]:
31
29
  Returns:
32
30
  dict[str, Any]: The content of the pyproject.toml file.
33
31
  """
32
+ import toml
34
33
  return toml.load(pyproject_path)
35
34
 
36
35
 
@@ -81,6 +80,7 @@ def format_toml_lists(content: str) -> str:
81
80
 
82
81
  def write_pyproject(pyproject_path: str, pyproject_content: dict[str, Any]) -> None:
83
82
  """ Write to the pyproject.toml file with properly indented lists. """
83
+ import toml
84
84
  content: str = "\n" + toml.dumps(pyproject_content) + "\n"
85
85
  content = format_toml_lists(content) # Apply formatting
86
86