Skip to content
This repository has been archived by the owner on Jan 4, 2020. It is now read-only.

Marathon run isn't working properly #110

Open
sahara108 opened this issue Jul 3, 2017 · 5 comments
Open

Marathon run isn't working properly #110

sahara108 opened this issue Jul 3, 2017 · 5 comments

Comments

@sahara108
Copy link

sahara108 commented Jul 3, 2017

I have found that running the scripts by using marathon run myscript.swift doesn't work properly. It hangs the program forever. I end up build an executable program to use it.
I am using 10.13 Beta (17A291j). The code is written by swift 4

@JohnSundell
Copy link
Owner

Hi @sahara108. Could you provide some more debuggable information? What kind of script are you trying to run? Does it have any dependencies? I haven't tried Marathon on 10.13 Beta yet, so it might have something to do with it as well.

@sahara108
Copy link
Author

Just try to use the Vision framework to detect and crop face from a picture.

if #available(OSX 10.13, *) {
    let processingQueue = OperationQueue()
    processingQueue.qualityOfService = .userInitiated
    processingQueue.maxConcurrentOperationCount = 1
    for item in urls {
        
        if let img = CIImage(contentsOf: item) {
            processingQueue.addOperation {
                let handler = FaceCrop()
                NSLog("Start process image at \(item)")
                handler.processImage(inputImage: img)
                while (handler.isProcessing) {
                    RunLoop.current.run(mode: .defaultRunLoopMode, before: Date(timeInterval: 1, since: Date()))
                }
                
                NSLog("Start process output images of \(item)")
                if let out = handler.outputImage {
                    save_cgimage_to_jpeg(input: out, destination: faceDir.appendingPathComponent(item.lastPathComponent))
                }
            }
            
            processingQueue.waitUntilAllOperationsAreFinished()
//            wait(8)
        }
    }
    
    
} else {
    // Fallback on earlier versions
}

@JohnSundell
Copy link
Owner

And you're saying that the exact same code works if you put it inside an executable program instead? Are you using the Swift Package Manager or a command line app from Xcode? What is the output if you run the script using the ---verbose flag?

@sahara108
Copy link
Author

And you're saying that the exact same code works if you put it inside an executable program instead? Yes
Are you using the Swift Package Manager or a command line app from Xcode? No

Verbose output:
$ marathon run getImages.swift --verbose

🏃  $ cd "/Users/$$$$$$/.marathon/Scripts/Cache/-Users-$$$$$$-Study-Scripts-Faces-getImages/" && readlink OriginalFile
   /Users/$$$$$$/Study/Scripts/Faces/getImages.swift
   $ cd "/Users/$$$$$$/Study/Scripts/Faces/" && /usr/bin/env xcrun --sdk macosx swift --version
   Apple Swift version 4.0 (swiftlang-900.0.43 clang-900.0.22.8)
   Target: x86_64-apple-macosx10.9
   $ cd "/Users/$$$$$$/.marathon/Scripts/Cache/-Users-$$$$$$-Study-Scripts-Faces-getImages/" && /usr/bin/env xcrun --sdk macosx swift build -C /Users/$$$$$$/.marathon/Scripts/Cache/-Users-$$$$$$-Study-Scripts-Faces-getImages/ --enable-prefetching 
   Compile Swift Module 'getImages' (1 sources)
   /Users/$$$$$$/.marathon/Scripts/Cache/-Users-$$$$$$-Study-Scripts-Faces-getImages/Sources/getImages/main.swift:483:13: warning: initialization of immutable value 'cropx' was never used; consider replacing with assignment to '_' or removing it
           let cropx = input.extent.origin
           ~~~~^~~~~
           _
   Linking ./.build/debug/getImages
   $ cd "/Users/$$$$$$/Study/Scripts/Faces/" && /Users/$$$$$$/.marathon/Scripts/Cache/-Users-$$$$$$-Study-Scripts-Faces-getImages/.build/debug/getImages --verbose

@ghost
Copy link

ghost commented Aug 19, 2018

Hi @sahara108

Could you try this again?

The code looks like it might fall of the end in certain places.

For example, the while loop may go forever ?

Or you may execute it on a system that isn't 10.13 ?

Try to handle all of these pitfalls and see if any of these reasons are to blame first.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants