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

Initial lint run #54

Closed
wants to merge 2 commits into from
Closed

Initial lint run #54

wants to merge 2 commits into from

Conversation

edmondop
Copy link
Contributor

No description provided.

@nqn
Copy link
Contributor

nqn commented Nov 16, 2023

I'm so sorry we lost track of this @edmondop ! How did you run this style fix? Would love to rerun and get us up to speed

@edmondop
Copy link
Contributor Author

I'm so sorry we lost track of this @edmondop ! How did you run this style fix? Would love to rerun and get us up to speed

I can rebase and reimplement the fix if you feel like , shouldn't be hard

@nqn
Copy link
Contributor

nqn commented Nov 17, 2023 via email

@edmondop
Copy link
Contributor Author

There are a lot of improvement that could be done, such as removing unused imports, getting the code length to 120, removing unused variables, etc. Can you check the current state and confirm you agree with the direction? There is still lot of work to do @nqn

@nqn nqn requested a review from wenzhe-log10 November 17, 2023 16:23
@wenzhe-log10
Copy link
Collaborator

@edmondop thanks for contributing!
I noticed you used flake8. There's a newer tool called ruff, which has been adopted by some Python libraries like Hugging Face, OpenAI, and Anthropic. It's often used alongside black and isort for formatting. E.g.

I think it would be beneficial for us to adopt a similar approach. Have you had any experience with ruff? Would you be open to giving it a try and updating the PR with it?

@edmondop
Copy link
Contributor Author

@edmondop thanks for contributing! I noticed you used flake8. There's a newer tool called ruff, which has been adopted by some Python libraries like Hugging Face, OpenAI, and Anthropic. It's often used alongside black and isort for formatting. E.g.

I think it would be beneficial for us to adopt a similar approach. Have you had any experience with ruff? Would you be open to giving it a try and updating the PR with it?

I like the idea @wenzhe-log10 ! It looks there's quite a bit of work to be done to bring the code in line with styleguides, I just wanted to check there's buy-in to do this before I proceed further

@wenzhe-log10
Copy link
Collaborator

@edmondop That's great! @nqn and I have discussed and we are on board to proceed with the update. I would recommend starting with something similar to the current openai-python practice.

Greatly appreciate your initiative. Let us know if you need any assistance.

@edmondop
Copy link
Contributor Author

edmondop commented Nov 20, 2023

@edmondop That's great! @nqn and I have discussed and we are on board to proceed with the update. I would recommend starting with something similar to the current openai-python practice.

Greatly appreciate your initiative. Let us know if you need any assistance.

Almost done, there's a lot of work to do with implicits optionals that are forbidden under PEP 484 and function/types , but I am getting there. One of the biggest question I have is about models. Take for example this code:

https://github.com/log10-io/log10/blob/main/log10/llm.py#L113

In this point, the code correctly guards against log10_config not being set. Few lines below it doesn't:

https://github.com/log10-io/log10/blob/main/log10/llm.py#L137

In order to get mypy happy, I need to align the behavior. Is it possible for hparams to be not set, and for log10 config to be not set? @wenzhe-log10

@wenzhe-log10
Copy link
Collaborator

Is it possible for hparams to be not set, and for log10 config to be not set?

@edmondop yes, both could be not set.

@edmondop
Copy link
Contributor Author

Is it possible for hparams to be not set, and for log10 config to be not set?

@edmondop yes, both could be not set.

then you agree that L137 for example as above should check for it to be set. What's the expected behavior when the config is not set? NOOP? raise an Exception?

@wenzhe-log10
Copy link
Collaborator

Generally speaking, it is NOOP, like return None here.

log10/log10/llm.py

Lines 175 to 176 in 38f62f8

if not self.log10_config:
return None

Do you see many places need adding the guard? In log10/llm.py, I see it's missing for func last_completion_url and we could return None.

@edmondop
Copy link
Contributor Author

@wenzhe-log10 after spending 2/3 hours there are still several hundreds of errors with py-right. It's probably easier to rewrite from scratch the code rather than fixing design problems and usage of problematic patterns, what do you think?

@wenzhe-log10
Copy link
Collaborator

@edmondop thanks for the effort. I'm curious to see the errors. Could you please tell me the steps to reproduce the errors?

@edmondop
Copy link
Contributor Author

@edmondop thanks for the effort. I'm curious to see the errors. Could you please tell me the steps to reproduce the errors?

You can checkout the code and run make lint or make lint-pyright for example

@wenzhe-log10
Copy link
Collaborator

@edmondop I didn't find lint-pyright in makefile. Wonder if the branch has your latest change. The last commit is from 5 days ago.

@edmondop
Copy link
Contributor Author

@edmondop I didn't find lint-pyright in makefile. Wonder if the branch has your latest change. The last commit is from 5 days ago.

Apologies, got a rejected push. Can you try now?

@wenzhe-log10
Copy link
Collaborator

See your latest code now. Thank you.

@wenzhe-log10
Copy link
Collaborator

@edmondop I used ruff for lint and format and created a PR #75. Currently opt out the pyright stuff. Do you mind if I close this PR? thanks.

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

Successfully merging this pull request may close these issues.

3 participants