Skip to content

Refactor code for python package#18

Open
babsey wants to merge 67 commits intoINM-6:mainfrom
babsey:pyproject
Open

Refactor code for python package#18
babsey wants to merge 67 commits intoINM-6:mainfrom
babsey:pyproject

Conversation

@babsey
Copy link
Collaborator

@babsey babsey commented Mar 17, 2025

Refactoring Summary

This pull request implements a major reorganization of the repository to improve code structure, modularity, and maintainability. The main changes are:

  • Python Package Structure:
    All core simulation and analysis code is now structured as a Python package under src/humam/. This includes classes for network setup, simulation, and analysis, as well as parameter definitions and auxiliary scripts. Submodules are introduced for parameters, data loading, preprocessing, helpers, figures, theory, and workflow automation.

  • Separation of Publication Scripts:
    Scripts specifically used to generate figures for the publication have been moved to misc/publication_figures/, clearly separating them from the core simulation code.

  • Jupyter Notebook Updates:
    The main tutorial notebook (humam_tutorial.ipynb) has been updated to import from the new humam package, using consistent and clear import paths.

  • Workflow and File Organization:
    Snakemake workflow scripts are now located under src/humam/snakemake/. The Snakefile and other workflow definitions have been updated accordingly.
    .gitignore and documentation files (README.md, misc/README.md) are updated to reflect the new structure.

  • General Cleanup:
    Redundant scripts and files are either moved to appropriate subdirectories or removed. The overall repository layout is clarified, with directory structures and file responsibilities now better documented.

These changes enable easier installation and usage as a Python package, and clarify the distinction between reusable simulation tools and manuscript-specific scripts.

@babsey babsey requested a review from shimoura March 17, 2025 13:29
terhorstd
terhorstd previously approved these changes May 6, 2025
Copy link

@terhorstd terhorstd left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

@terhorstd terhorstd left a comment

Choose a reason for hiding this comment

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

Appologies, clicked the wrong accept button...

@terhorstd terhorstd dismissed their stale review May 6, 2025 16:30

approval was only for the visible subset of the last change

@terhorstd terhorstd self-requested a review May 6, 2025 16:31
@terhorstd
Copy link

This is getting quite a big PR. Could you add a description at the top to summarize in a few bullet-points what needed to change? Not the technical details, but structurally where things can be found after the merge, or which dev-features were added.

@shimoura
Copy link
Member

This is getting quite a big PR. Could you add a description at the top to summarize in a few bullet-points what needed to change? Not the technical details, but structurally where things can be found after the merge, or which dev-features were added.

I added a description to this PR. Check if you agree @babsey

Copy link
Member

@shimoura shimoura left a comment

Choose a reason for hiding this comment

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

I believe it is all fine for me, only check the last changes I included, please. @babsey

@babsey
Copy link
Collaborator Author

babsey commented Jun 25, 2025

The PR description looks fine to me. Thanks @shimoura !

@babsey
Copy link
Collaborator Author

babsey commented Sep 8, 2025

@terhorstd friendly reminder!

@babsey
Copy link
Collaborator Author

babsey commented Oct 31, 2025

@terhorstd Friendly reminder for the review.

I would like to test the offical HUMAM package for NEST Desktop before Hackathon in December.

Copy link

@terhorstd terhorstd left a comment

Choose a reason for hiding this comment

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

Mostly code-quality comments. Consider using tools like isort, black, flake8, mypy, etc.

6. Congratulations! Now you can run the model. Enjoy!<br> To run the model, click the `Run` on the title bar and choose `Run All Cells`. It takes several minutes until you get all results.<br>
**Please note**: every time you click the `Try it on EBRAINS` button, the repository is loaded into your home directory on EBRAINS Lab and it overrides your old repository with the same name. Therefore, make sure you follow the [Fork the repository and save your changes](#fork-the-repository-and-save-your-changes) if you make changes and want to save them.
3. If you’re using EBRAINS for the first time, click `Sign in with GenericOAuth2` to sign in on EBRAINS. To do this, you
need an EBRAINS account.

Choose a reason for hiding this comment

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

Suggested change
need an EBRAINS account.
need an [EBRAINS account](https://ebrains.eu/register).

README.md Outdated

#### Try it on EBRAINS
1. Click [Try it on EBRAINS](https://lab.ebrains.eu/hub/user-redirect/git-pull?repo=https%3A%2F%2Fgithub.com%2FINM-6%2Fhuman-multi-area-model.git&urlpath=lab%2Ftree%2Fhuman-multi-area-model.git%2Fhumam_tutorial.ipynb&branch=main). If any error or unexpected happens during the following process, please close the browser tab and restart the [User instruction](https://lab.ebrains.eu/hub/user-redirect/git-pull?repo=https%3A%2F%2Fgithub.com%2Fshimoura%2Fhuman-multi-area-model.git&urlpath=lab%2Ftree%2Fhuman-multi-area-model.git%2Fhumam_tutorial.ipynb&branch=add-downscaling-factor) process again.
1. Click [Try it on EBRAINS](https://lab.ebrains.eu/hub/user-redirect/git-pull?repo=https%3A%2F%2Fgithub.com%2FINM-6%2Fhuman-multi-area-model.git&urlpath=lab%2Ftree%2Fhuman-multi-area-model.git%2Fhumam_tutorial.ipynb&branch=main). If any error or unexpected happens during the following process, please close the browser tab and restart the

Choose a reason for hiding this comment

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

This is fine for main, but remember to put a note in your release process to change the branch=main to the release tag once you split of a release candidate branch.

@@ -0,0 +1 @@
from . import connectivity, cytoarchitecture

Choose a reason for hiding this comment

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

Check if this could better be

Suggested change
from . import connectivity, cytoarchitecture
__all__ = ["connectivity", "cytoarchitecture"]

N_syn_ext : DataFrame
Population resolved internal syapse numbers.
"""
from itertools import product

Choose a reason for hiding this comment

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

Import not at top of file.

Comment on lines +897 to +900
import os
import yaml
import pandas as pd

Choose a reason for hiding this comment

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

Import not at top of file.

Comment on lines +438 to +439
from datetime import datetime

Choose a reason for hiding this comment

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

Import not at top of file.

Comment on lines +453 to +454
from dicthash import dicthash

Choose a reason for hiding this comment

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

Import not at top of file.

Comment on lines +483 to +484
import yaml

Choose a reason for hiding this comment

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

Import not at top of file.

Comment on lines +512 to +514
import os
import yaml

Choose a reason for hiding this comment

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

Import not at top of file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Changes that improve the code's structure or organization without altering its behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants