Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions All.sln
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "misc", "misc", "{2918C7E3-3
Ficus\Readme.md = Ficus\Readme.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Salve", "Salve", "{BA9BD6EC-204D-40AA-86A7-E70087EB9A1D}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UtilProjects", "UtilProjects", "{5EB4BB7D-E983-489E-A220-C99610C5FF01}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Salve", "Salve\Salve.csproj", "{11FB9788-D067-4AD5-A17D-4685DE9DD366}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Salve", "util_projects\Salve\Salve.csproj", "{A3A62DBD-B92F-46F2-9104-F39A6E606148}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -242,10 +242,10 @@ Global
{1BBDEB95-1084-4981-AE5A-EFFC74E095E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1BBDEB95-1084-4981-AE5A-EFFC74E095E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1BBDEB95-1084-4981-AE5A-EFFC74E095E4}.Release|Any CPU.Build.0 = Release|Any CPU
{11FB9788-D067-4AD5-A17D-4685DE9DD366}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{11FB9788-D067-4AD5-A17D-4685DE9DD366}.Debug|Any CPU.Build.0 = Debug|Any CPU
{11FB9788-D067-4AD5-A17D-4685DE9DD366}.Release|Any CPU.ActiveCfg = Release|Any CPU
{11FB9788-D067-4AD5-A17D-4685DE9DD366}.Release|Any CPU.Build.0 = Release|Any CPU
{A3A62DBD-B92F-46F2-9104-F39A6E606148}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A3A62DBD-B92F-46F2-9104-F39A6E606148}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A3A62DBD-B92F-46F2-9104-F39A6E606148}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A3A62DBD-B92F-46F2-9104-F39A6E606148}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{FEF48EF9-EDFC-4464-8942-64FC9FF000CA} = {C3E829BA-4C31-4F55-BF4D-C0D11B0B70B4}
Expand Down Expand Up @@ -285,6 +285,6 @@ Global
{B1223284-182E-4C3A-92CD-F59FBD42FFD6} = {0EC07BD3-AB92-48A0-B68B-05B3F2A767A3}
{1BBDEB95-1084-4981-AE5A-EFFC74E095E4} = {D50BD31E-296B-468E-817A-60AF1CE7A759}
{2918C7E3-3FC8-48A5-ADDF-8358E888B40C} = {5F2E0AEA-6AAF-4130-B486-A5F4F5A8A4BD}
{11FB9788-D067-4AD5-A17D-4685DE9DD366} = {BA9BD6EC-204D-40AA-86A7-E70087EB9A1D}
{A3A62DBD-B92F-46F2-9104-F39A6E606148} = {5EB4BB7D-E983-489E-A220-C99610C5FF01}
EndGlobalSection
EndGlobal
2 changes: 1 addition & 1 deletion Ficus/src/python/ficus/grpc_pipelines/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
const_abstract_timeline_diagram = 'AbstractTimelineDiagram'
const_clusterize_traces_k_means_grid_search = 'ClusterizeLogTracesKMeansGridSearch'
const_clusterize_traces_dbscan_grid_search = 'ClusterizeLogTracesDbscanGridSearch'
const_discover_root_sequence_graph = 'DiscoverRootSequenceGraph'
const_discover_ecfg = 'DiscoverECFG'
const_discover_loops_strict = 'DiscoverLoopsStrict'
const_discover_traces_timeline_diagram = 'DiscoverTracesTimelineDiagram'

Expand Down
4 changes: 2 additions & 2 deletions Ficus/src/python/ficus/grpc_pipelines/discovery_parts.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ class DiscoverDirectlyFollowsGraphStream(PipelinePart):
def to_grpc_part(self) -> GrpcPipelinePartBase:
return _create_default_discovery_part(const_discover_directly_follows_graph_stream)

class DiscoverRootSequenceGraph(PipelinePart):
class DiscoverECFG(PipelinePart):
def __init__(self,
root_sequence_kind: RootSequenceKind = RootSequenceKind.FindBest,
merge_sequences_of_events: bool = True):
Expand All @@ -261,4 +261,4 @@ def to_grpc_part(self) -> GrpcPipelinePartBase:
append_root_sequence_kind(config, const_root_sequence_kind, self.root_sequence_kind)
append_bool_value(config, const_merge_sequences_of_events, self.merge_sequences_of_events)

