Giter Site home page Giter Site logo

ignore unrecognized arguments about mrjob HOT 1 CLOSED

dhuy237 avatar dhuy237 commented on July 19, 2024
ignore unrecognized arguments

from mrjob.

Comments (1)

dhuy237 avatar dhuy237 commented on July 19, 2024

I found a workaround solution but I hope there will be a better way of doing this.

I have to define the argument again inside the mrjob class so it can recognize it:

from datetime import datetime
import json
import argparse

parser = argparse.ArgumentParser()
parser.add_argument("-t", "--time", help = "Output file")
# Use parse_known_args() to ignore all the arguments for mrjob class
args, unknown = parser.parse_known_args()

class Calculate(MRJob):
    def configure_args(self):
        super(Calculate, self).configure_args()
        # Define the argument again to ignore the argparse when running the MR job
        self.add_passthru_arg("-t", "--time", help="output folder for time")

start_time = datetime.now()
Calculate.run()
execute_time = (datetime.now() - start_time).total_seconds()

data = {}
data["step1"] = execute_time
with open(args.time+'/time.json', 'w') as outfile:
    json.dump(data, outfile)

And run with this command:

python cal.py data/input/input.txt --output data/output --time data/output

My question on Stack Overflow

from mrjob.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.