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

[BUG] TypeError: unsupported operand type(s) for +: 'datetime.date' and 'datetime.date' #22

Closed
verovaleros opened this issue Jul 31, 2023 · 1 comment · Fixed by #23
Closed
Labels
bug Something isn't working

Comments

@verovaleros
Copy link
Member

Describe the bug
Running AIP on the latest main/development throws the following error on the prioritise algorithms:

TypeError: unsupported operand type(s) for +: 'datetime.date' and 'datetime.date'

The error is caused by the following operation in the file lib/aip/models/prioritize.py:

knowledge = last_knowledge.groupby('orig').sum()

The error seems to be caused by the groupby().sum(), which tries to sum all columns in the grouped data, including the 'first_seen' and 'last_seen' columns, which are of type datetime.date.

To Reproduce

  1. Clone main repository
  2. Change dates from 2020 in various files to the dates where my Zeek data start
  3. Build container: docker build --build-arg uid=1000 --file etc/docker/Dockerfile --tag aip:latest .
  4. Run container: docker run --rm -v ${PWD}:/home/aip/AIP -v /opt/zeek/logs/:/home/aip/AIP/data/raw:ro -v ${PWD}/data/:/home/aip/AIP/data/:rw --name aip aip:latest bin/aip

Suggested solutions
One way to solve this would be to group by and sum all columns except those related with time:

cols_to_sum = ['flows', 'duration', 'bytes', 'packets', 'days_active',
               'mean_flows', 'mean_duration', 'mean_bytes', 'mean_packets']
knowledge = last_knowledge.groupby('orig')[cols_to_sum].sum()

The suggested modification seems to work in principle.

@verovaleros verovaleros added the bug Something isn't working label Jul 31, 2023
@verovaleros verovaleros linked a pull request Aug 1, 2023 that will close this issue
@verovaleros
Copy link
Member Author

Fixed in #23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant