kaizenflow icon indicating copy to clipboard operation
kaizenflow copied to clipboard

Unit test log_experiment_data.py

Open sonaalKant opened this issue 1 year ago • 5 comments

Let's mock the interaction with the database at the level of returning a tuple as the database would

  • the goal here is to confirm that the data is saved correctly to the file

We would like to create unit tests for https://github.com/kaizen-ai/kaizenflow/blob/a7952ef84cc2ebe93042ccc481486e6ef66ca292/im_v2/ccxt/db/log_experiment_data.py#L31

Steps:

  • Create new file im_v2/ccxt/db/test/test_log_experiment_data.py
  • You will have to mock the load_db_data to return some artificial bid_ask data https://github.com/kaizen-ai/kaizenflow/blob/a7952ef84cc2ebe93042ccc481486e6ef66ca292/im_v2/common/data/client/im_raw_data_client.py#L182
  • Load back the data and verify if it is done correctly.

FYI @samarth9008

sonaalKant avatar May 07 '24 22:05 sonaalKant

Created a draft PR for review of task progress.

aish-nidhi avatar May 08 '24 18:05 aish-nidhi

While trying to run the test and resolve the error for draft PR, I have been facing issues. I was following the code that raises the following error :-

im_v2/ccxt/db/test/test_log_experiment_data.py::TestLogExperimentData::test_log_experiment_data SKIPPED (Need docker children / sibling support and/or Run only if CK S3 is available)

Not sure why the check for macOS version is specified as Ventura and Monterey. But my mac is on latest version Sonoma(Version 14.4.1). Should I add it for my local to run the test and continue?

aish-nidhi avatar May 08 '24 21:05 aish-nidhi

Continued to resolve above issue on my local. Facing a different issue while the configuration of child docker container.

ERROR im_v2/ccxt/db/test/test_log_experiment_data.py::TestLogExperimentData::test_log_experiment_data - RuntimeError: cmd='(sudo docker-compose --file /app/im_v2/devops/compose/docker-compose_4716.yml --env-file /app/im_v2/devops/env/local.im_db_config_4716.env up -d im_postgres4716) 2>&1' failed with rc='1'

aish-nidhi avatar May 08 '24 21:05 aish-nidhi

Update :- Searched for docs and code to resolve the test run issue. Reached out to @sonaalKant for guidance on finding solution for the issue. Tried various hacks on local to run the test including environment and code modifications.

Found another issue with similar context #707 during search. Also, found a link for docker sibling container in docker how to guide given below and implemented it, but to no avail.

Sibling Container Approach

aish-nidhi avatar May 09 '24 23:05 aish-nidhi

I guess you won't be able to proceed further, you can pause on this issue, will update you. Good job trying things out yourself though.

sonaalKant avatar May 10 '24 01:05 sonaalKant

Can't be done on kaizen side, closing

samarth9008 avatar May 29 '24 13:05 samarth9008