Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove replication of code to get_token command. #223

Open
pushkalkatara opened this issue Dec 22, 2019 · 10 comments
Open

Remove replication of code to get_token command. #223

pushkalkatara opened this issue Dec 22, 2019 · 10 comments

Comments

@pushkalkatara
Copy link

There are two separate blocks of code which perform the same task -

  1. https://github.com/Cloud-CV/evalai-cli/blob/master/evalai/utils/auth.py#L53

  2. https://github.com/Cloud-CV/evalai-cli/blob/master/evalai/get_token.py

Remove replication of code.

@daedaldan
Copy link

Since these two blocks of code are essentially identical, would it be feasible to delete get_token.py and replace any usages of that file's code with the identical function in the utils/auth.py file?

@m-sameer
Copy link

m-sameer commented Dec 31, 2019

@pushkalkatara What should we do?

I am thinking that @daniel22373 is right.

@pushkalkatara
Copy link
Author

pushkalkatara commented Dec 31, 2019

@daniel22373 @m-sameer
The task is to use 2 as the wrapper for 1. Rename the file get_token.py to token.py and use the utils to write a click wrapper for get_token function. Just as it is done for other commands here.

add_token would also be integrated in the same file - token.py as it is a token/auth related command, but this would be another issue and another GCI task.

@daedaldan
Copy link

daedaldan commented Dec 31, 2019 via email

@daedaldan
Copy link

daedaldan commented Dec 31, 2019 via email

@pushkalkatara
Copy link
Author

@m-sameer Click defines decorators for each function to be used as a CLI command. In order to seperate click decorators and implementation of the function, we have two files token.py and utils/auth.py. In token.py we basically write the click decorators, import the utils/auth.py functions and call the functions directly, which can be called wrapping. In utils/auth.py we have the actual implementation of the function.

@m-sameer
Copy link

m-sameer commented Jan 2, 2020

So I have to create a function get_token in auth.py and point it to the function in token.py?

@pushkalkatara
Copy link
Author

  1. Rename get_token.py -> auth.py
  2. Import utils/auth.py in auth.py
  3. update get_token function to use functions present in utils/auth.py
  4. Check if the function works well
  5. Post screenshots of the working command.

@m-sameer
Copy link

m-sameer commented Jan 2, 2020

But you said rename get_token.py to token.py earlier?

@pushkalkatara
Copy link
Author

Yes, you can choose either of them.

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

No branches or pull requests

3 participants