return GrpcPipelinePartBase(defaultPart=create_default_pipeline_part(const_discover_root_sequence_graph, config))
return GrpcPipelinePartBase(defaultPart=create_default_pipeline_part(const_discover_ecfg, config))
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ def _execute_ocel_annotation_test(test_name: str, log_name: str, filter_parts: l

pipeline.parts.extend([
AddStartArtificialEvents(),
DiscoverRootSequenceGraph(root_sequence_kind=RootSequenceKind.FindBest,
merge_sequences_of_events=False),
DiscoverECFG(root_sequence_kind=RootSequenceKind.FindBest,
merge_sequences_of_events=False),
CreateDagOcelAnnotation(),
AssertCorrectOcelAnnotation(test_name)
])
Expand Down
20 changes: 12 additions & 8 deletions Ficus/src/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 1 addition & 12 deletions Ficus/src/rust/ficus/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[package]
name = "ficus"
version = "0.1.0"
edition = "2021"
build = "build.rs"
edition = "2024"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand All @@ -11,13 +10,8 @@ chrono = "0.4.42"
quick-xml = "0.29.0"
lazycell = "1.3"
tonic = "0.9.2"
prost = "0.11.9"
prost-types = "0.11.9"
tokio = { version = "1.49.0", features = ["rt-multi-thread"] }
futures = "0.3.31"
tokio-stream = "0.1.17"
rand = "0.8.5"
nameof = "1.3.0"
once_cell = "1.21.3"
fancy-regex = "0.11.0"
stopwatch = "0.0.7"
Expand All @@ -26,9 +20,7 @@ linfa-clustering = "0.7.1"
linfa-nn = "0.7.2"
ndarray = "0.15.6"
bxes = { path = "../../../../bxes/src/rust/bxes/" }
bxes_kafka = { path = "../../../../bxes/src/rust/bxes_kafka" }
lazy_static = "1.5.0"
rdkafka = { version = "0.36.2", features = ["cmake-build"] }
log = "0.4.29"
num-traits = "0.2.19"
approx = "0.5.1"
Expand All @@ -48,6 +40,3 @@ features = [
"fast-rng", # Use a faster (but still sufficiently random) RNG
"macro-diagnostics", # Enable better diagnostics for compile-time UUIDs
]

[build-dependencies]
tonic-build = "0.9.2"
20 changes: 11 additions & 9 deletions Ficus/src/rust/ficus/src/event_log/bxes/bxes_to_xes_converter.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::{cell::RefCell, collections::HashMap, rc::Rc};

use bxes::{
models::{
domain::{
Expand All @@ -15,6 +13,7 @@ use bxes::{
},
};
use chrono::{TimeZone, Utc};
use std::{cell::RefCell, collections::HashMap, fmt::Display, rc::Rc};

use super::conversions::{bxes_value_to_payload_value, global_type_to_string};
use crate::event_log::{
Expand All @@ -33,12 +32,15 @@ pub enum BxesToXesReadError {
ConversionError(String),
}

impl ToString for BxesToXesReadError {
fn to_string(&self) -> String {
match self {
BxesToXesReadError::BxesReadError(err) => err.to_string(),
BxesToXesReadError::ConversionError(err) => err.to_string(),
}
impl Display for BxesToXesReadError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(
match self {
BxesToXesReadError::BxesReadError(err) => err.to_string(),
BxesToXesReadError::ConversionError(err) => err.to_string(),
}
.as_str(),
)
}
}

Expand Down Expand Up @@ -197,7 +199,7 @@ fn create_xes_payload(
return Err(BxesToXesReadError::ConversionError(message));
};

payload.insert(key, bxes_value_to_payload_value(&value));
payload.insert(key, bxes_value_to_payload_value(value));
}

Ok(Some(payload))
Expand Down
2 changes: 1 addition & 1 deletion Ficus/src/rust/ficus/src/event_log/bxes/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub(super) fn payload_value_to_bxes_value(value: &EventPayloadValue) -> BxesValu
EventPayloadValue::Float64(value) => BxesValue::Float64(*value),
EventPayloadValue::Uint32(value) => BxesValue::Uint32(*value),
EventPayloadValue::Uint64(value) => BxesValue::Uint64(*value),
EventPayloadValue::Guid(value) => BxesValue::Guid(value.clone()),
EventPayloadValue::Guid(value) => BxesValue::Guid(*value),
EventPayloadValue::Timestamp(value) => BxesValue::Timestamp(*value),
EventPayloadValue::Lifecycle(lifecycle) => match convert_xes_to_bxes_lifecycle(lifecycle) {
bxes::models::domain::bxes_lifecycle::Lifecycle::Braf(braf) => BxesValue::BrafLifecycle(braf),
Expand Down
29 changes: 15 additions & 14 deletions Ficus/src/rust/ficus/src/event_log/bxes/xes_to_bxes_converter.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::rc::Rc;
use std::{fmt::Display, rc::Rc};

use super::conversions::{parse_entity_kind, payload_value_to_bxes_value};
use crate::event_log::{
Expand Down Expand Up @@ -30,12 +30,15 @@ pub enum XesToBxesWriterError {
ConversionError(String),
}

impl ToString for XesToBxesWriterError {
fn to_string(&self) -> String {
match self {
XesToBxesWriterError::BxesWriteError(err) => err.to_string(),
XesToBxesWriterError::ConversionError(err) => err.to_owned(),
}
impl Display for XesToBxesWriterError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(
match self {
XesToBxesWriterError::BxesWriteError(err) => err.to_string(),
XesToBxesWriterError::ConversionError(err) => err.to_owned(),
}
.as_str(),
)
}
}

Expand Down Expand Up @@ -94,20 +97,18 @@ fn create_bxes_traces(log: &XesEventLogImpl) -> Vec<BxesTraceVariant> {
}

fn create_bxes_event(log: &XesEventLogImpl, event: &XesEventImpl) -> BxesEvent {
let bxes_event = BxesEvent {
BxesEvent {
name: Rc::new(Box::new(BxesValue::String(event.name_pointer().clone()))),
timestamp: event.timestamp().timestamp_nanos_opt().expect("timestamp_nanos_opt"),
attributes: Some(
event
.ordered_payload()
.iter()
.filter(|kv| is_not_default_attribute(log, kv))
.map(|kv| kv_pair_to_bxes_pair(kv))
.map(kv_pair_to_bxes_pair)
.collect(),
),
};

bxes_event
}
}

fn is_not_default_attribute(log: &XesEventLogImpl, kv: &(&String, &EventPayloadValue)) -> bool {
Expand Down Expand Up @@ -138,7 +139,7 @@ fn create_bxes_classifiers(log: &XesEventLogImpl) -> Vec<BxesClassifier> {
}

fn create_bxes_extensions(log: &XesEventLogImpl) -> Vec<BxesExtension> {
log.extensions().iter().map(|e| convert_to_bxes_extension(e)).collect()
log.extensions().iter().map(convert_to_bxes_extension).collect()
}

fn convert_to_bxes_extension(e: &XesEventLogExtension) -> BxesExtension {
Expand All @@ -154,7 +155,7 @@ fn create_bxes_globals(log: &XesEventLogImpl) -> Result<Vec<BxesGlobal>, XesToBx
for xes_global in log.ordered_globals().iter() {
globals.push(BxesGlobal {
entity_kind: parse_entity_kind(xes_global.0.as_str())?,
globals: xes_global.1.iter().map(|kv| convert_to_bxes_global_attribute(kv)).collect(),
globals: xes_global.1.iter().map(convert_to_bxes_global_attribute).collect(),
})
}

Expand Down
4 changes: 2 additions & 2 deletions Ficus/src/rust/ficus/src/event_log/core/event/event_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl EventBase {
Self {
name,
timestamp,
user_data: UserDataImpl::new(),
user_data: Default::default(),
}
}
}
Expand All @@ -25,7 +25,7 @@ impl Clone for EventBase {
fn clone(&self) -> Self {
Self {
name: self.name.clone(),
timestamp: self.timestamp.clone(),
timestamp: self.timestamp,
user_data: self.user_data.clone(),
}
}
Expand Down
9 changes: 2 additions & 7 deletions Ficus/src/rust/ficus/src/event_log/core/event/event_hasher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,9 @@ where
fn hash(&self, event: &TEvent) -> u64;
}

#[derive(Default)]
pub struct NameEventHasher;

impl NameEventHasher {
pub fn new() -> Self {
Self {}
}
}

impl<TEvent> EventHasher<TEvent> for NameEventHasher
where
TEvent: Event,
Expand Down Expand Up @@ -59,7 +54,7 @@ where
}

impl RegexEventHasher {
pub fn new(regex: &String) -> Result<RegexEventHasher, Error> {
pub fn new(regex: &str) -> Result<RegexEventHasher, Error> {
match Regex::new(regex) {
Ok(regex) => Ok(RegexEventHasher { regex }),
Err(error) => Err(error),
Expand Down
18 changes: 7 additions & 11 deletions Ficus/src/rust/ficus/src/event_log/core/event/events_holder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ where
{
fn clone(&self) -> Self {
Self {
events: (&self.events)
.into_iter()
.map(|ptr| Rc::new(RefCell::new(ptr.borrow().clone())))
.collect(),
events: self.events.iter().map(|ptr| Rc::new(RefCell::new(ptr.borrow().clone()))).collect(),

events_sequence_info: LazyCell::new(),
events_positions: LazyCell::new(),
Expand Down Expand Up @@ -70,9 +67,10 @@ where
{
let mut new_events = vec![];
let events = &self.events;
for index in 0..events.len() {
if !predicate(&events[index].borrow()) {
new_events.push(events[index].clone())

for (index, event) in events.iter().enumerate() {
if !predicate(&event.borrow()) {
new_events.push(event.clone())
} else {
debug!("Removing event at index {}: {:?}", index, events[index].borrow())
}
Expand Down Expand Up @@ -164,19 +162,17 @@ impl EventsPositions {
TEvent: Event,
{
let mut positions = HashMap::new();
let mut index = 0;

for event in events.events() {
for (index, event) in events.events().iter().enumerate() {
add_to_list_in_map(&mut positions, event.borrow().name(), index);
index += 1;
}

EventsPositions { positions }
}
}

impl TraceEventsPositions for EventsPositions {
fn event_positions(&self, event_class: &String) -> Option<&Vec<usize>> {
fn event_positions(&self, event_class: &str) -> Option<&Vec<usize>> {
self.positions.get(event_class)
}
}
Loading
Loading