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

Resource file path from simulation #1410

Open
wants to merge 49 commits into
base: master
Choose a base branch
from

Conversation

jkumwenda
Copy link
Collaborator

Created resource file path function and calling it from different modules.

@jkumwenda jkumwenda linked an issue Jul 2, 2024 that may be closed by this pull request
5 tasks
@@ -44,7 +44,7 @@ class Simulation:
"""

def __init__(self, *, start_date: Date, seed: int = None, log_config: dict = None,
show_progress_bar=False):
show_progress_bar=False, resourcefilepath = None):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add str type hint to resourcefilepath.

@@ -80,6 +81,7 @@ def __init__(self, *, start_date: Date, seed: int = None, log_config: dict = Non
data=f'Simulation RNG {seed_from} entropy = {self._seed_seq.entropy}'
)
self.rng = np.random.RandomState(np.random.MT19937(self._seed_seq))
self.resourcefilepath = resourcefilepath
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here, we could convert and store Path type and check that path exists.

thewati and others added 20 commits July 30, 2024 15:50
…tate cancer, fixed test equipment and dxmanager
…t.py and breast_cancer.py method updated for resource file path from simulation.py
…t.py and breast_cancer.py method updated for resource file path from simulation.py
…t.py isort the import to fix incorrectly sorted error
@thewati
Copy link
Collaborator

thewati commented Oct 2, 2024

Is there anyone who has an idea how I can solve this problem. Whenever I run scripts/hiv/batch_test_runs.py, I am
getting a file not found error. My path is getting mixed up with a path to ResourceFile_Demography_parameters.csv.
Can't pinpoint where these two paths are getting concatenated. The paths are C:\\Users\\User\\PycharmProjects\\TLOmodel\\src\\scripts\\hiv\\projections_jan2023\\batch_test_runs.py and demography\\ResourceFile_Demography_parameters.csv

@thewati thewati requested a review from mnjowe October 7, 2024 07:06
@tbhallett tbhallett requested a review from tamuri October 7, 2024 13:41
Copy link
Collaborator

@tbhallett tbhallett left a comment

Choose a reason for hiding this comment

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

Well done!!! This seems to do the job, and with a minimum if invasiveness! Thank you.

See a couple of comments/queries.

src/tlo/methods/epi.py Show resolved Hide resolved
Comment on lines 396 to 403
logger.info(key="message", data=f"Running draw {sample['draw_number']}, sample {sample['sample_number']}")

sim = Simulation(
start_date=self.scenario.start_date,
seed=sample["simulation_seed"],
log_config=log_config,
resourcefilepath=self.scenario.scenario_path)

Copy link
Collaborator

Choose a reason for hiding this comment

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

confused about the need for these changes? Should they be on this PR?!?!

Copy link
Collaborator

Choose a reason for hiding this comment

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

I was mostly following the Simulation objects to make changes to them wherever they are... If this change is not necessary for this PR, I can rollback

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah if it's not necessary for the PR, then I think it's best to roll it back.

src/tlo/scenario.py Outdated Show resolved Hide resolved
def __init__(
self,
*,
start_date: Date,
seed: Optional[int] = None,
log_config: Optional[dict] = None,
show_progress_bar: bool = False,
resourcefilepath: Optional[Path] = None,
resourcefilepath: str = None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
resourcefilepath: str = None,
resourcefilepath: Optional[str|Path] = None,

Copy link
Collaborator

@tbhallett tbhallett left a comment

Choose a reason for hiding this comment

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

Thanks Wati and Joel. This all seems very good to me.

@tbhallett
Copy link
Collaborator

@tamuri and @matt-graham -- this looks ready to go, from my perspective

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Ready to merge
Development

Successfully merging this pull request may close these issues.

Get resource file path from simulation
5 participants