From cadeff8eee4dd8aa0dcbc2f3bae9153e2b6a6d33 Mon Sep 17 00:00:00 2001 From: nahuakang Date: Sun, 26 Jul 2020 23:59:53 +0200 Subject: [PATCH 1/2] Edit existing inline documentation --- src/syft.js | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/syft.js b/src/syft.js index 384b5da3..602bf481 100644 --- a/src/syft.js +++ b/src/syft.js @@ -8,43 +8,42 @@ import ObjectRegistry from './object-registry'; * Syft client for static federated learning. * * @param {Object} options - * @param {string} options.url Full URL to PyGrid app (`ws` and `http` schemas supported). - * @param {boolean} options.verbose Whether to enable logging and allow unsecured PyGrid connection. - * @param {string} options.authToken PyGrid authentication token. - * @param {Object} options.peerConfig [not implemented] WebRTC peer config used with RTCPeerConnection. + * @param {string} options.url - Full URL to PyGrid app (`ws` and `http` schemas supported). + * @param {boolean} options.verbose - Whether to enable logging and allow unsecured PyGrid connection. + * @param {string} options.authToken - PyGrid authentication token. + * @param {Object} options.peerConfig - [not implemented] WebRTC peer config used with RTCPeerConnection. * * @example * * const client = new Syft({url: "ws://localhost:5000", verbose: true}) * const job = client.newJob({modelName: "mnist", modelVersion: "1.0.0"}) * job.on('accepted', async ({model, clientConfig}) => { - * // execute training + * // Execute training * const [...newParams] = await this.plans['...'].execute(...) * const diff = await model.createSerializedDiff(newParams) * await this.report(diff) * }) * job.on('rejected', ({timeout}) => { - * // re-try later or stop + * // Retry later or stop * }) * job.on('error', (err) => { - * // handle errors + * // Handle errors * }) * job.start() */ export default class Syft { constructor({ url, verbose, authToken, peerConfig }) { - // For creating verbose logging should the worker desire + // Create verbose logging if verbose value is true this.logger = new Logger('syft.js', verbose); - // Forcing connection to be secure if verbose value is false. + // Force connection to be secure if verbose value is false this.verbose = verbose; - this.gridClient = new GridAPIClient({ url, allowInsecureUrl: verbose }); - // objects registry + // Create objects registry this.objects = new ObjectRegistry(); - // For creating event listeners + // Create event listeners this.observer = new EventObserver(); this.worker_id = null; @@ -56,15 +55,15 @@ export default class Syft { /** * Authenticates the client against PyGrid and instantiates new Job with given options. * - * @throws Error + * @throws Error if grid client authentication failed. * @param {Object} options - * @param {string} options.modelName FL Model name. - * @param {string} options.modelVersion FL Model version. + * @param {string} options.modelName - FL Model name. + * @param {string} options.modelVersion - FL Model version. * @returns {Promise} */ async newJob({ modelName, modelVersion }) { if (!this.worker_id) { - // authenticate + // Authenticate the client const authResponse = await this.gridClient.authenticate( modelName, modelVersion, @@ -78,7 +77,7 @@ export default class Syft { worker: this, modelName, modelVersion, - gridClient: this.gridClient + gridClient: this.gridClient, }); } } From f877125ff3b0f0c965a3a768b208136b1ed16f1e Mon Sep 17 00:00:00 2001 From: nahuakang Date: Mon, 27 Jul 2020 00:01:42 +0200 Subject: [PATCH 2/2] Update api reference --- API-REFERENCE.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/API-REFERENCE.md b/API-REFERENCE.md index be565ca2..def9d7f8 100644 --- a/API-REFERENCE.md +++ b/API-REFERENCE.md @@ -45,16 +45,16 @@ Syft client for static federated learning. const client = new Syft({url: "ws://localhost:5000", verbose: true}) const job = client.newJob({modelName: "mnist", modelVersion: "1.0.0"}) job.on('accepted', async ({model, clientConfig}) => { - // execute training + // Execute training const [...newParams] = await this.plans['...'].execute(...) const diff = await model.createSerializedDiff(newParams) await this.report(diff) }) job.on('rejected', ({timeout}) => { - // re-try later or stop + // Retry later or stop }) job.on('error', (err) => { - // handle errors + // Handle errors }) job.start() ``` @@ -70,7 +70,7 @@ Authenticates the client against PyGrid and instantiates new Job with given opti - `options.modelVersion` **[string][26]** FL Model version. -- Throws **any** Error +- Throws **any** Error if grid client authentication failed. Returns **[Promise][28]<[Job][29]>**