@@ -55,6 +55,7 @@ def _source_plan() -> dict[str, object]:
5555 "manager" : None ,
5656 "name" : None ,
5757 "prefix" : "/opt/deepmd" ,
58+ "dp1s_home" : None ,
5859 },
5960 "package" : {
6061 "deepmd_version" : None ,
@@ -117,6 +118,7 @@ def _easy_plan(method: str) -> dict[str, object]:
117118 "manager" : None ,
118119 "name" : None ,
119120 "prefix" : "/opt/deepmd" ,
121+ "dp1s_home" : None ,
120122 }
121123 package : dict [str , object ] = {
122124 "deepmd_version" : None ,
@@ -137,6 +139,15 @@ def _easy_plan(method: str) -> dict[str, object]:
137139 environment .update (
138140 {"kind" : "conda" , "python" : None , "manager" : "/opt/conda" , "name" : "deepmd" }
139141 )
142+ elif method == "dp1s" :
143+ environment .update (
144+ {
145+ "kind" : "prefix" ,
146+ "python" : None ,
147+ "prefix" : None ,
148+ "dp1s_home" : "/opt/dp1s" ,
149+ }
150+ )
140151 elif method == "offline" :
141152 environment .update ({"kind" : "prefix" , "python" : None })
142153 package .update (
@@ -237,7 +248,7 @@ def test_validate_jax_cpp_rejects_ambiguous_tensorflow_roots() -> None:
237248 assert any ("mutually exclusive" in error for error in errors )
238249
239250
240- @pytest .mark .parametrize ("method" , ["pip" , "conda" , "offline" , "docker" ])
251+ @pytest .mark .parametrize ("method" , ["pip" , "conda" , "dp1s" , " offline" , "docker" ])
241252def test_validate_easy_install_plans (method : str ) -> None :
242253 """Accept the method-specific fields for each easy-install path."""
243254 assert PLAN .validate_plan (_easy_plan (method )) == []
@@ -272,6 +283,41 @@ def test_validate_conda_channels_are_method_specific() -> None:
272283 assert "package.channels: non-empty channels require method 'conda'" in errors
273284
274285
286+ def test_validate_dp1s_lifecycle_keeps_home_and_prefix_distinct (tmp_path : Path ) -> None :
287+ """Accept unresolved and resolved dp1s identities without conflating paths."""
288+ plan = _easy_plan ("dp1s" )
289+ environment = plan ["environment" ]
290+ assert isinstance (environment , dict )
291+ dp1s_home = tmp_path / "dp1s-home"
292+ python_prefix = dp1s_home / "envs" / "dp1s"
293+ environment ["dp1s_home" ] = str (dp1s_home )
294+ assert PLAN .validate_plan (plan ) == []
295+
296+ environment ["python" ] = str (python_prefix / "bin" / "python" )
297+ environment ["prefix" ] = str (python_prefix )
298+ assert environment ["dp1s_home" ] != environment ["prefix" ]
299+ assert PLAN .validate_plan (plan ) == []
300+
301+ environment ["prefix" ] = environment ["dp1s_home" ]
302+ errors = PLAN .validate_plan (plan )
303+ assert any ("must be distinct" in error for error in errors )
304+
305+ environment ["prefix" ] = str (python_prefix )
306+ environment ["python" ] = None
307+ errors = PLAN .validate_plan (plan )
308+ assert any ("must both be null or absolute paths" in error for error in errors )
309+
310+
311+ def test_validate_dp1s_home_is_method_specific () -> None :
312+ """Reject a dp1s installer root that another method would ignore."""
313+ plan = _easy_plan ("pip" )
314+ environment = plan ["environment" ]
315+ assert isinstance (environment , dict )
316+ environment ["dp1s_home" ] = "/opt/dp1s"
317+ errors = PLAN .validate_plan (plan )
318+ assert "environment.dp1s_home: allowed only for method 'dp1s'" in errors
319+
320+
275321@pytest .mark .parametrize ("field" , ["python" , "prefix" ])
276322def test_validate_conda_resolved_paths_must_be_absolute (field : str ) -> None :
277323 """Reject a relative Conda interpreter or prefix after environment creation."""
@@ -934,9 +980,10 @@ def test_dp1s_reference_preserves_planned_identity() -> None:
934980 reference = (
935981 REPOSITORY_ROOT / "skills" / "deepmd-install" / "references" / "easy-install.md"
936982 ).read_text (encoding = "utf-8" )
937- assert 'DP1S_HOME="<absolute-environment-prefix >"' in reference
983+ assert 'DP1S_HOME="<absolute-dp1s-home >"' in reference
938984 assert 'DEEPMD_VERSION="<deepmd-version>"' in reference
939985 assert "DP1S_NO_PATH_UPDATE=1" in reference
986+ assert '--expected-prefix "<absolute-environment-prefix>"' in reference
940987
941988
942989def test_verify_lammps_dpa4c_cli (tmp_path : Path ) -> None :
0 commit comments