-
Notifications
You must be signed in to change notification settings - Fork 790
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
Typegen #28
Typegen #28
Conversation
@xenova this is only the utils.js file. It will take some time lol. |
src/utils.js
Outdated
.map((x, i) => [i, x]) // Get indices ([index, score]) | ||
.sort((a, b) => b[1] - a[1]) // Sort by log probabilities | ||
items = Array.from(items) | ||
.map((x, i) => [i, x]) // Get indices ([index, score]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather have the comments aligned and it might be best to focus on JSDoc only in one PR, otherwise it becomes hard to judge
src/utils.js
Outdated
/** | ||
* Creates a new instance of the Callable class. | ||
* | ||
* @constructor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@constructor
not needed
src/utils.js
Outdated
* This method should be implemented in subclasses to provide the | ||
* functionality of the callable object. | ||
* | ||
* @method _call |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@method _call
not needed
src/utils.js
Outdated
* @method _call | ||
* @throws {Error} Must implement _call method in subclass | ||
*/ | ||
_call(...args) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
args param is not in jsdoc
src/utils.js
Outdated
function isIntegralNumber(x) { | ||
return Number.isInteger(x) || typeof x === 'bigint' | ||
return Number.isInteger(x) || typeof x === "bigint"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why bother replacing every ' with "?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's my prettier. Forgot to disable it.
There are a few cases of I will close my PR so we don't have to mess around with two PR's. Thank you for the great work and time! |
I just resolved a conflict coming from main. Let me know when you want me to review and test fully 👍 |
@xenova I have left only 3 files. Hopefully in two days. |
Sweet! No rush :) |
8679602
to
e3ddccf
Compare
@xenova The PR is ready, all files have JSdoc now :) But I have to say it is far from perfect. From now we need to make incremental changes and fixes. |
Nice! 🎉 I'm almost done adding a few more models/tasks to main, then I'll review, merge, and finally add any missing docs. |
Just a general question for you @xenova, do you prefer to keep the source in JavaScript vs. moving some things over to TypeScript? |
Not too sure 👀 ... JS has been easier (and faster) to develop in since I don't have much experience with TS. But I'm pretty sure that eventually, the project will transition to TS. |
I hope not. TS is useful powering a language server, but actually writing TS is ugly once the types become a bit more complicated. And you lose the ability to load code directly as ES6 modules in the browser via I would urge caution with regards to those who seem overly enthusiastic about TS, as their enthusiasm is often just following "that shiny new thing", while being disconnected from pragmatism. Simple job for you, @biw, to make things clear, translate this to TypeScript: /**
* @example
* forInMap({a: 11, b: 22}, (k, v) => v); // [11, 22]
* @param {Record<KEY, VAL>} o - The object.
* @param {(key: string, value: VAL) => RET} lambda - The function that operates on the key/value pairs.
* @template {string | number | symbol} KEY - The key.
* @template VAL - Type of the value given to `lambda`.
* @template RET - Type of the return value of `lambda`.
* @returns {RET[]}
*/
function forInMap(o, lambda) {
return Object.keys(o).map(key => lambda(key, o[key]));
} |
Great work 👍 I looked over it and |
@kungfooman thanks for the feedback. The linter is turned off. I think it happened when resolving conflicts. I will have a look and fix :) |
@xenova just checking what is missing to merge this :) |
Since there's already a build pipeline with webpack, this isn't an issue. 😄
As someone who's been shipping typescript code in production for over four years, my intentions are not to chase the new shiny thing. Just trying to help out if the need is there. Not trying to force anyone to use anything 😄
Here you go! function forInMap2<V, K extends Record<string | number | symbol, V>, Ret>(
o: K,
lambda: (key: keyof K, value: K[typeof key]) => Ret,
) {
return Object.keys(o).map((key) => lambda(key, o[key as keyof K]))
} Not trying to start a flame war, I just wanted to be helpful if @xenova had an interest in using TypeScript. |
Hi! No need to do anything on your side - I will get to fully reviewing (and merging) by the end of the week (hopefully lol). |
Haha no worries! 🤣 I'm definitely open to learning new tech, so, we shall see ;) For now, as you'd expect, I'll continue developing in JS, otherwise, I'd probably not be able to keep up with all the craziness in the AI space right now 😄 |
Replace with `AutoModelForObjectDetection`
@chelouche9 I'm almost done with my pass over everything (it's taking so long haha). I tried to push, but I apparently don't have write access to your branch. Could you add me as a collaborator? |
@xenova now you have permissions. |
Thanks! I've pushed my changes. You and @kungfooman can do a quick skim over everything if you'd like... and then I'll merge into main 🔥 Also, I assume we have to run the build command each time before release? If so, then you're probably right that it's a good idea to remove dist from the repo. Perhaps @kungfooman can give some advice in that regard. |
I see you added some changes to the code except for jsdoc. For the annotation part looks good to me :) |
The only reason I like to commit build artifacts is to be able to see potential regressions, e.g. while rewriting a documentation system to keep track of the changes in the generated documentation files. In such cases I just create a throw-away repo and commit as many files I want. But I don't like all these artifact files in the "main repo", since I don't like large repositories. Cloning just takes longer and longer and it will probably also decrease the amount of contributors over time. It's likely to result in merge conflicts aswell and I prefer not to spend time resolving merge conflicts in build artifacts. I also like to use the file-search in VSCode and I don't want to put "dist" in "Exclude dirs" all the time, to filter for the SSOF (single source of truth) e.g. finding some specific types to improve. TLDR: my suggestion is to remove /dist/ from repo |
No description provided.