Puneet Saini
03/07/2025, 5:35 PMpackage_name in the ProjectContext I create but it's being initialized as None. Looks like we don't set this variable in the kedro run cli flow but for configure project flow we do set the package name. Is this intended?Hall
03/07/2025, 5:35 PMNok Lam Chan
03/10/2025, 10:12 AMPuneet Saini
03/10/2025, 10:12 AMPuneet Saini
03/10/2025, 10:13 AMNok Lam Chan
03/10/2025, 11:44 AMPuneet Saini
03/11/2025, 10:18 AM# settings.py
from package.context import ProjectContext
CONTEXT_CLASS = ProjectContext
# context.py
from kedro.framework.context import KedroContext
class ProjectContext(KedroContext):
def __init__(
self,
package_name: str,
project_path: Union[Path, str],
config_loader: AbstractConfigLoader,
hook_manager: PluginManager,
env: str = None,
extra_params: dict[str, Any] = None,
):
super().__init__(
package_name=package_name,
project_path=project_path,
config_loader=config_loader,
hook_manager=hook_manager,
env=env,
extra_params=extra_params,
)
self.package_name = package_name
def init_spark_session(self) -> None:
... (I try to get self._package_name and self.package_name here but I get None for both)Nok Lam Chan
03/11/2025, 2:11 PMNok Lam Chan
03/11/2025, 2:11 PMmainNok Lam Chan
03/11/2025, 2:12 PMhook, I am surprised since this mean the telemetry data will be skewed tooNok Lam Chan
03/11/2025, 2:13 PMpackage_name for specific logic? I remember this is removed from KedroSession because it's not necessary anymore, it looks like we didn't clean up properlyPuneet Saini
03/11/2025, 2:13 PM__main__.pyPuneet Saini
03/11/2025, 2:13 PMNok Lam Chan
03/11/2025, 2:13 PMPuneet Saini
03/11/2025, 2:14 PMNok Lam Chan
03/11/2025, 2:14 PMPuneet Saini
03/11/2025, 2:14 PMNok Lam Chan
03/11/2025, 2:17 PMkedro run doesn't work but running __main__.py worksNok Lam Chan
03/11/2025, 2:17 PMfrom kedro.framework.project import PACKAGE_NAME
print(PACKAGE_NAME)Nok Lam Chan
03/11/2025, 2:17 PMNok Lam Chan
03/11/2025, 2:18 PMPuneet Saini
03/11/2025, 2:19 PM__main__.py I suspect it would (I haven't tried the main approach, just saying looking at the code)Nok Lam Chan
03/11/2025, 2:20 PMPACKAGE_NAME directly because in Python this create new variable (so it's not pointing to global anymore).
If you do from kedro.framework import project, and use project.PACKAGE_NAME, you would be accessing the global correctly.Puneet Saini
03/11/2025, 2:20 PMself.package_name = package_name or Path(__file__).parent.nameNok Lam Chan
03/11/2025, 2:20 PMJuan Luis
03/11/2025, 2:21 PMPACKAGE_NAME is set in configure_project https://github.com/kedro-org/kedro/blob/34e65ae8fa2843353b6db8c6de946b508a98634d/kedro/framework/project/__init__.py#L311-L312 (sorry if this has been mentioned before, skimmed the conversation quickly)Nok Lam Chan
03/11/2025, 2:21 PMPACKAGE_NAME is set correctly, but the _package_name in KedroContext is notNok Lam Chan
03/11/2025, 2:22 PMPuneet Saini
03/11/2025, 2:22 PMJuan Luis
03/11/2025, 2:24 PMKedroContext._package_name being ever reassigned... dead code maybe? should we open an issue about it?