|
|
Hello, I've been using Julia for a month probably and I would now like to execute a bash script containing a set of commands to run the same file for different arguments. The file myFile.jl contains calls to some functions to accomplish a task and this task needs to be rerun for different datasets which are input as csv files. I want to realise something like the following. I need to run the same file for different datasets which are input as csv files. Python provides a -args option but I'm unaware of how to do this in Julia. I'd be very grateful for any assistance. Thank You
julia myFile.jl dataset1.csv julia myFile.jl dataset2.csv julia myFile.jl dataset3.csv julia myFile.jl dataset4.csv : : :
|
|
Hi Josef, I shall paste a function that I used for my python files. Would it be okay if I asked you for some help to do the same in Julia? I've implemented most of the code but this still remains to be done in Julia and I wasn't aware such a package exists. Thanks a lot def main(argv):
parser = argparse.ArgumentParser(description='optimization') parser.add_argument( '-i', '--info', action='store_true', dest='infoFlag', default=False, required=False, help='show transformation information' )
parser.add_argument( '-o', '--output', action='store', dest='output', default="solution", help='output file name' )
parser.add_argument( '-l', '--logPath', action='store', dest='logPath', default="", help='path where logfiles should be written' )
parser.add_argument( '-p', '--singlePath', action='store_true', dest='singlePath', default=False, required=False, help='unplittable flow problem flag' )
parser.add_argument( '--lp', action='store_true', dest='lp', default=False, required=False, help='flag for writing a lp file to <outputfile>.lp' )
parser.add_argument( '--xml', action='store', dest='xmlInstance', metavar='xmlInstanceFilename', default=None, required=True, help='name of the xml instance file' )
parser.add_argument( '--nRC', action='store_true', dest='noRoutingCosts', default=False, required=False, help='flag for disabeling link mapping costs' )
parser.add_argument( '--uEC', action='store_true', dest='unitEdgeCosts', default=False, required=False, help='flag for unit edge costs' )
global args args = parser.parse_args()
global logFile
if not args.xmlInstance: print "No instance file" return
start = rtime.localtime() start = str(start[:6])[1:-1].replace(", ", "-") phy_network, demands = readXML(args.xmlInstance) logFile = open( args.logPath + "{}-{}.log".format( args.xmlInstance.split("/")[-1], start ), "w" )
printLog("Start Time: {}".format( start ))
solveProblem( phy_network, demands, args.output)
end = rtime.localtime() printLog( "Log file closed at {}".format( str(end[:6])[1:-1].replace(", ", "-") ) )
logFile.close() if __name__ == "__main__": main(sys.argv[1:])
On Thursday, 27 October 2016 14:30:10 UTC+2, Josef Sachs wrote: >>>>> On Thu, 27 Oct 2016 04:51:42 -0700 (PDT), <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="6ECDMrcHAQAJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">varu...@...> said:
> Hello, I've been using Julia for a month probably and I would now
> like to execute a bash script containing a set of commands to run
> the same file for different arguments.
Within Julia, you can inspect the global constant ARGS.
See <a href="http://docs.julialang.org/en/release-0.5/manual/getting-started/" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fdocs.julialang.org%2Fen%2Frelease-0.5%2Fmanual%2Fgetting-started%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE7IqQ2-QFi18V6S3S2GvMDnDda0g';return true;" onclick="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fdocs.julialang.org%2Fen%2Frelease-0.5%2Fmanual%2Fgetting-started%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE7IqQ2-QFi18V6S3S2GvMDnDda0g';return true;">http://docs.julialang.org/en/release-0.5/manual/getting-started/
For something more sophisticated, see
<a href="https://github.com/carlobaldassi/ArgParse.jl" target="_blank" rel="nofollow" onmousedown="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fcarlobaldassi%2FArgParse.jl\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBR30-YWM-p_joxbhjuB7qAyAMCw';return true;" onclick="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fcarlobaldassi%2FArgParse.jl\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBR30-YWM-p_joxbhjuB7qAyAMCw';return true;">https://github.com/carlobaldassi/ArgParse.jl
|
|
On Thu, Oct 27, 2016 at 8:48 AM, < [hidden email]> wrote:
> Hi Josef,
>
> I shall paste a function that I used for my python files. Would it be okay
> if I asked you for some help to do the same in Julia? I've implemented most
> of the code but this still remains to be done in Julia and I wasn't aware
> such a package exists. Thanks a lot
>
https://github.com/carlobaldassi/ArgParse.jl> def main(argv):
>
> parser = argparse.ArgumentParser(description='optimization')
>
> parser.add_argument( '-i', '--info',
> action='store_true',
> dest='infoFlag',
> default=False,
> required=False,
> help='show transformation information' )
>
> parser.add_argument( '-o', '--output',
> action='store',
> dest='output',
> default="solution",
> help='output file name' )
>
> parser.add_argument( '-l', '--logPath',
> action='store',
> dest='logPath',
> default="",
> help='path where logfiles should be written' )
>
> parser.add_argument( '-p', '--singlePath',
> action='store_true',
> dest='singlePath',
> default=False,
> required=False,
> help='unplittable flow problem flag' )
>
> parser.add_argument( '--lp',
> action='store_true',
> dest='lp',
> default=False,
> required=False,
> help='flag for writing a lp file to
> <outputfile>.lp' )
>
> parser.add_argument( '--xml',
> action='store',
> dest='xmlInstance',
> metavar='xmlInstanceFilename',
> default=None,
> required=True,
> help='name of the xml instance file' )
>
> parser.add_argument( '--nRC',
> action='store_true',
> dest='noRoutingCosts',
> default=False,
> required=False,
> help='flag for disabeling link mapping costs' )
>
> parser.add_argument( '--uEC',
> action='store_true',
> dest='unitEdgeCosts',
> default=False,
> required=False,
> help='flag for unit edge costs' )
>
> global args
> args = parser.parse_args()
>
> global logFile
>
> if not args.xmlInstance:
> print "No instance file"
> return
>
> start = rtime.localtime()
> start = str(start[:6])[1:-1].replace(", ", "-")
>
> phy_network, demands = readXML(args.xmlInstance)
> logFile = open( args.logPath + "{}-{}.log".format(
> args.xmlInstance.split("/")[-1], start ), "w" )
>
> printLog("Start Time: {}".format( start ))
>
> solveProblem( phy_network, demands, args.output)
>
> end = rtime.localtime()
> printLog( "Log file closed at {}".format( str(end[:6])[1:-1].replace(",
> ", "-") ) )
>
> logFile.close()
> if __name__ == "__main__":
> main(sys.argv[1:])
>
>
>
>
> On Thursday, 27 October 2016 14:30:10 UTC+2, Josef Sachs wrote:
>>
>> >>>>> On Thu, 27 Oct 2016 04:51:42 -0700 (PDT), < [hidden email]> said:
>>
>> > Hello, I've been using Julia for a month probably and I would now
>> > like to execute a bash script containing a set of commands to run
>> > the same file for different arguments.
>>
>> Within Julia, you can inspect the global constant ARGS.
>> See http://docs.julialang.org/en/release-0.5/manual/getting-started/>>
>> For something more sophisticated, see
>> https://github.com/carlobaldassi/ArgParse.jl
|
|
There are a few doubts that I may want to clarify as of now. Thanks a lot for the link @Yichao, @Josef. 1. The function definition in python is def main(argv). I wrote function main(args) in the Julia equivalent. Is this the right way to do it? 2. For the line in Python args = parser.parse_args() , the Jullia equivalent is args = parse_args(s) and correct me if I am wrong. This function is mapping the command line arguments to a dictionary with keys
3. This is the most confusing part for me. I really don't get the Julia equivalent of these two lines. if __name__ == "__main__": main(sys.argv[1:])
Could you please clarify my questions? On Thursday, 27 October 2016 15:05:57 UTC+2, Yichao Yu wrote: On Thu, Oct 27, 2016 at 8:48 AM, <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="_pXuLasJAQAJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">varu...@...> wrote:
> Hi Josef,
>
> I shall paste a function that I used for my python files. Would it be okay
> if I asked you for some help to do the same in Julia? I've implemented most
> of the code but this still remains to be done in Julia and I wasn't aware
> such a package exists. Thanks a lot
>
<a href="https://github.com/carlobaldassi/ArgParse.jl" target="_blank" rel="nofollow" onmousedown="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fcarlobaldassi%2FArgParse.jl\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBR30-YWM-p_joxbhjuB7qAyAMCw';return true;" onclick="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fcarlobaldassi%2FArgParse.jl\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBR30-YWM-p_joxbhjuB7qAyAMCw';return true;">https://github.com/carlobaldassi/ArgParse.jl
> def main(argv):
>
> parser = argparse.ArgumentParser( description='optimization')
>
> parser.add_argument( '-i', '--info',
> action='store_true',
> dest='infoFlag',
> default=False,
> required=False,
> help='show transformation information' )
>
> parser.add_argument( '-o', '--output',
> action='store',
> dest='output',
> default="solution",
> help='output file name' )
>
> parser.add_argument( '-l', '--logPath',
> action='store',
> dest='logPath',
> default="",
> help='path where logfiles should be written' )
>
> parser.add_argument( '-p', '--singlePath',
> action='store_true',
> dest='singlePath',
> default=False,
> required=False,
> help='unplittable flow problem flag' )
>
> parser.add_argument( '--lp',
> action='store_true',
> dest='lp',
> default=False,
> required=False,
> help='flag for writing a lp file to
> <outputfile>.lp' )
>
> parser.add_argument( '--xml',
> action='store',
> dest='xmlInstance',
> metavar='xmlInstanceFilename',
> default=None,
> required=True,
> help='name of the xml instance file' )
>
> parser.add_argument( '--nRC',
> action='store_true',
> dest='noRoutingCosts',
> default=False,
> required=False,
> help='flag for disabeling link mapping costs' )
>
> parser.add_argument( '--uEC',
> action='store_true',
> dest='unitEdgeCosts',
> default=False,
> required=False,
> help='flag for unit edge costs' )
>
> global args
> args = parser.parse_args()
>
> global logFile
>
> if not args.xmlInstance:
> print "No instance file"
> return
>
> start = rtime.localtime()
> start = str(start[:6])[1:-1].replace(", ", "-")
>
> phy_network, demands = readXML(args.xmlInstance)
> logFile = open( args.logPath + "{}-{}.log".format(
> args.xmlInstance.split("/")[-1], start ), "w" )
>
> printLog("Start Time: {}".format( start ))
>
> solveProblem( phy_network, demands, args.output)
>
> end = rtime.localtime()
> printLog( "Log file closed at {}".format( str(end[:6])[1:-1].replace(",
> ", "-") ) )
>
> logFile.close()
> if __name__ == "__main__":
> main(sys.argv[1:])
>
>
>
>
> On Thursday, 27 October 2016 14:30:10 UTC+2, Josef Sachs wrote:
>>
>> >>>>> On Thu, 27 Oct 2016 04:51:42 -0700 (PDT), <[hidden email]> said:
>>
>> > Hello, I've been using Julia for a month probably and I would now
>> > like to execute a bash script containing a set of commands to run
>> > the same file for different arguments.
>>
>> Within Julia, you can inspect the global constant ARGS.
>> See <a href="http://docs.julialang.org/en/release-0.5/manual/getting-started/" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fdocs.julialang.org%2Fen%2Frelease-0.5%2Fmanual%2Fgetting-started%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE7IqQ2-QFi18V6S3S2GvMDnDda0g';return true;" onclick="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fdocs.julialang.org%2Fen%2Frelease-0.5%2Fmanual%2Fgetting-started%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE7IqQ2-QFi18V6S3S2GvMDnDda0g';return true;">http://docs.julialang.org/en/release-0.5/manual/getting-started/
>>
>> For something more sophisticated, see
>> <a href="https://github.com/carlobaldassi/ArgParse.jl" target="_blank" rel="nofollow" onmousedown="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fcarlobaldassi%2FArgParse.jl\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBR30-YWM-p_joxbhjuB7qAyAMCw';return true;" onclick="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fcarlobaldassi%2FArgParse.jl\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBR30-YWM-p_joxbhjuB7qAyAMCw';return true;">https://github.com/carlobaldassi/ArgParse.jl
|
|
> 3. This is the most confusing part for me. I really don't get the Julia
> equivalent of these two lines. if __name__ == "__main__":
> main(sys.argv[1:])
None.
>
> Could you please clarify my questions?
>
>
> On Thursday, 27 October 2016 15:05:57 UTC+2, Yichao Yu wrote:
>>
>> On Thu, Oct 27, 2016 at 8:48 AM, < [hidden email]> wrote:
>> > Hi Josef,
>> >
>> > I shall paste a function that I used for my python files. Would it be
>> > okay
>> > if I asked you for some help to do the same in Julia? I've implemented
>> > most
>> > of the code but this still remains to be done in Julia and I wasn't
>> > aware
>> > such a package exists. Thanks a lot
>> >
>>
>> https://github.com/carlobaldassi/ArgParse.jl>>
>> > def main(argv):
>> >
>> > parser = argparse.ArgumentParser(description='optimization')
>> >
>> > parser.add_argument( '-i', '--info',
>> > action='store_true',
>> > dest='infoFlag',
>> > default=False,
>> > required=False,
>> > help='show transformation information' )
>> >
>> > parser.add_argument( '-o', '--output',
>> > action='store',
>> > dest='output',
>> > default="solution",
>> > help='output file name' )
>> >
>> > parser.add_argument( '-l', '--logPath',
>> > action='store',
>> > dest='logPath',
>> > default="",
>> > help='path where logfiles should be written'
>> > )
>> >
>> > parser.add_argument( '-p', '--singlePath',
>> > action='store_true',
>> > dest='singlePath',
>> > default=False,
>> > required=False,
>> > help='unplittable flow problem flag' )
>> >
>> > parser.add_argument( '--lp',
>> > action='store_true',
>> > dest='lp',
>> > default=False,
>> > required=False,
>> > help='flag for writing a lp file to
>> > <outputfile>.lp' )
>> >
>> > parser.add_argument( '--xml',
>> > action='store',
>> > dest='xmlInstance',
>> > metavar='xmlInstanceFilename',
>> > default=None,
>> > required=True,
>> > help='name of the xml instance file' )
>> >
>> > parser.add_argument( '--nRC',
>> > action='store_true',
>> > dest='noRoutingCosts',
>> > default=False,
>> > required=False,
>> > help='flag for disabeling link mapping costs'
>> > )
>> >
>> > parser.add_argument( '--uEC',
>> > action='store_true',
>> > dest='unitEdgeCosts',
>> > default=False,
>> > required=False,
>> > help='flag for unit edge costs' )
>> >
>> > global args
>> > args = parser.parse_args()
>> >
>> > global logFile
>> >
>> > if not args.xmlInstance:
>> > print "No instance file"
>> > return
>> >
>> > start = rtime.localtime()
>> > start = str(start[:6])[1:-1].replace(", ", "-")
>> >
>> > phy_network, demands = readXML(args.xmlInstance)
>> > logFile = open( args.logPath + "{}-{}.log".format(
>> > args.xmlInstance.split("/")[-1], start ), "w" )
>> >
>> > printLog("Start Time: {}".format( start ))
>> >
>> > solveProblem( phy_network, demands, args.output)
>> >
>> > end = rtime.localtime()
>> > printLog( "Log file closed at {}".format(
>> > str(end[:6])[1:-1].replace(",
>> > ", "-") ) )
>> >
>> > logFile.close()
>> > if __name__ == "__main__":
>> > main(sys.argv[1:])
>> >
>> >
>> >
>> >
>> > On Thursday, 27 October 2016 14:30:10 UTC+2, Josef Sachs wrote:
>> >>
>> >> >>>>> On Thu, 27 Oct 2016 04:51:42 -0700 (PDT), < [hidden email]>
>> >> >>>>> said:
>> >>
>> >> > Hello, I've been using Julia for a month probably and I would now
>> >> > like to execute a bash script containing a set of commands to run
>> >> > the same file for different arguments.
>> >>
>> >> Within Julia, you can inspect the global constant ARGS.
>> >> See http://docs.julialang.org/en/release-0.5/manual/getting-started/>> >>
>> >> For something more sophisticated, see
>> >> https://github.com/carlobaldassi/ArgParse.jl
|
|
I don't understand what the post means. Could you please elaborate a bit? On Saturday, 29 October 2016 22:04:32 UTC+2, Yichao Yu wrote: > 3. This is the most confusing part for me. I really don't get the Julia
> equivalent of these two lines. if __name__ == "__main__":
> main(sys.argv[1:])
None.
>
> Could you please clarify my questions?
>
>
> On Thursday, 27 October 2016 15:05:57 UTC+2, Yichao Yu wrote:
>>
>> On Thu, Oct 27, 2016 at 8:48 AM, < [hidden email]> wrote:
>> > Hi Josef,
>> >
>> > I shall paste a function that I used for my python files. Would it be
>> > okay
>> > if I asked you for some help to do the same in Julia? I've implemented
>> > most
>> > of the code but this still remains to be done in Julia and I wasn't
>> > aware
>> > such a package exists. Thanks a lot
>> >
>>
>> <a href="https://github.com/carlobaldassi/ArgParse.jl" target="_blank" rel="nofollow" onmousedown="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fcarlobaldassi%2FArgParse.jl\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBR30-YWM-p_joxbhjuB7qAyAMCw';return true;" onclick="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fcarlobaldassi%2FArgParse.jl\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBR30-YWM-p_joxbhjuB7qAyAMCw';return true;">https://github.com/ carlobaldassi/ArgParse.jl
>>
>> > def main(argv):
>> >
>> > parser = argparse.ArgumentParser(description='optimization')
>> >
>> > parser.add_argument( '-i', '--info',
>> > action='store_true',
>> > dest='infoFlag',
>> > default=False,
>> > required=False,
>> > help='show transformation information' )
>> >
>> > parser.add_argument( '-o', '--output',
>> > action='store',
>> > dest='output',
>> > default="solution",
>> > help='output file name' )
>> >
>> > parser.add_argument( '-l', '--logPath',
>> > action='store',
>> > dest='logPath',
>> > default="",
>> > help='path where logfiles should be written'
>> > )
>> >
>> > parser.add_argument( '-p', '--singlePath',
>> > action='store_true',
>> > dest='singlePath',
>> > default=False,
>> > required=False,
>> > help='unplittable flow problem flag' )
>> >
>> > parser.add_argument( '--lp',
>> > action='store_true',
>> > dest='lp',
>> > default=False,
>> > required=False,
>> > help='flag for writing a lp file to
>> > <outputfile>.lp' )
>> >
>> > parser.add_argument( '--xml',
>> > action='store',
>> > dest='xmlInstance',
>> > metavar='xmlInstanceFilename',
>> > default=None,
>> > required=True,
>> > help='name of the xml instance file' )
>> >
>> > parser.add_argument( '--nRC',
>> > action='store_true',
>> > dest='noRoutingCosts',
>> > default=False,
>> > required=False,
>> > help='flag for disabeling link mapping costs'
>> > )
>> >
>> > parser.add_argument( '--uEC',
>> > action='store_true',
>> > dest='unitEdgeCosts',
>> > default=False,
>> > required=False,
>> > help='flag for unit edge costs' )
>> >
>> > global args
>> > args = parser.parse_args()
>> >
>> > global logFile
>> >
>> > if not args.xmlInstance:
>> > print "No instance file"
>> > return
>> >
>> > start = rtime.localtime()
>> > start = str(start[:6])[1:-1].replace(", ", "-")
>> >
>> > phy_network, demands = readXML(args.xmlInstance)
>> > logFile = open( args.logPath + "{}-{}.log".format(
>> > args.xmlInstance.split("/")[-1], start ), "w" )
>> >
>> > printLog("Start Time: {}".format( start ))
>> >
>> > solveProblem( phy_network, demands, args.output)
>> >
>> > end = rtime.localtime()
>> > printLog( "Log file closed at {}".format(
>> > str(end[:6])[1:-1].replace(",
>> > ", "-") ) )
>> >
>> > logFile.close()
>> > if __name__ == "__main__":
>> > main(sys.argv[1:])
>> >
>> >
>> >
>> >
>> > On Thursday, 27 October 2016 14:30:10 UTC+2, Josef Sachs wrote:
>> >>
>> >> >>>>> On Thu, 27 Oct 2016 04:51:42 -0700 (PDT), <[hidden email]>
>> >> >>>>> said:
>> >>
>> >> > Hello, I've been using Julia for a month probably and I would now
>> >> > like to execute a bash script containing a set of commands to run
>> >> > the same file for different arguments.
>> >>
>> >> Within Julia, you can inspect the global constant ARGS.
>> >> See <a href="http://docs.julialang.org/en/release-0.5/manual/getting-started/" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fdocs.julialang.org%2Fen%2Frelease-0.5%2Fmanual%2Fgetting-started%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE7IqQ2-QFi18V6S3S2GvMDnDda0g';return true;" onclick="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fdocs.julialang.org%2Fen%2Frelease-0.5%2Fmanual%2Fgetting-started%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE7IqQ2-QFi18V6S3S2GvMDnDda0g';return true;">http://docs.julialang.org/en/release-0.5/manual/getting-started/
>> >>
>> >> For something more sophisticated, see
>> >> <a href="https://github.com/carlobaldassi/ArgParse.jl" target="_blank" rel="nofollow" onmousedown="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fcarlobaldassi%2FArgParse.jl\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBR30-YWM-p_joxbhjuB7qAyAMCw';return true;" onclick="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fcarlobaldassi%2FArgParse.jl\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBR30-YWM-p_joxbhjuB7qAyAMCw';return true;">https://github.com/carlobaldassi/ArgParse.jl
|
|
On Sat, Oct 29, 2016 at 4:21 PM, < [hidden email]> wrote:
> I don't understand what the post means. Could you please elaborate a bit?
>
>
> On Saturday, 29 October 2016 22:04:32 UTC+2, Yichao Yu wrote:
>>
>> > 3. This is the most confusing part for me. I really don't get the Julia
>> > equivalent of these two lines. if __name__ == "__main__":
>> > main(sys.argv[1:])
There's no equivalent of that because that's not how julia works.
>>
>> None.
>>
>> >
>> > Could you please clarify my questions?
>> >
>> >
>> > On Thursday, 27 October 2016 15:05:57 UTC+2, Yichao Yu wrote:
>> >>
>> >> On Thu, Oct 27, 2016 at 8:48 AM, < [hidden email]> wrote:
>> >> > Hi Josef,
>> >> >
>> >> > I shall paste a function that I used for my python files. Would it be
>> >> > okay
>> >> > if I asked you for some help to do the same in Julia? I've
>> >> > implemented
>> >> > most
>> >> > of the code but this still remains to be done in Julia and I wasn't
>> >> > aware
>> >> > such a package exists. Thanks a lot
>> >> >
>> >>
>> >> https://github.com/carlobaldassi/ArgParse.jl>> >>
>> >> > def main(argv):
>> >> >
>> >> > parser = argparse.ArgumentParser(description='optimization')
>> >> >
>> >> > parser.add_argument( '-i', '--info',
>> >> > action='store_true',
>> >> > dest='infoFlag',
>> >> > default=False,
>> >> > required=False,
>> >> > help='show transformation information' )
>> >> >
>> >> > parser.add_argument( '-o', '--output',
>> >> > action='store',
>> >> > dest='output',
>> >> > default="solution",
>> >> > help='output file name' )
>> >> >
>> >> > parser.add_argument( '-l', '--logPath',
>> >> > action='store',
>> >> > dest='logPath',
>> >> > default="",
>> >> > help='path where logfiles should be
>> >> > written'
>> >> > )
>> >> >
>> >> > parser.add_argument( '-p', '--singlePath',
>> >> > action='store_true',
>> >> > dest='singlePath',
>> >> > default=False,
>> >> > required=False,
>> >> > help='unplittable flow problem flag' )
>> >> >
>> >> > parser.add_argument( '--lp',
>> >> > action='store_true',
>> >> > dest='lp',
>> >> > default=False,
>> >> > required=False,
>> >> > help='flag for writing a lp file to
>> >> > <outputfile>.lp' )
>> >> >
>> >> > parser.add_argument( '--xml',
>> >> > action='store',
>> >> > dest='xmlInstance',
>> >> > metavar='xmlInstanceFilename',
>> >> > default=None,
>> >> > required=True,
>> >> > help='name of the xml instance file' )
>> >> >
>> >> > parser.add_argument( '--nRC',
>> >> > action='store_true',
>> >> > dest='noRoutingCosts',
>> >> > default=False,
>> >> > required=False,
>> >> > help='flag for disabeling link mapping
>> >> > costs'
>> >> > )
>> >> >
>> >> > parser.add_argument( '--uEC',
>> >> > action='store_true',
>> >> > dest='unitEdgeCosts',
>> >> > default=False,
>> >> > required=False,
>> >> > help='flag for unit edge costs' )
>> >> >
>> >> > global args
>> >> > args = parser.parse_args()
>> >> >
>> >> > global logFile
>> >> >
>> >> > if not args.xmlInstance:
>> >> > print "No instance file"
>> >> > return
>> >> >
>> >> > start = rtime.localtime()
>> >> > start = str(start[:6])[1:-1].replace(", ", "-")
>> >> >
>> >> > phy_network, demands = readXML(args.xmlInstance)
>> >> > logFile = open( args.logPath + "{}-{}.log".format(
>> >> > args.xmlInstance.split("/")[-1], start ), "w" )
>> >> >
>> >> > printLog("Start Time: {}".format( start ))
>> >> >
>> >> > solveProblem( phy_network, demands, args.output)
>> >> >
>> >> > end = rtime.localtime()
>> >> > printLog( "Log file closed at {}".format(
>> >> > str(end[:6])[1:-1].replace(",
>> >> > ", "-") ) )
>> >> >
>> >> > logFile.close()
>> >> > if __name__ == "__main__":
>> >> > main(sys.argv[1:])
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > On Thursday, 27 October 2016 14:30:10 UTC+2, Josef Sachs wrote:
>> >> >>
>> >> >> >>>>> On Thu, 27 Oct 2016 04:51:42 -0700 (PDT), < [hidden email]>
>> >> >> >>>>> said:
>> >> >>
>> >> >> > Hello, I've been using Julia for a month probably and I would now
>> >> >> > like to execute a bash script containing a set of commands to run
>> >> >> > the same file for different arguments.
>> >> >>
>> >> >> Within Julia, you can inspect the global constant ARGS.
>> >> >> See http://docs.julialang.org/en/release-0.5/manual/getting-started/>> >> >>
>> >> >> For something more sophisticated, see
>> >> >> https://github.com/carlobaldassi/ArgParse.jl
|
|
>>>>> On Sat, 29 Oct 2016 12:59:45 -0700 (PDT), < [hidden email]> said:
> 3. This is the most confusing part for me. I really don't get the Julia
> equivalent of these two lines. if __name__ == "__main__":
> main(sys.argv[1:])
It seems like a lot of members of the Julia community do not really like
this usage, but there is an equivalent in v0.5. See
https://groups.google.com/forum/#!topic/julia-users/INlaEr8fBbU
|
|