-
Notifications
You must be signed in to change notification settings - Fork 0
p_sync: FileSyncer + CLI + Local File Usage #30
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
Conversation
…pt idioms - Rename SyncClient to FileSyncer and update client options to match Python SDK - Add useLocalFiles, localFilesDirectory, and cacheSize options - Update pull method to return [successful, failed] arrays - Improve TypeScript terminology in docstrings (array vs tuple/list) - Fix type errors and error handling Makes the codebase more consistent with Python SDK while improving TypeScript idioms and type safety.
- Create new unified `overloadClient` function that handles both log and call methods - Simplify client initialization by directly overloading parent class instances - Replace SyncClient with direct FileSyncer instance for cleaner file handling - Standardize tracing context, local file handling, and evaluation context across all client types
| const LogType = { | ||
| SUCCESS: "\x1b[92m", // green | ||
| ERROR: "\x1b[91m", // red | ||
| INFO: "\x1b[96m", // cyan | ||
| WARN: "\x1b[93m", // yellow | ||
| RESET: "\x1b[0m", | ||
| } as const; | ||
|
|
||
| function log(message: string, type: keyof typeof LogType): void { | ||
| console.log(`${LogType[type]}${message}${LogType.RESET}`); | ||
| } |
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.
move to a separate util module
| .description("Pull Prompt and Agent files from Humanloop to your local filesystem") | ||
| .addHelpText( | ||
| "after", | ||
| "\nThis command will:\n" + |
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.
Add a screnshot on PR conversation showing how the help menu is printed
| ): T { | ||
| const originalLog = client.log.bind(client); | ||
|
|
||
| const _overloadedLog = async ( |
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.
does typing work ok? think this guard was in place for a reason
| * For example, an invalid path format (absolute paths, leading/trailing slashes, etc.) | ||
| * or a file not being found. | ||
| */ | ||
| function handleLocalFiles<T extends LogRequestType>( |
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.
There's some similar logic in resolve File in eval.run(...). Modifying it now could take a while, but do add it in the Linear project for milestone 2
| // If file_type is already specified in request, prioritize user-provided value | ||
| if (fileType in request && typeof request[fileType as keyof T] !== "string") { | ||
| console.warn( | ||
| `Ignoring local file for \`${filePath}\` as ${fileType} parameters were directly provided. ` + |
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.
Message could be better worded
| /** | ||
| * Normalize a path to the standard Humanloop API format. | ||
| * | ||
| * This function is primarily used when interacting with the Humanloop API to ensure paths |
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 not use a standard library
https://nodejs.org/api/path.html#pathnormalizepath
| const LogType = { | ||
| DEBUG: "\x1b[90m", // gray | ||
| INFO: "\x1b[96m", // cyan | ||
| WARN: "\x1b[93m", // yellow | ||
| ERROR: "\x1b[91m", // red | ||
| RESET: "\x1b[0m", | ||
| } as const; |
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.
This can also go in the common logging module mentioned earlier
andreibratu
left a comment
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.
logic looks good - i think we can use libraries in two places + i have some questions
Command example output
npx humanloop --helpnpx humanloop pull --helpnpx humanloop pull