@@ -20,6 +20,7 @@ use windmill_common::error::Error;
2020use windmill_common:: error:: Result ;
2121use windmill_common:: flows:: { FlowModule , FlowModuleValue , FlowNodeId } ;
2222use windmill_common:: jobs:: JobPayload ;
23+ use windmill_common:: lockfiles:: is_generated_from_raw_requirements;
2324use windmill_common:: scripts:: ScriptHash ;
2425use windmill_common:: utils:: WarnAfterExt ;
2526#[ cfg( feature = "python" ) ]
@@ -373,15 +374,7 @@ pub async fn process_relative_imports(
373374 db,
374375 )
375376 . await ?;
376- if ( script_lang. is_some_and ( |v| v == ScriptLang :: Bun )
377- && lock
378- . as_ref ( )
379- . is_some_and ( |v| v. contains ( "generatedFromPackageJson" ) ) )
380- || ( script_lang. is_some_and ( |v| v == ScriptLang :: Python3 )
381- && lock
382- . as_ref ( )
383- . is_some_and ( |v| v. starts_with ( LOCKFILE_GENERATED_FROM_REQUIREMENTS_TXT ) ) )
384- {
377+ if is_generated_from_raw_requirements ( script_lang, & lock) {
385378 // if the lock file is generated from a package.json/requirements.txt, we need to clear the dependency map
386379 // because we do not want to have dependencies be recomputed automatically. Empty relative imports passed
387380 // to update_script_dependency_map will clear the dependency map.
@@ -445,17 +438,6 @@ pub async fn process_relative_imports(
445438 Ok ( ( ) )
446439}
447440
448- pub fn is_generated_from_raw_requirements ( lang : Option < ScriptLang > , lock : & Option < String > ) -> bool {
449- ( lang. is_some_and ( |v| v == ScriptLang :: Bun )
450- && lock
451- . as_ref ( )
452- . is_some_and ( |v| v. contains ( "generatedFromPackageJson" ) ) )
453- || ( lang. is_some_and ( |v| v == ScriptLang :: Python3 )
454- && lock
455- . as_ref ( )
456- . is_some_and ( |v| v. starts_with ( LOCKFILE_GENERATED_FROM_REQUIREMENTS_TXT ) ) )
457- }
458-
459441pub async fn trigger_dependents_to_recompute_dependencies (
460442 w_id : & str ,
461443 script_path : & str ,
@@ -1450,7 +1432,7 @@ async fn lock_modules<'c>(
14501432
14511433 if let Some ( locks_to_reload) = locks_to_reload {
14521434 if !locks_to_reload. contains ( & e. id ) {
1453- if !is_generated_from_raw_requirements ( Some ( language) , & lock) {
1435+ if !is_generated_from_raw_requirements ( & Some ( language) , & lock) {
14541436 let relative_imports = get_imports ( ) ;
14551437 tx = dependency_map
14561438 . patch ( relative_imports. clone ( ) , e. id . clone ( ) , tx)
@@ -1463,7 +1445,7 @@ async fn lock_modules<'c>(
14631445 if lock. as_ref ( ) . is_some_and ( |x| !x. trim ( ) . is_empty ( ) ) {
14641446 let skip_creating_new_lock = skip_creating_new_lock ( & language, & content) ;
14651447 if skip_creating_new_lock {
1466- if !is_generated_from_raw_requirements ( Some ( language) , & lock) {
1448+ if !is_generated_from_raw_requirements ( & Some ( language) , & lock) {
14671449 let relative_imports = get_imports ( ) ;
14681450 tx = dependency_map
14691451 . patch ( relative_imports. clone ( ) , e. id . clone ( ) , tx)
@@ -2582,8 +2564,6 @@ async fn ansible_dep(
25822564 serde_json:: to_string ( & ansible_lockfile) . map_err ( |e| e. into ( ) )
25832565}
25842566
2585- pub const LOCKFILE_GENERATED_FROM_REQUIREMENTS_TXT : & str = "# from requirements.txt" ;
2586-
25872567async fn capture_dependency_job (
25882568 job_id : & Uuid ,
25892569 job_language : & ScriptLang ,
@@ -2672,7 +2652,11 @@ async fn capture_dependency_job(
26722652 . await
26732653 . map ( |res| {
26742654 if raw_deps {
2675- format ! ( "{}\n {}" , LOCKFILE_GENERATED_FROM_REQUIREMENTS_TXT , res)
2655+ format ! (
2656+ "{}\n {}" ,
2657+ windmill_common:: lockfiles:: LOCKFILE_GENERATED_FROM_REQUIREMENTS_TXT ,
2658+ res
2659+ )
26762660 } else {
26772661 res
26782662 }
0 commit comments