File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed
Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -150,4 +150,25 @@ export class Client {
150150 throw error ;
151151 } ) ;
152152 }
153+
154+ /**
155+ * Loads the DL/ML backend specified by the backend identifier from path.
156+ *
157+ * @param backend
158+ * @param path
159+ */
160+ public configLoadBackend ( backend : string , path : string ) : Promise < any > {
161+ const args : any [ ] = [ 'LOADBACKEND' , backend , path ] ;
162+ return this . _sendCommand ( 'ai.config' , args ) ;
163+ }
164+
165+ /**
166+ * Specifies the default base backends path to path.
167+ *
168+ * @param path
169+ */
170+ public configBackendsPath ( path : string ) : Promise < any > {
171+ const args : any [ ] = [ 'BACKENDSPATH' , path ] ;
172+ return this . _sendCommand ( 'ai.config' , args ) ;
173+ }
153174}
Original file line number Diff line number Diff line change 622622 aiclient . end ( true ) ;
623623 } ) ,
624624) ;
625+
626+ it (
627+ 'ai.config positive and negative testing' ,
628+ mochaAsync ( async ( ) => {
629+ const nativeClient = createClient ( ) ;
630+ const aiclient = new Client ( nativeClient ) ;
631+ const result = await aiclient . configBackendsPath ( '/usr/lib/redis/modules/backends/' ) ;
632+ expect ( result ) . to . equal ( 'OK' ) ;
633+ // negative test
634+ try {
635+ const loadReply = await aiclient . configLoadBackend ( Backend . TF , 'notexist/redisai_tensorflow.so' ) ;
636+ } catch ( e ) {
637+ expect ( e . toString ( ) ) . to . equal ( 'ReplyError: ERR error loading backend' ) ;
638+ }
639+
640+ try {
641+ // may throw error if backend already loaded
642+ const loadResult = await aiclient . configLoadBackend ( Backend . TF , 'redisai_tensorflow/redisai_tensorflow.so' ) ;
643+ expect ( loadResult ) . to . equal ( 'OK' ) ;
644+ } catch ( e ) {
645+ expect ( e . toString ( ) ) . to . equal ( 'ReplyError: ERR error loading backend' ) ;
646+ }
647+ aiclient . end ( true ) ;
648+ } ) ,
649+ ) ;
You can’t perform that action at this time.
0 commit comments