Skip to content

Commit 9b9bc36

Browse files
unified package, only 2 modes, dependency check
1 parent cab2897 commit 9b9bc36

6 files changed

Lines changed: 53 additions & 15 deletions

File tree

kratos.gid/exec/launch.json

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,25 @@
22
"configurations": [
33
{
44
"name": "Launch via pip",
5-
"script": "pip"
5+
"script": "pip",
6+
"pip_packages": "KratosMultiphysics-all",
7+
"dependency_check": "Kratos::CheckDependenciesPipMode"
68
},
79
{
810
"name": "Launch via pip with local packages",
9-
"script": "local_pip"
11+
"script": "local_pip",
12+
"pip_packages": "exec/packages/**.whl",
13+
"dependency_check": "Kratos::CheckDependenciesLocalPipMode"
1014
},
1115
{
1216
"name": "Launch local compiled version",
13-
"script": "compiled"
17+
"script": "compiled",
18+
"dependency_check": "Kratos::CheckDependenciesLocalMode"
1419
},
1520
{
1621
"name": "Docker",
17-
"script": ""
22+
"script": "",
23+
"dependency_check": "Kratos::CheckDependenciesDockerMode"
1824
}
1925
]
2026
}

kratos.gid/kratos.tcl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,11 @@ proc Kratos::InitGlobalVariables {dir} {
187187
set namespaces [list ]
188188

189189
variable pip_packages_required
190-
set pip_packages_required [list KratosMultiphysics KratosFluidDynamicsApplication KratosConvectionDiffusionApplication \
191-
KratosDEMApplication numpy KratosDamApplication KratosSwimmingDEMApplication KratosStructuralMechanicsApplication KratosMeshMovingApplication \
192-
KratosMappingApplication KratosParticleMechanicsApplication KratosLinearSolversApplication KratosContactStructuralMechanicsApplication]
190+
# set pip_packages_required [list KratosMultiphysics KratosFluidDynamicsApplication KratosConvectionDiffusionApplication \
191+
# KratosDEMApplication numpy KratosDamApplication KratosSwimmingDEMApplication KratosStructuralMechanicsApplication KratosMeshMovingApplication \
192+
# KratosMappingApplication KratosParticleMechanicsApplication KratosLinearSolversApplication KratosContactStructuralMechanicsApplication \
193+
# KratosFSIApplication]
194+
set pip_packages_required KratosMultiphysics-all==9.0.2
193195
}
194196

