Skip to content

feat: add dynamic url info#998

Open
Pablu23 wants to merge 10 commits into
mainfrom
feat-add-dynamic-url-info
Open

feat: add dynamic url info#998
Pablu23 wants to merge 10 commits into
mainfrom
feat-add-dynamic-url-info

Conversation

@Pablu23

@Pablu23 Pablu23 commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Description

  • Briefly summarize your changes in a few bullet points (can and should correspond to CHANGELOG.md)
  • Relates to #XXX (insert issue number here), if there is a corresponding GH issue

Assignee

  • The changes adhere to the contribution guidelines
  • I have performed a self-review of my code
  • My changes generate no new warnings (e.g. flake8/mypy/pytest/...) other than deprecations

Documentation

Code Quality

  • Patch test coverage > 95% and does not decrease
  • New code uses correct & specific type hints

How did you verify that the changes work in practice?

  • Ran tests

Reviewer


The rendered docs for this PR can be found here.


The rendered docs for this PR can be found here.


The rendered docs for this PR can be found here.

@Pablu23 Pablu23 self-assigned this Jul 22, 2026
@Pablu23 Pablu23 changed the title Feat add dynamic url info feat: add dynamic url info Jul 22, 2026
Comment thread logprep/abc/getter.py Outdated
Comment thread logprep/processor/generic_adder/processor.py Outdated
Comment thread logprep/abc/getter.py Outdated
super().setup()
for rule in self.rules:
rule = typing.cast(GenericAdderRule, rule)
rule.init_generic_adder(self._job_tag_for_cleanup)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we really need this external init and would like to avoid it. The list_comparison has it, as the list_search_base_path comes from the processor and is relevant for the function of the rule. Here rule could generate it's own job tag, couldn't it?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we really need this external init and would like to avoid it. The list_comparison has it, as the list_search_base_path comes from the processor and is relevant for the function of the rule. Here rule could generate it's own job tag, couldn't it?

Yes we do, I forgot to add the _shut_down function here, this makes it clearer why we need to init here

@mhoff mhoff Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mh, I see where you are coming from. Alright, we can keep this for consistency with other processors (namely list_comparison).

But I still think that the job_tag and managing callbacks is rather an implementation detail of the rule, which it should handle itself. I think it would be consequential, that processor.setup() calls rule.setup() and processor.shut_down() calls rule.shut_down(), whereas managing callbacks is completely handled by the rule.

Currently we are calling an init (which has setup-like semantics) on the rule but basically handle the shutdown on the processor-level, which is inconsistent.

Comment thread logprep/processor/generic_adder/rule.py Outdated
Comment thread logprep/processor/generic_adder/rule.py
Comment thread logprep/processor/generic_adder/rule.py Outdated
Comment thread logprep/processor/generic_adder/rule.py Outdated
Comment thread tests/unit/processor/generic_adder/test_generic_adder.py Outdated
Comment thread logprep/processor/generic_adder/rule.py
Comment thread logprep/processor/generic_adder/rule.py Outdated
from logprep.util.defaults import ENV_NAME_LOGPREP_GETTER_CONFIG
from logprep.util.getter import HttpGetter


Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test_cases and failure_test_cases would be nice here as well. I figure that this is a scope creep; so probably we drop it for this PR

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test_cases and failure_test_cases would be nice here as well. I figure that this is a scope creep; so probably we drop it for this PR

Yes thats right, but I would rather have this be in another PR / task of itself

@Pablu23
Pablu23 force-pushed the feat-add-dynamic-url-info branch from e0b8071 to 1ab8eeb Compare July 23, 2026 12:06
Comment thread logprep/abc/getter.py
Comment thread logprep/ng/processor/generic_adder/processor.py Outdated
Comment thread logprep/processor/generic_adder/processor.py Outdated
Comment thread logprep/ng/processor/generic_adder/processor.py Outdated
Comment thread logprep/processor/generic_adder/rule.py
Comment on lines +127 to +129
def __attrs_post_init__(self) -> None:
if not self.target_field and not self.target_field_mapping:
raise ValueError("adding values from url requires target_field or target_field_mapping")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is does not have a super class, but we need to ensure all derived classes actually call super attrs_post_init. I wonder if we can just always have it (even for non-derived classes), but I have not tried it and out this might throw an error. Try it out if you feel like it, otherwise resolve as a no-op.

Suggested change
def __attrs_post_init__(self) -> None:
if not self.target_field and not self.target_field_mapping:
raise ValueError("adding values from url requires target_field or target_field_mapping")
def __attrs_post_init__(self) -> None:
super().__attrs_post_init__()
if not self.target_field and not self.target_field_mapping:
raise ValueError("adding values from url requires target_field or target_field_mapping")

Comment thread logprep/processor/generic_adder/rule.py
@@ -160,20 +213,47 @@ def _refresh_add(self):
def __attrs_post_init__(self):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super needs to be called here

Comment on lines +248 to +249
# TODO: This never gets cleaned up, Memory leak on a lot of new generic adders / generic resolvers
getter.add_callback(f"generic_adder:{self.id}:{add_file}", self._refresh_add)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have the job_tag now and can resolve this properly

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not here we dont, because that is the rule config and gets loaded on config time, we dont pass in the job tag, but I guess I could just change that with a private _callback_tag on the config, pass that into the rule from the processor and then also remove the init because now the rule knows the callback tag?

Comment thread logprep/processor/generic_adder/rule.py Outdated
Comment thread logprep/processor/generic_adder/rule.py Outdated
Comment thread logprep/processor/generic_adder/rule.py Outdated
Comment thread logprep/processor/generic_adder/rule.py Outdated
Comment thread logprep/processor/generic_adder/rule.py Outdated
Comment thread logprep/processor/generic_adder/rule.py Outdated
Comment thread logprep/processor/generic_adder/rule.py Outdated
Comment thread logprep/processor/generic_adder/rule.py Outdated
Comment thread logprep/processor/generic_adder/rule.py Outdated
Comment thread logprep/processor/generic_adder/rule.py Outdated
mapping_source_field,
mapping_target_field,
)
continue

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we stick to this, this might be a case for a processor warning

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants