Skip to content

Commit

Permalink
Merge dev into main
Browse files Browse the repository at this point in the history
  • Loading branch information
DinisCruz committed Jan 27, 2025
2 parents 00aa1e9 + 0eba724 commit fecfcf5
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 37 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci-pipeline__dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ 3.8.18, 3.9.19, 3.10.14, 3.11.9, 3.12.3 , ]
python-version: [ 3.9.21, 3.10.16, 3.11.11, 3.12.8, 3.13.1 ]
#[ 3.8.18, 3.9.19, 3.10.14, 3.11.9, 3.12.3 , ]
# [3.7.17, 3.13.0-beta.1 ] # poetry doesn't support: 3.7.17, and was hanging on the installation of 3.13.0-beta.1

steps:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Powerful Python util methods and classes that simplify common apis and tasks.

![Current Release](https://img.shields.io/badge/release-v2.17.0-blue)
![Current Release](https://img.shields.io/badge/release-v2.17.4-blue)
[![codecov](https://codecov.io/gh/owasp-sbot/OSBot-Utils/graph/badge.svg?token=GNVW0COX1N)](https://codecov.io/gh/owasp-sbot/OSBot-Utils)


Expand Down
24 changes: 12 additions & 12 deletions osbot_utils/helpers/flows/Flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@
import logging
import typing

from osbot_utils.helpers.Dependency_Manager import Dependency_Manager
from osbot_utils.type_safe.Type_Safe import Type_Safe
from osbot_utils.helpers.CFormat import CFormat, f_dark_grey, f_magenta, f_bold
from osbot_utils.helpers.flows.models.Flow_Run__Config import Flow_Run__Config
from osbot_utils.helpers.flows.Flow__Events import flow_events
from osbot_utils.helpers.flows.models.Flow_Run__Event_Data import Flow_Run__Event_Data
from osbot_utils.testing.Stdout import Stdout
from osbot_utils.utils.Misc import random_id, lower, time_now
from osbot_utils.utils.Python_Logger import Python_Logger
from osbot_utils.utils.Str import ansis_to_texts
from osbot_utils.utils.Threads import invoke_in_new_event_loop
from osbot_utils.helpers.Dependency_Manager import Dependency_Manager
from osbot_utils.type_safe.Type_Safe import Type_Safe
from osbot_utils.helpers.CFormat import CFormat, f_dark_grey, f_magenta, f_bold
from osbot_utils.helpers.flows.models.Flow_Run__Config import Flow_Run__Config
from osbot_utils.helpers.flows.Flow__Events import flow_events
from osbot_utils.helpers.flows.models.Flow_Run__Event_Data import Flow_Run__Event_Data
from osbot_utils.testing.Stdout import Stdout
from osbot_utils.utils.Misc import random_id, lower, time_now
from osbot_utils.utils.Python_Logger import Python_Logger
from osbot_utils.utils.Str import ansis_to_texts
from osbot_utils.utils.Threads import invoke_in_new_event_loop

FLOW__RANDOM_ID__PREFIX = 'flow_id__'
FLOW__RANDOM_NAME__PREFIX = 'flow_name__'
FLOW__LOGGING__LOG_FORMAT = '%(asctime)s.%(msecs)03d | %(levelname)-8s | %(message)s'
FLOW__LOGGING__DATE_FORMAT = '%H:%M:%S'



# todo: add flow duration
class Flow(Type_Safe):
captured_exec_logs : list
data : dict # dict available to the tasks to add and collect data
Expand Down
19 changes: 10 additions & 9 deletions osbot_utils/helpers/flows/Task.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import asyncio
import inspect
import typing

from osbot_utils.helpers.flows.models.Flow_Run__Event_Data import Flow_Run__Event_Data
from osbot_utils.utils.Misc import random_id, lower
from osbot_utils.helpers.Dependency_Manager import Dependency_Manager
from osbot_utils.helpers.flows.Flow__Events import flow_events
from osbot_utils.testing.Stdout import Stdout
from osbot_utils.helpers.CFormat import CFormat, f_dark_grey, f_red, f_blue, f_bold
from osbot_utils.type_safe.Type_Safe import Type_Safe
from osbot_utils.helpers.flows.Flow import Flow
from osbot_utils.helpers.flows.models.Flow_Run__Event_Data import Flow_Run__Event_Data
from osbot_utils.utils.Misc import random_id, lower
from osbot_utils.helpers.Dependency_Manager import Dependency_Manager
from osbot_utils.helpers.flows.Flow__Events import flow_events
from osbot_utils.testing.Stdout import Stdout
from osbot_utils.helpers.CFormat import CFormat, f_dark_grey, f_red, f_blue, f_bold
from osbot_utils.type_safe.Type_Safe import Type_Safe
from osbot_utils.helpers.flows.Flow import Flow

TASK__RANDOM_ID__PREFIX = 'task_id__'

# todo: add task duration

class Task(Type_Safe):
data : dict # dict available to the task to add and collect data
task_id : str
Expand Down
5 changes: 4 additions & 1 deletion osbot_utils/type_safe/steps/Type_Safe__Step__From_Json.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import types
from decimal import Decimal
from enum import EnumMeta
from osbot_utils.helpers.Obj_Id import Obj_Id
from osbot_utils.type_safe.Type_Safe import Type_Safe
from osbot_utils.type_safe.Type_Safe__List import Type_Safe__List
from osbot_utils.helpers.Random_Guid import Random_Guid
Expand Down Expand Up @@ -100,8 +101,10 @@ def deserialize_from_dict(self, _self, data, raise_on_not_found=False):
value = Random_Guid(value)
elif type_safe_annotations.obj_is_attribute_annotation_of_type(_self, key, Random_Guid_Short): # handle Random_Guid_Short
value = Random_Guid_Short(value)
elif type_safe_annotations.obj_is_attribute_annotation_of_type(_self, key, Timestamp_Now): # handle Timestamp_Now
elif type_safe_annotations.obj_is_attribute_annotation_of_type(_self, key, Timestamp_Now ): # handle Timestamp_Now
value = Timestamp_Now(value)
elif type_safe_annotations.obj_is_attribute_annotation_of_type(_self, key, Obj_Id ): # handle Obj_Id
value = Obj_Id(value)

setattr(_self, key, value) # Direct assignment for primitive types and other structures

Expand Down
2 changes: 1 addition & 1 deletion osbot_utils/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.17.0
v2.17.4
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "osbot_utils"
version = "v2.17.0"
version = "v2.17.4"
description = "OWASP Security Bot - Utils"
authors = ["Dinis Cruz <[email protected]>"]
license = "MIT"
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/helpers/test_Obj_Id.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ def test__perf__new__(self):

def test__perf__new_obj_id(self):
with Performance_Measure__Session() as _:
_.measure(lambda: new_obj_id() ).assert_time__less_than(300)
_.measure(lambda: is_obj_id('abc')).assert_time__less_than(300)
_.measure(lambda: new_obj_id() ).assert_time__less_than(500)
_.measure(lambda: is_obj_id('abc')).assert_time__less_than(500)
12 changes: 3 additions & 9 deletions tests/unit/utils/test_Process.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import sys
from unittest import TestCase
from unittest.mock import patch, call

import pytest

from osbot_utils.utils.Files import temp_file
from osbot_utils.utils.Process import Process, run_process, chmod_x, exec_open, stop_process
from unittest import TestCase
from unittest.mock import patch, call
from osbot_utils.utils.Process import run_process, exec_open, stop_process


class test_Process(TestCase):
Expand All @@ -17,8 +13,6 @@ class test_Process(TestCase):
# assert '-rwxr-xr-x' in run_process('ls', ['-la', temp_exe])['stdout']

def test_run(self):
if sys.version_info < (3, 8):
pytest.skip("Skipping test that doesn't work on 3.7 or lower")

assert run_process('echo', ['hello', 'world'])['stdout'] == 'hello world\n'
assert run_process('echo', 'hello world')['stdout'] == 'hello world\n'
Expand Down

0 comments on commit fecfcf5

Please sign in to comment.