-
Notifications
You must be signed in to change notification settings - Fork 67
Changes for BoefjeScheduler to support deduplication
#4309
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
Changes from 2 commits
8c01058
ca006ce
2d9008d
c2531ad
ea2250c
164e4e2
d2913dd
3bd4c0e
8171700
923cd43
8a9ed33
1a9abf4
bd7f34b
687a9b2
7f8d5a2
ef52396
b5308f7
abb00eb
3cf78ad
fb83669
f40d7c0
26898be
4181f30
215f995
35d7d64
a2fbbc5
e17d619
8f9dad9
17d65d6
6502e8a
fda531d
edf9c48
da55ba4
ef1f689
e031f60
176195f
bb57fa2
ad74040
299db50
28f4400
0cc91b7
e848223
76e0b76
e8f9b76
ef4b382
6e65e9f
078d2ec
3bb3101
ff7338a
7b6ad15
744d02e
1535c37
7b21ac8
beddd9a
b7c8c66
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -402,6 +402,35 @@ def push_boefje_task( | |
| task_db.status = models.TaskStatus.FAILED | ||
| self.ctx.datastores.task_store.update_task(task_db) | ||
|
|
||
| # Is the ooi in other organisations? When the ooi is in other | ||
| # organisations we need to create tasks for those organisations as well. | ||
| if boefje_task.input_ooi is not None: | ||
| # FIXME: is the ooi shared between organisations, or is it a copy? | ||
| # If it is a copy we need to use the ooi id in the boefje task. | ||
| orgs = self.is_ooi_in_other_organisations(boefje_task.input_ooi) | ||
| if orgs: | ||
| boefje_task.organizations = orgs | ||
|
|
||
| # FIXME: what if boefje is disabled in the other org? Are we sure | ||
| # that in that org the boefje is allowed to scan the ooi? | ||
| # FIXME: what status do we give it do we give it completed, we | ||
|
||
| # can't make it queued since it shouldn't be picked up by | ||
| # the task runner. | ||
| # FIXME: how to these tasks get associated with the other raw files? | ||
|
||
| for org in orgs: | ||
| boefje_task.id = uuid.uuid4() | ||
| boefje_task.organization = org | ||
|
|
||
| task = models.Task( | ||
| id=boefje_task.id, | ||
| scheduler_id=self.scheduler_id, | ||
| organisation=org, | ||
| status=models.TaskStatus.COMPLETED, | ||
| hash=boefje_task.hash, | ||
| data=boefje_task.model_dump(), | ||
| ) | ||
| self.ctx.datastores.task_store.create_task(task) | ||
|
|
||
| task = models.Task( | ||
| id=boefje_task.id, | ||
| scheduler_id=self.scheduler_id, | ||
|
|
@@ -685,6 +714,38 @@ def get_oois_for_boefje(self, boefje: models.Plugin, organisation: str) -> list[ | |
|
|
||
| return oois | ||
|
|
||
| def is_ooi_in_other_organisations(self, ooi: models.OOI) -> list[str] | None: | ||
| """Check if the OOI is in other organisations. | ||
|
|
||
| Args: | ||
| ooi: The OOI to check. | ||
|
|
||
| Returns: | ||
| A list of organisations that have the same OOI. | ||
| """ | ||
| organisations = None | ||
| try: | ||
| organisations = self.ctx.services.octopoes.get_organisations_by_ooi(ooi) | ||
| except ExternalServiceError: | ||
| self.logger.exception( | ||
| "Error occurred while checking if OOI is in other organisations", | ||
| ooi_primary_key=ooi.primary_key, | ||
| scheduler_id=self.scheduler_id, | ||
| ) | ||
| return None | ||
|
|
||
| return organisations | ||
|
|
||
| # TODO: implement this method | ||
| def get_organisations_for_same_task(self) -> list[str] | None: | ||
| """Get the organisations that have the same task. | ||
|
|
||
| Returns: | ||
| A list of organisations that have the same task. | ||
| """ | ||
| organisations = None | ||
| return organisations | ||
|
|
||
| def calculate_deadline(self, schedule: models.Schedule) -> models.Schedule: | ||
| """Override Scheduler.calculate_deadline() to calculate the deadline | ||
| for a task and based on the boefje interval.""" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OOI information is not shared between orga's. However, since they are the same (by primary key) most of their information is exactly the same. Small differences might still exists in properties that are present on the OOI but which are not used in the primary_key