Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DFP pipeline module #510

Merged
64 commits merged into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
1427674
dfp modules testing
bsuryadevara Nov 14, 2022
3d769ae
Merge branch 'nv-morpheus:branch-22.11' into dfp-training-module
bsuryadevara Nov 14, 2022
df5066b
modules stage work
bsuryadevara Nov 18, 2022
ebb2db8
Added module stage implementation
bsuryadevara Nov 22, 2022
c736828
morpehus modules integration
bsuryadevara Nov 22, 2022
1d12aee
trivial changes
bsuryadevara Nov 22, 2022
3376ca7
renamed configuration file
bsuryadevara Nov 23, 2022
4253d34
added tests
bsuryadevara Nov 28, 2022
b5ded8b
update module factory
bsuryadevara Nov 28, 2022
4b13b99
update module factory
bsuryadevara Nov 28, 2022
4789d23
Updated linear modules stage
bsuryadevara Nov 29, 2022
5cdfd68
Updated linear modules stage
bsuryadevara Nov 29, 2022
d15322a
Merge branch 'nv-morpheus:branch-23.01' into dfp-pipeline-module
bsuryadevara Nov 29, 2022
bea98a7
Updated linear modules stage
bsuryadevara Nov 29, 2022
5a4aa4a
Merge branch 'dfp-pipeline-module' of github.com:bsuryadevara/Morpheu…
bsuryadevara Nov 29, 2022
f0268b6
renamed mlflow model writer module
bsuryadevara Nov 29, 2022
25d1c5a
added functiontools wraps to a decorator func
bsuryadevara Nov 29, 2022
e4a73f2
created dfp pipeline preprocessing and training modules
bsuryadevara Nov 30, 2022
e5b770f
created dfp pipeline preprocessing and training modules
bsuryadevara Nov 30, 2022
1575fcd
created dfp pipeline preprocessing and training modules
bsuryadevara Nov 30, 2022
70fc4cf
created dfp pipeline preprocessing and training modules
bsuryadevara Nov 30, 2022
5159b0b
used dill to persist source and preprocess schema
bsuryadevara Nov 30, 2022
9619c0e
used dill to persist source and preprocess schema
bsuryadevara Nov 30, 2022
88d03b1
renamed files
bsuryadevara Dec 1, 2022
899df5c
Updated dfp pipleines with modules
bsuryadevara Dec 7, 2022
6a0bcdd
Added tests
bsuryadevara Dec 7, 2022
e85ee77
resolved merge conflicts
bsuryadevara Dec 7, 2022
dd9f2d2
created dfp (azure, duo) training pipelines with modules
bsuryadevara Dec 7, 2022
0bacf6e
style correction
bsuryadevara Dec 7, 2022
d9983dd
style correction
bsuryadevara Dec 7, 2022
2185886
style correction
bsuryadevara Dec 8, 2022
e50d1d1
added dask and distributed packages to requirements.txt
bsuryadevara Dec 8, 2022
4fdd4c9
Merge branch 'branch-23.01' into dfp-pipeline-module
bsuryadevara Dec 8, 2022
0e6d5cf
Resloved conflicts
bsuryadevara Dec 8, 2022
9158130
addedd missing tests file
bsuryadevara Dec 9, 2022
e0e7309
Merge remote-tracking branch 'upstream/branch-23.01' into dfp-pipelin…
bsuryadevara Dec 9, 2022
c91aa7f
fix to failing test
bsuryadevara Dec 10, 2022
a9d3e9e
fix to failing test
bsuryadevara Dec 10, 2022
516e746
fix tests
bsuryadevara Dec 10, 2022
bdf384a
addressed feedback comments
bsuryadevara Dec 13, 2022
c6c49a9
Update examples/digital_fingerprinting/production/morpheus/dfp_azure_…
bsuryadevara Dec 13, 2022
c93ac48
Update examples/digital_fingerprinting/production/morpheus/dfp_duo_mo…
bsuryadevara Dec 13, 2022
7e30dea
input and output port names from a module as params
bsuryadevara Dec 13, 2022
8aa84f5
Merge branch 'branch-23.01' into dfp-pipeline-module
bsuryadevara Dec 13, 2022
2fb7a5e
Update morpheus/stages/general/linear_modules_stage.py
bsuryadevara Dec 14, 2022
a4ce99e
Merge branch 'branch-23.01' into dfp-pipeline-module
bsuryadevara Dec 14, 2022
6e35679
updated readme, filenames
bsuryadevara Dec 15, 2022
7da7189
Merge branch 'branch-23.01' into dfp-pipeline-module
bsuryadevara Dec 15, 2022
ae9393b
Updated DFP readme.md
bsuryadevara Dec 15, 2022
4059466
Merge remote-tracking branch 'upstream/branch-23.01' into dfp-pipelin…
bsuryadevara Dec 20, 2022
2fc2916
moved from srf to mrc
bsuryadevara Dec 20, 2022
62149a7
Merge branch 'branch-23.01' into dfp-pipeline-module
bsuryadevara Jan 4, 2023
e0867c4
changes related to feedback
bsuryadevara Jan 18, 2023
c1af70a
Merge remote-tracking branch 'origin/branch-23.01' into dfp-pipeline-…
bsuryadevara Jan 18, 2023
0a98249
updated header and logging format
bsuryadevara Jan 18, 2023
dd8d69a
fix incomplete headers
bsuryadevara Jan 18, 2023
3d5e592
Removed commented code
bsuryadevara Jan 19, 2023
6d30b13
changed module fucntion name to align with filename
bsuryadevara Jan 23, 2023
31538f0
Merge branch 'dfp-pipeline-module' of https://github.com/bsuryadevara…
bsuryadevara Jan 23, 2023
b0a42b8
added distributed dependency to dfp example
bsuryadevara Jan 23, 2023
904a92e
Merge remote-tracking branch 'upstream/branch-23.01' into dfp-pipelin…
bsuryadevara Jan 23, 2023
ba56921
Merge branch-23.01 to dfp-pipeline-module
bsuryadevara Jan 23, 2023
6d6e030
Merge branch 'branch-23.01' into dfp-pipeline-module
bsuryadevara Jan 23, 2023
5af5813
resolved merge conflicts
bsuryadevara Jan 23, 2023
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
Prev Previous commit
Next Next commit
addedd missing tests file
  • Loading branch information
bsuryadevara committed Dec 9, 2022
commit 91581302ed4edddeb8d9692dd10c240069e6a729
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def make_dfp_training_module(module_id: str, namespace: str):
Namespace to virtually cluster the modules.
"""

@register_module(module_id=module_id, namespace=namespace)
@register_module(module_id, namespace)
def module_init(builder: srf.Builder):

config = builder.get_current_module_config()
Expand Down Expand Up @@ -109,7 +109,7 @@ def make_dfp_split_users_module(module_id: str, namespace: str):
Namespace to virtually cluster the modules.
"""

@register_module(module_id=module_id, namespace=namespace)
@register_module(module_id, namespace)
def module_init(builder: srf.Builder):
config = builder.get_current_module_config()

Expand Down Expand Up @@ -206,7 +206,7 @@ def make_dfp_rolling_window_module(module_id: str, namespace: str):
Namespace to virtually cluster the modules.
"""

@register_module(module_id=module_id, namespace=namespace)
@register_module(module_id, namespace)
def module_init(builder: srf.Builder):

config = builder.get_current_module_config()
Expand Down Expand Up @@ -336,7 +336,7 @@ def make_dfp_preporcessing_module(module_id: str, namespace: str):
Namespace to virtually cluster the modules.
"""

@register_module(module_id=module_id, namespace=namespace)
@register_module(module_id, namespace)
def module_init(builder: srf.Builder):

config = builder.get_current_module_config()
Expand Down
2 changes: 1 addition & 1 deletion morpheus/modules/file_batcher_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def make_file_batcher_module(module_id, namespace):
Namespace to virtually cluster the modules.
"""

@register_module(module_id=module_id, namespace=namespace)
@register_module(module_id, namespace)
def module_init(builder: srf.Builder):

TimestampFileObj = namedtuple("TimestampFileObj", ["timestamp", "file_object"])
Expand Down
2 changes: 1 addition & 1 deletion morpheus/modules/file_to_df_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def make_file_to_df_module(module_id, namespace):
Namespace to virtually cluster the modules.
"""

@register_module(module_id=module_id, namespace=namespace)
@register_module(module_id, namespace)
def module_init(builder: srf.Builder):

config = builder.get_current_module_config()
Expand Down
2 changes: 1 addition & 1 deletion morpheus/modules/mlflow_model_writer_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def make_mlflow_model_writer_module(module_id, namespace):
Namespace to virtually cluster the modules.
"""

@register_module(module_id=module_id, namespace=namespace)
@register_module(module_id, namespace)
def module_init(builder: srf.Builder):

config = builder.get_current_module_config()
Expand Down
10 changes: 5 additions & 5 deletions morpheus/modules/nested_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

import srf

from morpheus.utils.decorators import is_module_registered
from morpheus.utils.decorators import register_module
from morpheus.utils.decorators import verify_module_registration

logger = logging.getLogger(f"morpheus.{__name__}")

Expand All @@ -38,12 +38,12 @@ def make_nested_module(module_id: str, namespace: str, ordered_modules_meta: typ
The sequence in which the edges between the nodes are made will be determined by ordered modules meta.
"""

@is_module_registered
def is_module_exists(module_id=None, namespace=None):
@verify_module_registration
def verify_module_existance(module_id, namespace):
logger.debug("Registry contains module {} with namespace {}".format(module_id, namespace))
return True

@register_module(module_id=module_id, namespace=namespace)
@register_module(module_id, namespace)
def module_init(builder: srf.Builder):

config = builder.get_current_module_config()
Expand All @@ -62,7 +62,7 @@ def module_init(builder: srf.Builder):
# ________________________ ______
for x, y in ordered_modules_meta:

is_module_exists(module_id=x, namespace=y)
verify_module_existance(x, y)

curr_module = builder.load_module(x, y, module_id, config)

Expand Down
21 changes: 11 additions & 10 deletions morpheus/stages/general/linear_modules_stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from morpheus.config import Config
from morpheus.pipeline.single_port_stage import SinglePortStage
from morpheus.pipeline.stream_pair import StreamPair
from morpheus.utils.decorators import is_module_registered
from morpheus.utils.decorators import verify_module_registration

logger = logging.getLogger("morpheus.{}".format(__name__))

Expand Down Expand Up @@ -77,19 +77,20 @@ def accepted_types(self) -> typing.Tuple:
def _get_cpp_module_node(self, builder: srf.Builder) -> srf.SegmentObject:
raise NotImplementedError("No C++ node is available for this module type")

@is_module_registered
def _load_module(self, builder: srf.Builder, module_id: str, namespace: str, module_name: str):
def _build_single(self, builder: srf.Builder, input_stream: StreamPair) -> StreamPair:

module = builder.load_module(module_id, namespace, module_name, self._module_config)
@verify_module_registration
def load_module(module_id: str, namespace: str, module_name: str, builder: srf.Builder):

return module
module = builder.load_module(module_id, namespace, module_name, self._module_config)
logger.info("Module '{}' with namespace '{}' is successfully loaded.".format(module_id, namespace))

def _build_single(self, builder: srf.Builder, input_stream: StreamPair) -> StreamPair:
return module

module = self._load_module(builder=builder,
module_id=self._module_config["module_id"],
namespace=self._module_config["namespace"],
module_name=self._module_config["module_name"])
module = load_module(self._module_config["module_id"],
self._module_config["namespace"],
module_name=self._module_config["module_name"],
builder=builder)

mod_in_stream = module.input_port("input")
mod_out_stream = module.output_port("output")
Expand Down
28 changes: 13 additions & 15 deletions morpheus/utils/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
registry = srf.ModuleRegistry


def is_module_registered(func):
def verify_module_registration(func):
"""
Module availability in the module registry is verified by this function.

Expand All @@ -39,29 +39,29 @@ def is_module_registered(func):
"""

@functools.wraps(func)
def inner_func(*args, **kwargs):

module_id = kwargs["module_id"]
namespace = kwargs["namespace"]
def inner_func(module_id, namespace, **kwargs):

if module_id is None or namespace is None:
raise TypeError("TypeError: a string-like object is required for module_id and namespace, not 'NoneType'")

if not registry.contains(module_id, namespace):
raise Exception("Module {} doesn't exist in the namespace {}".format(module_id, namespace))
raise Exception("Module '{}' doesn't exist in the namespace '{}'".format(module_id, namespace))

return func(*args, **kwargs)
return func(module_id, namespace, **kwargs)

return inner_func


def register_module(**kwargs):
def register_module(module_id, namespace):
"""
Registers a module if not exists in the module registry.

Parameters
----------
**kwargs : Function arguments.
module_id : str
Unique identifier for a module in the module registry.
namespace : str
Namespace to virtually cluster the modules.

Returns
-------
Expand All @@ -70,15 +70,13 @@ def register_module(**kwargs):
"""

def inner_func(func):

module_id = kwargs["module_id"]
namespace = kwargs["namespace"]

# Register a module if not exists in the registry.
if not registry.contains(module_id, namespace):
registry.register_module(module_id, namespace, get_srf_version_as_list(), func)
logger.info("Module {} was successfully registered with {} namespace.".format(module_id, namespace))
logger.debug("Module '{}' was successfully registered with '{}' namespace.".format(module_id, namespace))
else:
logger.info("Module: {} already exists in the given namespace: {}".format(module_id, namespace))
logger.debug("Module: '{}' already exists in the given namespace '{}'".format(module_id, namespace))

return func

return inner_func
56 changes: 56 additions & 0 deletions tests/test_decorators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env python
# SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import pytest

from morpheus.utils.decorators import register_module
from morpheus.utils.decorators import verify_module_registration


def test_register_module():

@register_module("TestModule", "test_morpheus_modules")
def module_init():
return True

assert module_init()

# Attempting to register duplicate module raises an error.
with pytest.raises(TypeError):

@register_module(None, "test_morpheus_modules")
def module_init2():
pass

module_init2()


def test_verify_module_registration():

@verify_module_registration
def verify_module_existence(module_id, namespace):
return True

assert verify_module_existence("TestModule", "test_morpheus_modules")

with pytest.raises(TypeError):
verify_module_existence(None, "test_morpheus_modules")

with pytest.raises(Exception):
verify_module_existence("TestModule2", "test_morpheus_modules")

with pytest.raises(Exception):
verify_module_existence("TestModule", "default")