195197
proc Kratos::LoadCommonScripts { } {

kratos.gid/scripts/Controllers/Preferences.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
<entrywithbutton name="debug_folder" label="Debug path" variable="debug_folder" buttonimage="folder.png" variablemanager='Kratos::ManagePreferences' buttonfunction="OpenBrowserForDirectory" help='Path to the kratos debug folder. This is placed in the launch.json file for debugging' />
2222
<combobox name="launch_configuration" label="Launch configuration" variable="launch_configuration" variablemanager='Kratos::ManagePreferences' help='' >
2323
<option value='Launch via pip' label='Launch via pip'/>
24-
<option value='Launch via pip with local packages' label='Launch via pip with local packages'/>
24+
<!-- <option value='Launch via pip with local packages' label='Launch via pip with local packages'/> -->
2525
<option value='Launch local compiled version' label='Launch local compiled version'/>
26-
<option value='Docker' label='Docker'/>
27-
<option value='Custom...' label='Custom...'/>
26+
<!-- <option value='Docker' label='Docker'/> -->
27+
<!-- <option value='Custom...' label='Custom...'/> -->
2828
</combobox>
2929
</labelframe>
3030
</group>

kratos.gid/scripts/Controllers/PreferencesWindow.tcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ proc Kratos::ManagePreferences { cmd name {value ""}} {
1212
"SetValue" {
1313
set ::Kratos::kratos_private($name) $value
1414
if {$name eq "allow_logs"} {Kratos::InitLog}
15+
if {$name eq "launch_configuration"} {Kratos::CheckDependencies}
1516
}
1617
"GetDefaultValue" {
1718
# same as GetValue

kratos.gid/scripts/Launch.tcl

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ proc Kratos::GetMissingPipPackages { } {
8181

8282

8383
proc Kratos::CheckDependencies { } {
84+
set curr_mode [Kratos::GetLaunchMode]
85+
# W $curr_mode
86+
if {[dict exists $curr_mode dependency_check]} {
87+
set deps [dict get $curr_mode dependency_check]
88+
$deps
89+
}
90+
}
91+
92+
proc Kratos::CheckDependenciesPipMode {} {
8493
if { [GidUtils::IsTkDisabled] } {
8594
return 0
8695
}
@@ -120,6 +129,15 @@ proc Kratos::CheckDependencies { } {
120129
}
121130
}
122131
}
132+
proc Kratos::CheckDependenciesLocalPipMode {} {
133+
134+
}
135+
proc Kratos::CheckDependenciesLocalMode {} {
136+
W "local"
137+
}
138+
proc Kratos::CheckDependenciesDockerMode {} {
139+
140+
}
123141

124142
proc Kratos::GetLaunchConfigurationFile { } {
125143
set new_dir [file join $::env(HOME) .kratos_multiphysics]
@@ -165,12 +183,23 @@ proc Kratos::SetDefaultLaunchMode { } {
165183
proc Kratos::ExecuteLaunchByMode {launch_mode} {
166184
set bat_file ""
167185
if { $::tcl_platform(platform) == "windows" } { set os win } {set os unix}
186+
set mode [Kratos::GetLaunchMode $launch_mode]
187+
if {$mode ne ""} {
188+
set bat [dict get $mode script]
189+
set bat_file [file join exec $bat.$os.bat]
190+
}
191+
192+
return $bat_file
193+
}
194+
195+
proc Kratos::GetLaunchMode { {launch_mode "current"} } {
196+
set curr_mode ""
197+
if {$launch_mode eq "current"} {set launch_mode $Kratos::kratos_private(launch_configuration)}
168198
foreach mode $::Kratos::kratos_private(configurations) {
169199
set mode_name [dict get $mode name]
170200
if {$mode_name eq $launch_mode} {
171-
set bat [dict get $mode script]
172-
set bat_file [file join exec $bat.$os.bat]
201+
set curr_mode $mode
173202
}
174203
}
175-
return $bat_file
176-
}
204+
return $curr_mode
205+
}

kratos.gid/scripts/Menus.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ proc Kratos::ChangeMenus { } {
151151
if {[GidUtils::VersionCmp "14.1.4d"] <0 } { set cmd [list ChangeVariables kratos_preferences] } {set cmd [list PreferencesWindow kratos_preferences]}
152152
GiDMenu::InsertOption "Kratos" [list "Kratos preferences" ] [incr pos] PRE $cmd "" "" replace =
153153
GiDMenu::InsertOption "Kratos" [list "View current log" ] [incr pos] PREPOST [list Kratos::ViewLog] "" "" replace =
154-
GiDMenu::InsertOption "Kratos" [list "Install python and dependencies" ] [incr pos] PREPOST [list Kratos::InstallAllPythonDependencies] "" "" replace =
154+
GiDMenu::InsertOption "Kratos" [list "Install python and update dependencies" ] [incr pos] PREPOST [list Kratos::InstallAllPythonDependencies] "" "" replace =
155155
GiDMenu::InsertOption "Kratos" [list "Refresh launch configurations" ] [incr pos] PREPOST [list Kratos::LoadLaunchModes 1] "" "" replace =
156156
GiDMenu::InsertOption "Kratos" [list "---"] [incr pos] PRE "" "" "" replace =
157157
GiDMenu::InsertOption "Kratos" [list "About Kratos" ] [incr pos] PREPOST [list Kratos::About] "" "" replace =

0 commit comments

Comments
 (0)