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

ENH: Value in MDIO__IMPORT__CPU_COUNT does not get used for ingestion in a particular scenario #427

Open
amitpendharkar opened this issue Aug 21, 2024 · 1 comment

Comments

@amitpendharkar
Copy link

Issue

The value in environment variable MDIO__IMPORT__CPU_COUNT should be used to limit number of processed spawned by ProcessPoolExecutor. However, this value does not get used in a particular situation.

In following two scenarios, it get's used in scenario 1 but not in scenario 2.
Scenario 1:
Set the environment variable MDIO__IMPORT__CPU_COUNT and then run the script that invokes segy_to_mdio function : Works
E.g. Launch a pod with environment variable MDIO__IMPORT__CPU_COUNT already set and then run the script

Scenario 2:
Run the script, set environment variable MDIO__IMPORT__CPU_COUNT in that script and then invoke segy_to_mdio function : Does not work
E.g. Launch a pod. Use argument sent to the script to set the environment variable MDIO__IMPORT__CPU_COUNT in the script and then invoke the segy_to_mdio function

This happens because NUM_CPUS value gets updated when the code is loaded in memory before execution starts thus requiring environment variable to be set before running the script.

Suggested solution

Re-read the value of MDIO__IMPORT__CPU_COUNT just before following line and save it in NUM_CPUs. This will ensure that Scenario 2 would also work.

num_workers = min(num_chunks, NUM_CPUS)

@tasansal
Copy link
Collaborator

Hi Amit; thanks for sharing this. I'll try to find a more clean way that satisfies both.

In the meantime if you set it with os.environ before you import mdio functions it should still work for scenario 2. Can you please try and let me know?

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

No branches or pull requests

2 participants