index
int64 0
0
| repo_id
stringlengths 16
145
| file_path
stringlengths 27
196
| content
stringlengths 1
16.7M
|
---|---|---|---|
0 | capitalone_repos/rubicon-ml/docs | capitalone_repos/rubicon-ml/docs/source/visualizations.rst | .. _visualizations:
Visualizations
**************
``rubicon_ml.viz`` contains a number of visualization widgets powered by
`Dash <https://dash.plotly.com>`_ and `Plotly <https://plotly.com/>`_.
Each widget provides a unique UI for exploring and visualizing projects and
experiments stored locally or in S3. The widgets can be compiled into an
interactive dashboard. They can also run in the browser or any iPython
environment like Jupyter Notebook, JupyterLab or JupyterHub. With some
extra work, they could be deployed to a static URL using Docker.
|
.. figure:: _static/images/dashboard.png
:align: center
:alt: rubicon-ml dashboard
A **Dashboard** composed of an **Experiments Table** and a **Metric
Correlation Plot**.
Available Widgets
=================
.. toctree::
:maxdepth: 1
visualizations/dataframe-plot
visualizations/experiments-table
visualizations/metric-correlation-plot
visualizations/metric-lists-comparisons
Dashboarding
============
The widgets detailed in the examples above can also be compiled into an
interactive dashboard.
.. toctree::
:maxdepth: 1
visualizations/dashboard
Basic Usage
===========
Each individual widget can be launched directly from Python code. Widgets
will be hosted locally. You can navigate to the provided link in each widgets'
output, or visualize the widget in-line if you are running from a Jupyter
environment.
.. code-block:: python
from rubicon_ml.viz import ExperimentsTable
ExperimentsTable(experiments=my_rubicon_project.experiments()).serve()
The above launches the experiments table on ``localhost:8050`` and will run from
any Python interpreter. If you're working in a Jupyter environment, you can
launch the dashboard inline in a notebook with ``show``:
.. code-block:: python
ExperimentsTable(experiments=my_rubicon_project.experiments()).show()
If you need to configure the Dash proxy, that can also be done with a
few extra parameters:
.. code-block:: python
dash_kwargs = {
"requests_pathname_prefix": "/proxy/8050",
}
run_server_kwargs = {
"proxy": "http://127.0.0.1:8050::https://my-jupyterhub-server.com/",
}
ExperimentsTable(experiments=my_rubicon_project.experiments()).serve(
dash_kwargs=dash_options,
run_server_kwargs=run_server_kwargs,
)
More info on configuring proxies and additional ``dash_kwargs`` can be found in the
`Dash API Reference <https://dash.plotly.com/reference>`_.
CLI
===
The ``rubicon_ml`` CLI can lauch a dashboard containing an **Experiments
Table** stacked on top of a **Metric Correlation Plot**, as shown in the
figure above.
.. code-block:: shell
rubicon_ml ui --root-dir /rubicon-root --project-name "My Cool Project"
Use the ``--help`` flag for full usage details:
.. code-block:: shell
rubicon_ml ui --help
|
0 | capitalone_repos/rubicon-ml/docs/source | capitalone_repos/rubicon-ml/docs/source/_static/custom.css | /*
the ipython3 code blocks and dataframes coming from
the notebooks were not getting the dark theme styles
applied, so manually overriding them
*/
@media (prefers-color-scheme: dark) {
.dataframe {
color: white !important;
}
.highlight-ipython3 {
background: #202020 !important;
border: none !important;
border-radius: 2px !important;
color: #d0d0d0 !important;
}
tr:nth-child(odd) {
background-color: #202020 !important;
}
}
.hidden {
display: none;
}
.sidebar-brand {
margin-top: 1rem;
}
.version {
text-align: center;
}
|
0 | capitalone_repos/rubicon-ml/docs/source | capitalone_repos/rubicon-ml/docs/source/_static/underscore.js | // Underscore.js 1.13.1
// https://underscorejs.org
// (c) 2009-2021 Jeremy Ashkenas, Julian Gonggrijp, and DocumentCloud and Investigative Reporters & Editors
// Underscore may be freely distributed under the MIT license.
var VERSION="1.13.1",root="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global||Function("return this")()||{},ArrayProto=Array.prototype,ObjProto=Object.prototype,SymbolProto="undefined"!=typeof Symbol?Symbol.prototype:null,push=ArrayProto.push,slice=ArrayProto.slice,toString=ObjProto.toString,hasOwnProperty=ObjProto.hasOwnProperty,supportsArrayBuffer="undefined"!=typeof ArrayBuffer,supportsDataView="undefined"!=typeof DataView,nativeIsArray=Array.isArray,nativeKeys=Object.keys,nativeCreate=Object.create,nativeIsView=supportsArrayBuffer&&ArrayBuffer.isView,_isNaN=isNaN,_isFinite=isFinite,hasEnumBug=!{toString:null}.propertyIsEnumerable("toString"),nonEnumerableProps=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],MAX_ARRAY_INDEX=Math.pow(2,53)-1;function restArguments(e,t){return t=null==t?e.length-1:+t,function(){for(var n=Math.max(arguments.length-t,0),r=Array(n),i=0;i<n;i++)r[i]=arguments[i+t];switch(t){case 0:return e.call(this,r);case 1:return e.call(this,arguments[0],r);case 2:return e.call(this,arguments[0],arguments[1],r)}var a=Array(t+1);for(i=0;i<t;i++)a[i]=arguments[i];return a[t]=r,e.apply(this,a)}}function isObject(e){var t=typeof e;return"function"===t||"object"===t&&!!e}function isNull(e){return null===e}function isUndefined(e){return void 0===e}function isBoolean(e){return!0===e||!1===e||"[object Boolean]"===toString.call(e)}function isElement(e){return!(!e||1!==e.nodeType)}function tagTester(e){var t="[object "+e+"]";return function(e){return toString.call(e)===t}}var isString=tagTester("String"),isNumber=tagTester("Number"),isDate=tagTester("Date"),isRegExp=tagTester("RegExp"),isError=tagTester("Error"),isSymbol=tagTester("Symbol"),isArrayBuffer=tagTester("ArrayBuffer"),isFunction=tagTester("Function"),nodelist=root.document&&root.document.childNodes;"function"!=typeof/./&&"object"!=typeof Int8Array&&"function"!=typeof nodelist&&(isFunction=function(e){return"function"==typeof e||!1});var isFunction$1=isFunction,hasObjectTag=tagTester("Object"),hasStringTagBug=supportsDataView&&hasObjectTag(new DataView(new ArrayBuffer(8))),isIE11="undefined"!=typeof Map&&hasObjectTag(new Map),isDataView=tagTester("DataView");function ie10IsDataView(e){return null!=e&&isFunction$1(e.getInt8)&&isArrayBuffer(e.buffer)}var isDataView$1=hasStringTagBug?ie10IsDataView:isDataView,isArray=nativeIsArray||tagTester("Array");function has$1(e,t){return null!=e&&hasOwnProperty.call(e,t)}var isArguments=tagTester("Arguments");!function(){isArguments(arguments)||(isArguments=function(e){return has$1(e,"callee")})}();var isArguments$1=isArguments;function isFinite$1(e){return!isSymbol(e)&&_isFinite(e)&&!isNaN(parseFloat(e))}function isNaN$1(e){return isNumber(e)&&_isNaN(e)}function constant(e){return function(){return e}}function createSizePropertyCheck(e){return function(t){var n=e(t);return"number"==typeof n&&n>=0&&n<=MAX_ARRAY_INDEX}}function shallowProperty(e){return function(t){return null==t?void 0:t[e]}}var getByteLength=shallowProperty("byteLength"),isBufferLike=createSizePropertyCheck(getByteLength),typedArrayPattern=/\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/;function isTypedArray(e){return nativeIsView?nativeIsView(e)&&!isDataView$1(e):isBufferLike(e)&&typedArrayPattern.test(toString.call(e))}var isTypedArray$1=supportsArrayBuffer?isTypedArray:constant(!1),getLength=shallowProperty("length");function emulatedSet(e){for(var t={},n=e.length,r=0;r<n;++r)t[e[r]]=!0;return{contains:function(e){return t[e]},push:function(n){return t[n]=!0,e.push(n)}}}function collectNonEnumProps(e,t){t=emulatedSet(t);var n=nonEnumerableProps.length,r=e.constructor,i=isFunction$1(r)&&r.prototype||ObjProto,a="constructor";for(has$1(e,a)&&!t.contains(a)&&t.push(a);n--;)(a=nonEnumerableProps[n])in e&&e[a]!==i[a]&&!t.contains(a)&&t.push(a)}function keys(e){if(!isObject(e))return[];if(nativeKeys)return nativeKeys(e);var t=[];for(var n in e)has$1(e,n)&&t.push(n);return hasEnumBug&&collectNonEnumProps(e,t),t}function isEmpty(e){if(null==e)return!0;var t=getLength(e);return"number"==typeof t&&(isArray(e)||isString(e)||isArguments$1(e))?0===t:0===getLength(keys(e))}function isMatch(e,t){var n=keys(t),r=n.length;if(null==e)return!r;for(var i=Object(e),a=0;a<r;a++){var u=n[a];if(t[u]!==i[u]||!(u in i))return!1}return!0}function _$1(e){return e instanceof _$1?e:this instanceof _$1?void(this._wrapped=e):new _$1(e)}function toBufferView(e){return new Uint8Array(e.buffer||e,e.byteOffset||0,getByteLength(e))}_$1.VERSION=VERSION,_$1.prototype.value=function(){return this._wrapped},_$1.prototype.valueOf=_$1.prototype.toJSON=_$1.prototype.value,_$1.prototype.toString=function(){return String(this._wrapped)};var tagDataView="[object DataView]";function eq(e,t,n,r){if(e===t)return 0!==e||1/e==1/t;if(null==e||null==t)return!1;if(e!=e)return t!=t;var i=typeof e;return("function"===i||"object"===i||"object"==typeof t)&&deepEq(e,t,n,r)}function deepEq(e,t,n,r){e instanceof _$1&&(e=e._wrapped),t instanceof _$1&&(t=t._wrapped);var i=toString.call(e);if(i!==toString.call(t))return!1;if(hasStringTagBug&&"[object Object]"==i&&isDataView$1(e)){if(!isDataView$1(t))return!1;i=tagDataView}switch(i){case"[object RegExp]":case"[object String]":return""+e==""+t;case"[object Number]":return+e!=+e?+t!=+t:0==+e?1/+e==1/t:+e==+t;case"[object Date]":case"[object Boolean]":return+e==+t;case"[object Symbol]":return SymbolProto.valueOf.call(e)===SymbolProto.valueOf.call(t);case"[object ArrayBuffer]":case tagDataView:return deepEq(toBufferView(e),toBufferView(t),n,r)}var a="[object Array]"===i;if(!a&&isTypedArray$1(e)){if(getByteLength(e)!==getByteLength(t))return!1;if(e.buffer===t.buffer&&e.byteOffset===t.byteOffset)return!0;a=!0}if(!a){if("object"!=typeof e||"object"!=typeof t)return!1;var u=e.constructor,o=t.constructor;if(u!==o&&!(isFunction$1(u)&&u instanceof u&&isFunction$1(o)&&o instanceof o)&&"constructor"in e&&"constructor"in t)return!1}r=r||[];for(var s=(n=n||[]).length;s--;)if(n[s]===e)return r[s]===t;if(n.push(e),r.push(t),a){if((s=e.length)!==t.length)return!1;for(;s--;)if(!eq(e[s],t[s],n,r))return!1}else{var c,f=keys(e);if(s=f.length,keys(t).length!==s)return!1;for(;s--;)if(!has$1(t,c=f[s])||!eq(e[c],t[c],n,r))return!1}return n.pop(),r.pop(),!0}function isEqual(e,t){return eq(e,t)}function allKeys(e){if(!isObject(e))return[];var t=[];for(var n in e)t.push(n);return hasEnumBug&&collectNonEnumProps(e,t),t}function ie11fingerprint(e){var t=getLength(e);return function(n){if(null==n)return!1;var r=allKeys(n);if(getLength(r))return!1;for(var i=0;i<t;i++)if(!isFunction$1(n[e[i]]))return!1;return e!==weakMapMethods||!isFunction$1(n[forEachName])}}var forEachName="forEach",hasName="has",commonInit=["clear","delete"],mapTail=["get",hasName,"set"],mapMethods=commonInit.concat(forEachName,mapTail),weakMapMethods=commonInit.concat(mapTail),setMethods=["add"].concat(commonInit,forEachName,hasName),isMap=isIE11?ie11fingerprint(mapMethods):tagTester("Map"),isWeakMap=isIE11?ie11fingerprint(weakMapMethods):tagTester("WeakMap"),isSet=isIE11?ie11fingerprint(setMethods):tagTester("Set"),isWeakSet=tagTester("WeakSet");function values(e){for(var t=keys(e),n=t.length,r=Array(n),i=0;i<n;i++)r[i]=e[t[i]];return r}function pairs(e){for(var t=keys(e),n=t.length,r=Array(n),i=0;i<n;i++)r[i]=[t[i],e[t[i]]];return r}function invert(e){for(var t={},n=keys(e),r=0,i=n.length;r<i;r++)t[e[n[r]]]=n[r];return t}function functions(e){var t=[];for(var n in e)isFunction$1(e[n])&&t.push(n);return t.sort()}function createAssigner(e,t){return function(n){var r=arguments.length;if(t&&(n=Object(n)),r<2||null==n)return n;for(var i=1;i<r;i++)for(var a=arguments[i],u=e(a),o=u.length,s=0;s<o;s++){var c=u[s];t&&void 0!==n[c]||(n[c]=a[c])}return n}}var extend=createAssigner(allKeys),extendOwn=createAssigner(keys),defaults=createAssigner(allKeys,!0);function ctor(){return function(){}}function baseCreate(e){if(!isObject(e))return{};if(nativeCreate)return nativeCreate(e);var t=ctor();t.prototype=e;var n=new t;return t.prototype=null,n}function create(e,t){var n=baseCreate(e);return t&&extendOwn(n,t),n}function clone(e){return isObject(e)?isArray(e)?e.slice():extend({},e):e}function tap(e,t){return t(e),e}function toPath$1(e){return isArray(e)?e:[e]}function toPath(e){return _$1.toPath(e)}function deepGet(e,t){for(var n=t.length,r=0;r<n;r++){if(null==e)return;e=e[t[r]]}return n?e:void 0}function get(e,t,n){var r=deepGet(e,toPath(t));return isUndefined(r)?n:r}function has(e,t){for(var n=(t=toPath(t)).length,r=0;r<n;r++){var i=t[r];if(!has$1(e,i))return!1;e=e[i]}return!!n}function identity(e){return e}function matcher(e){return e=extendOwn({},e),function(t){return isMatch(t,e)}}function property(e){return e=toPath(e),function(t){return deepGet(t,e)}}function optimizeCb(e,t,n){if(void 0===t)return e;switch(null==n?3:n){case 1:return function(n){return e.call(t,n)};case 3:return function(n,r,i){return e.call(t,n,r,i)};case 4:return function(n,r,i,a){return e.call(t,n,r,i,a)}}return function(){return e.apply(t,arguments)}}function baseIteratee(e,t,n){return null==e?identity:isFunction$1(e)?optimizeCb(e,t,n):isObject(e)&&!isArray(e)?matcher(e):property(e)}function iteratee(e,t){return baseIteratee(e,t,1/0)}function cb(e,t,n){return _$1.iteratee!==iteratee?_$1.iteratee(e,t):baseIteratee(e,t,n)}function mapObject(e,t,n){t=cb(t,n);for(var r=keys(e),i=r.length,a={},u=0;u<i;u++){var o=r[u];a[o]=t(e[o],o,e)}return a}function noop(){}function propertyOf(e){return null==e?noop:function(t){return get(e,t)}}function times(e,t,n){var r=Array(Math.max(0,e));t=optimizeCb(t,n,1);for(var i=0;i<e;i++)r[i]=t(i);return r}function random(e,t){return null==t&&(t=e,e=0),e+Math.floor(Math.random()*(t-e+1))}_$1.toPath=toPath$1,_$1.iteratee=iteratee;var now=Date.now||function(){return(new Date).getTime()};function createEscaper(e){var t=function(t){return e[t]},n="(?:"+keys(e).join("|")+")",r=RegExp(n),i=RegExp(n,"g");return function(e){return e=null==e?"":""+e,r.test(e)?e.replace(i,t):e}}var escapeMap={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},_escape=createEscaper(escapeMap),unescapeMap=invert(escapeMap),_unescape=createEscaper(unescapeMap),templateSettings=_$1.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g},noMatch=/(.)^/,escapes={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},escapeRegExp=/\\|'|\r|\n|\u2028|\u2029/g;function escapeChar(e){return"\\"+escapes[e]}var bareIdentifier=/^\s*(\w|\$)+\s*$/;function template(e,t,n){!t&&n&&(t=n),t=defaults({},t,_$1.templateSettings);var r=RegExp([(t.escape||noMatch).source,(t.interpolate||noMatch).source,(t.evaluate||noMatch).source].join("|")+"|$","g"),i=0,a="__p+='";e.replace(r,(function(t,n,r,u,o){return a+=e.slice(i,o).replace(escapeRegExp,escapeChar),i=o+t.length,n?a+="'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'":r?a+="'+\n((__t=("+r+"))==null?'':__t)+\n'":u&&(a+="';\n"+u+"\n__p+='"),t})),a+="';\n";var u,o=t.variable;if(o){if(!bareIdentifier.test(o))throw new Error("variable is not a bare identifier: "+o)}else a="with(obj||{}){\n"+a+"}\n",o="obj";a="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{u=new Function(o,"_",a)}catch(e){throw e.source=a,e}var s=function(e){return u.call(this,e,_$1)};return s.source="function("+o+"){\n"+a+"}",s}function result(e,t,n){var r=(t=toPath(t)).length;if(!r)return isFunction$1(n)?n.call(e):n;for(var i=0;i<r;i++){var a=null==e?void 0:e[t[i]];void 0===a&&(a=n,i=r),e=isFunction$1(a)?a.call(e):a}return e}var idCounter=0;function uniqueId(e){var t=++idCounter+"";return e?e+t:t}function chain(e){var t=_$1(e);return t._chain=!0,t}function executeBound(e,t,n,r,i){if(!(r instanceof t))return e.apply(n,i);var a=baseCreate(e.prototype),u=e.apply(a,i);return isObject(u)?u:a}var partial=restArguments((function(e,t){var n=partial.placeholder,r=function(){for(var i=0,a=t.length,u=Array(a),o=0;o<a;o++)u[o]=t[o]===n?arguments[i++]:t[o];for(;i<arguments.length;)u.push(arguments[i++]);return executeBound(e,r,this,this,u)};return r}));partial.placeholder=_$1;var bind=restArguments((function(e,t,n){if(!isFunction$1(e))throw new TypeError("Bind must be called on a function");var r=restArguments((function(i){return executeBound(e,r,t,this,n.concat(i))}));return r})),isArrayLike=createSizePropertyCheck(getLength);function flatten$1(e,t,n,r){if(r=r||[],t||0===t){if(t<=0)return r.concat(e)}else t=1/0;for(var i=r.length,a=0,u=getLength(e);a<u;a++){var o=e[a];if(isArrayLike(o)&&(isArray(o)||isArguments$1(o)))if(t>1)flatten$1(o,t-1,n,r),i=r.length;else for(var s=0,c=o.length;s<c;)r[i++]=o[s++];else n||(r[i++]=o)}return r}var bindAll=restArguments((function(e,t){var n=(t=flatten$1(t,!1,!1)).length;if(n<1)throw new Error("bindAll must be passed function names");for(;n--;){var r=t[n];e[r]=bind(e[r],e)}return e}));function memoize(e,t){var n=function(r){var i=n.cache,a=""+(t?t.apply(this,arguments):r);return has$1(i,a)||(i[a]=e.apply(this,arguments)),i[a]};return n.cache={},n}var delay=restArguments((function(e,t,n){return setTimeout((function(){return e.apply(null,n)}),t)})),defer=partial(delay,_$1,1);function throttle(e,t,n){var r,i,a,u,o=0;n||(n={});var s=function(){o=!1===n.leading?0:now(),r=null,u=e.apply(i,a),r||(i=a=null)},c=function(){var c=now();o||!1!==n.leading||(o=c);var f=t-(c-o);return i=this,a=arguments,f<=0||f>t?(r&&(clearTimeout(r),r=null),o=c,u=e.apply(i,a),r||(i=a=null)):r||!1===n.trailing||(r=setTimeout(s,f)),u};return c.cancel=function(){clearTimeout(r),o=0,r=i=a=null},c}function debounce(e,t,n){var r,i,a,u,o,s=function(){var c=now()-i;t>c?r=setTimeout(s,t-c):(r=null,n||(u=e.apply(o,a)),r||(a=o=null))},c=restArguments((function(c){return o=this,a=c,i=now(),r||(r=setTimeout(s,t),n&&(u=e.apply(o,a))),u}));return c.cancel=function(){clearTimeout(r),r=a=o=null},c}function wrap(e,t){return partial(t,e)}function negate(e){return function(){return!e.apply(this,arguments)}}function compose(){var e=arguments,t=e.length-1;return function(){for(var n=t,r=e[t].apply(this,arguments);n--;)r=e[n].call(this,r);return r}}function after(e,t){return function(){if(--e<1)return t.apply(this,arguments)}}function before(e,t){var n;return function(){return--e>0&&(n=t.apply(this,arguments)),e<=1&&(t=null),n}}var once=partial(before,2);function findKey(e,t,n){t=cb(t,n);for(var r,i=keys(e),a=0,u=i.length;a<u;a++)if(t(e[r=i[a]],r,e))return r}function createPredicateIndexFinder(e){return function(t,n,r){n=cb(n,r);for(var i=getLength(t),a=e>0?0:i-1;a>=0&&a<i;a+=e)if(n(t[a],a,t))return a;return-1}}var findIndex=createPredicateIndexFinder(1),findLastIndex=createPredicateIndexFinder(-1);function sortedIndex(e,t,n,r){for(var i=(n=cb(n,r,1))(t),a=0,u=getLength(e);a<u;){var o=Math.floor((a+u)/2);n(e[o])<i?a=o+1:u=o}return a}function createIndexFinder(e,t,n){return function(r,i,a){var u=0,o=getLength(r);if("number"==typeof a)e>0?u=a>=0?a:Math.max(a+o,u):o=a>=0?Math.min(a+1,o):a+o+1;else if(n&&a&&o)return r[a=n(r,i)]===i?a:-1;if(i!=i)return(a=t(slice.call(r,u,o),isNaN$1))>=0?a+u:-1;for(a=e>0?u:o-1;a>=0&&a<o;a+=e)if(r[a]===i)return a;return-1}}var indexOf=createIndexFinder(1,findIndex,sortedIndex),lastIndexOf=createIndexFinder(-1,findLastIndex);function find(e,t,n){var r=(isArrayLike(e)?findIndex:findKey)(e,t,n);if(void 0!==r&&-1!==r)return e[r]}function findWhere(e,t){return find(e,matcher(t))}function each(e,t,n){var r,i;if(t=optimizeCb(t,n),isArrayLike(e))for(r=0,i=e.length;r<i;r++)t(e[r],r,e);else{var a=keys(e);for(r=0,i=a.length;r<i;r++)t(e[a[r]],a[r],e)}return e}function map(e,t,n){t=cb(t,n);for(var r=!isArrayLike(e)&&keys(e),i=(r||e).length,a=Array(i),u=0;u<i;u++){var o=r?r[u]:u;a[u]=t(e[o],o,e)}return a}function createReduce(e){var t=function(t,n,r,i){var a=!isArrayLike(t)&&keys(t),u=(a||t).length,o=e>0?0:u-1;for(i||(r=t[a?a[o]:o],o+=e);o>=0&&o<u;o+=e){var s=a?a[o]:o;r=n(r,t[s],s,t)}return r};return function(e,n,r,i){var a=arguments.length>=3;return t(e,optimizeCb(n,i,4),r,a)}}var reduce=createReduce(1),reduceRight=createReduce(-1);function filter(e,t,n){var r=[];return t=cb(t,n),each(e,(function(e,n,i){t(e,n,i)&&r.push(e)})),r}function reject(e,t,n){return filter(e,negate(cb(t)),n)}function every(e,t,n){t=cb(t,n);for(var r=!isArrayLike(e)&&keys(e),i=(r||e).length,a=0;a<i;a++){var u=r?r[a]:a;if(!t(e[u],u,e))return!1}return!0}function some(e,t,n){t=cb(t,n);for(var r=!isArrayLike(e)&&keys(e),i=(r||e).length,a=0;a<i;a++){var u=r?r[a]:a;if(t(e[u],u,e))return!0}return!1}function contains(e,t,n,r){return isArrayLike(e)||(e=values(e)),("number"!=typeof n||r)&&(n=0),indexOf(e,t,n)>=0}var invoke=restArguments((function(e,t,n){var r,i;return isFunction$1(t)?i=t:(t=toPath(t),r=t.slice(0,-1),t=t[t.length-1]),map(e,(function(e){var a=i;if(!a){if(r&&r.length&&(e=deepGet(e,r)),null==e)return;a=e[t]}return null==a?a:a.apply(e,n)}))}));function pluck(e,t){return map(e,property(t))}function where(e,t){return filter(e,matcher(t))}function max(e,t,n){var r,i,a=-1/0,u=-1/0;if(null==t||"number"==typeof t&&"object"!=typeof e[0]&&null!=e)for(var o=0,s=(e=isArrayLike(e)?e:values(e)).length;o<s;o++)null!=(r=e[o])&&r>a&&(a=r);else t=cb(t,n),each(e,(function(e,n,r){((i=t(e,n,r))>u||i===-1/0&&a===-1/0)&&(a=e,u=i)}));return a}function min(e,t,n){var r,i,a=1/0,u=1/0;if(null==t||"number"==typeof t&&"object"!=typeof e[0]&&null!=e)for(var o=0,s=(e=isArrayLike(e)?e:values(e)).length;o<s;o++)null!=(r=e[o])&&r<a&&(a=r);else t=cb(t,n),each(e,(function(e,n,r){((i=t(e,n,r))<u||i===1/0&&a===1/0)&&(a=e,u=i)}));return a}function sample(e,t,n){if(null==t||n)return isArrayLike(e)||(e=values(e)),e[random(e.length-1)];var r=isArrayLike(e)?clone(e):values(e),i=getLength(r);t=Math.max(Math.min(t,i),0);for(var a=i-1,u=0;u<t;u++){var o=random(u,a),s=r[u];r[u]=r[o],r[o]=s}return r.slice(0,t)}function shuffle(e){return sample(e,1/0)}function sortBy(e,t,n){var r=0;return t=cb(t,n),pluck(map(e,(function(e,n,i){return{value:e,index:r++,criteria:t(e,n,i)}})).sort((function(e,t){var n=e.criteria,r=t.criteria;if(n!==r){if(n>r||void 0===n)return 1;if(n<r||void 0===r)return-1}return e.index-t.index})),"value")}function group(e,t){return function(n,r,i){var a=t?[[],[]]:{};return r=cb(r,i),each(n,(function(t,i){var u=r(t,i,n);e(a,t,u)})),a}}var groupBy=group((function(e,t,n){has$1(e,n)?e[n].push(t):e[n]=[t]})),indexBy=group((function(e,t,n){e[n]=t})),countBy=group((function(e,t,n){has$1(e,n)?e[n]++:e[n]=1})),partition=group((function(e,t,n){e[n?0:1].push(t)}),!0),reStrSymbol=/[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g;function toArray(e){return e?isArray(e)?slice.call(e):isString(e)?e.match(reStrSymbol):isArrayLike(e)?map(e,identity):values(e):[]}function size(e){return null==e?0:isArrayLike(e)?e.length:keys(e).length}function keyInObj(e,t,n){return t in n}var pick=restArguments((function(e,t){var n={},r=t[0];if(null==e)return n;isFunction$1(r)?(t.length>1&&(r=optimizeCb(r,t[1])),t=allKeys(e)):(r=keyInObj,t=flatten$1(t,!1,!1),e=Object(e));for(var i=0,a=t.length;i<a;i++){var u=t[i],o=e[u];r(o,u,e)&&(n[u]=o)}return n})),omit=restArguments((function(e,t){var n,r=t[0];return isFunction$1(r)?(r=negate(r),t.length>1&&(n=t[1])):(t=map(flatten$1(t,!1,!1),String),r=function(e,n){return!contains(t,n)}),pick(e,r,n)}));function initial(e,t,n){return slice.call(e,0,Math.max(0,e.length-(null==t||n?1:t)))}function first(e,t,n){return null==e||e.length<1?null==t||n?void 0:[]:null==t||n?e[0]:initial(e,e.length-t)}function rest(e,t,n){return slice.call(e,null==t||n?1:t)}function last(e,t,n){return null==e||e.length<1?null==t||n?void 0:[]:null==t||n?e[e.length-1]:rest(e,Math.max(0,e.length-t))}function compact(e){return filter(e,Boolean)}function flatten(e,t){return flatten$1(e,t,!1)}var difference=restArguments((function(e,t){return t=flatten$1(t,!0,!0),filter(e,(function(e){return!contains(t,e)}))})),without=restArguments((function(e,t){return difference(e,t)}));function uniq(e,t,n,r){isBoolean(t)||(r=n,n=t,t=!1),null!=n&&(n=cb(n,r));for(var i=[],a=[],u=0,o=getLength(e);u<o;u++){var s=e[u],c=n?n(s,u,e):s;t&&!n?(u&&a===c||i.push(s),a=c):n?contains(a,c)||(a.push(c),i.push(s)):contains(i,s)||i.push(s)}return i}var union=restArguments((function(e){return uniq(flatten$1(e,!0,!0))}));function intersection(e){for(var t=[],n=arguments.length,r=0,i=getLength(e);r<i;r++){var a=e[r];if(!contains(t,a)){var u;for(u=1;u<n&&contains(arguments[u],a);u++);u===n&&t.push(a)}}return t}function unzip(e){for(var t=e&&max(e,getLength).length||0,n=Array(t),r=0;r<t;r++)n[r]=pluck(e,r);return n}var zip=restArguments(unzip);function object(e,t){for(var n={},r=0,i=getLength(e);r<i;r++)t?n[e[r]]=t[r]:n[e[r][0]]=e[r][1];return n}function range(e,t,n){null==t&&(t=e||0,e=0),n||(n=t<e?-1:1);for(var r=Math.max(Math.ceil((t-e)/n),0),i=Array(r),a=0;a<r;a++,e+=n)i[a]=e;return i}function chunk(e,t){if(null==t||t<1)return[];for(var n=[],r=0,i=e.length;r<i;)n.push(slice.call(e,r,r+=t));return n}function chainResult(e,t){return e._chain?_$1(t).chain():t}function mixin(e){return each(functions(e),(function(t){var n=_$1[t]=e[t];_$1.prototype[t]=function(){var e=[this._wrapped];return push.apply(e,arguments),chainResult(this,n.apply(_$1,e))}})),_$1}each(["pop","push","reverse","shift","sort","splice","unshift"],(function(e){var t=ArrayProto[e];_$1.prototype[e]=function(){var n=this._wrapped;return null!=n&&(t.apply(n,arguments),"shift"!==e&&"splice"!==e||0!==n.length||delete n[0]),chainResult(this,n)}})),each(["concat","join","slice"],(function(e){var t=ArrayProto[e];_$1.prototype[e]=function(){var e=this._wrapped;return null!=e&&(e=t.apply(e,arguments)),chainResult(this,e)}}));var allExports={__proto__:null,VERSION:VERSION,restArguments:restArguments,isObject:isObject,isNull:isNull,isUndefined:isUndefined,isBoolean:isBoolean,isElement:isElement,isString:isString,isNumber:isNumber,isDate:isDate,isRegExp:isRegExp,isError:isError,isSymbol:isSymbol,isArrayBuffer:isArrayBuffer,isDataView:isDataView$1,isArray:isArray,isFunction:isFunction$1,isArguments:isArguments$1,isFinite:isFinite$1,isNaN:isNaN$1,isTypedArray:isTypedArray$1,isEmpty:isEmpty,isMatch:isMatch,isEqual:isEqual,isMap:isMap,isWeakMap:isWeakMap,isSet:isSet,isWeakSet:isWeakSet,keys:keys,allKeys:allKeys,values:values,pairs:pairs,invert:invert,functions:functions,methods:functions,extend:extend,extendOwn:extendOwn,assign:extendOwn,defaults:defaults,create:create,clone:clone,tap:tap,get:get,has:has,mapObject:mapObject,identity:identity,constant:constant,noop:noop,toPath:toPath$1,property:property,propertyOf:propertyOf,matcher:matcher,matches:matcher,times:times,random:random,now:now,escape:_escape,unescape:_unescape,templateSettings:templateSettings,template:template,result:result,uniqueId:uniqueId,chain:chain,iteratee:iteratee,partial:partial,bind:bind,bindAll:bindAll,memoize:memoize,delay:delay,defer:defer,throttle:throttle,debounce:debounce,wrap:wrap,negate:negate,compose:compose,after:after,before:before,once:once,findKey:findKey,findIndex:findIndex,findLastIndex:findLastIndex,sortedIndex:sortedIndex,indexOf:indexOf,lastIndexOf:lastIndexOf,find:find,detect:find,findWhere:findWhere,each:each,forEach:each,map:map,collect:map,reduce:reduce,foldl:reduce,inject:reduce,reduceRight:reduceRight,foldr:reduceRight,filter:filter,select:filter,reject:reject,every:every,all:every,some:some,any:some,contains:contains,includes:contains,include:contains,invoke:invoke,pluck:pluck,where:where,max:max,min:min,shuffle:shuffle,sample:sample,sortBy:sortBy,groupBy:groupBy,indexBy:indexBy,countBy:countBy,partition:partition,toArray:toArray,size:size,pick:pick,omit:omit,first:first,head:first,take:first,initial:initial,last:last,rest:rest,tail:rest,drop:rest,compact:compact,flatten:flatten,without:without,uniq:uniq,unique:uniq,union:union,intersection:intersection,difference:difference,unzip:unzip,transpose:unzip,zip:zip,object:object,range:range,chunk:chunk,mixin:mixin,default:_$1},_=mixin(allExports);_._=_;export default _;export{VERSION,after,every as all,allKeys,some as any,extendOwn as assign,before,bind,bindAll,chain,chunk,clone,map as collect,compact,compose,constant,contains,countBy,create,debounce,defaults,defer,delay,find as detect,difference,rest as drop,each,_escape as escape,every,extend,extendOwn,filter,find,findIndex,findKey,findLastIndex,findWhere,first,flatten,reduce as foldl,reduceRight as foldr,each as forEach,functions,get,groupBy,has,first as head,identity,contains as include,contains as includes,indexBy,indexOf,initial,reduce as inject,intersection,invert,invoke,isArguments$1 as isArguments,isArray,isArrayBuffer,isBoolean,isDataView$1 as isDataView,isDate,isElement,isEmpty,isEqual,isError,isFinite$1 as isFinite,isFunction$1 as isFunction,isMap,isMatch,isNaN$1 as isNaN,isNull,isNumber,isObject,isRegExp,isSet,isString,isSymbol,isTypedArray$1 as isTypedArray,isUndefined,isWeakMap,isWeakSet,iteratee,keys,last,lastIndexOf,map,mapObject,matcher,matcher as matches,max,memoize,functions as methods,min,mixin,negate,noop,now,object,omit,once,pairs,partial,partition,pick,pluck,property,propertyOf,random,range,reduce,reduceRight,reject,rest,restArguments,result,sample,filter as select,shuffle,size,some,sortBy,sortedIndex,rest as tail,first as take,tap,template,templateSettings,throttle,times,toArray,toPath$1 as toPath,unzip as transpose,_unescape as unescape,union,uniq,uniq as unique,uniqueId,unzip,values,where,without,wrap,zip}; |
0 | capitalone_repos/rubicon-ml/docs/source/_static | capitalone_repos/rubicon-ml/docs/source/_static/images/rubicon_ml_logo_name.svg | <?xml version="1.0" encoding="utf-8"?>
<svg viewBox="2105.75 -45.413 1575.526 1313.609" fill="none" xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient id="paint0_linear" x1="612.729" y1="0" x2="612.729" y2="1224" gradientUnits="userSpaceOnUse">
<stop stop-color="#E2F4FE"/>
<stop offset="1" stop-color="#97D6ED"/>
</linearGradient>
<linearGradient id="paint1_linear" x1="-56.8245" y1="299.696" x2="-4.63461" y2="834.312" gradientUnits="userSpaceOnUse">
<stop stop-color="#019ED5"/>
<stop offset="1" stop-color="#003362"/>
</linearGradient>
<linearGradient id="paint2_linear" x1="746.205" y1="437.978" x2="807.142" y2="893.844" gradientUnits="userSpaceOnUse">
<stop stop-color="#009ED5"/>
<stop offset="1" stop-color="#003362"/>
</linearGradient>
<linearGradient id="paint3_linear" x1="664.533" y1="810.789" x2="704.345" y2="1179.18" gradientUnits="userSpaceOnUse">
<stop stop-color="#009ED5"/>
<stop offset="1" stop-color="#003362"/>
</linearGradient>
</defs>
<mask id="mask0" mask-type="alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="1226" height="1224">
<path d="M612.729 1224C951.129 1224 1225.46 949.998 1225.46 612C1225.46 274.002 951.129 0 612.729 0C274.328 0 0 274.002 0 612C0 949.998 274.328 1224 612.729 1224Z" fill="white"/>
</mask>
<circle style="fill: rgb(255, 255, 255);" cx="2879.961" cy="610.774" r="652.849"/>
<g mask="url(#mask0)" transform="matrix(1, 0, 0, 1, 2266.402832, 2.070756)">
<path d="M612.729 1224C951.129 1224 1225.46 949.998 1225.46 612C1225.46 274.002 951.129 0 612.729 0C274.328 0 0 274.002 0 612C0 949.998 274.328 1224 612.729 1224Z" fill="url(#paint0_linear)"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M837.22 435.232H900.153L1143.78 505.688L1121.3 1031.5L-673.418 804.379L-617.239 770.25C-402.345 639.698 -229.15 541.72 -97.5173 476.264C36.646 409.55 128.11 376.181 180.447 376.181C217.065 376.181 254.259 385.277 294.511 402.507C325.056 415.582 353.008 430.905 397.713 457.78C401.595 460.114 417.778 469.878 421.952 472.386C431.186 477.935 438.529 482.295 445.533 486.37C462.753 496.386 477.103 504.173 490.475 510.623C521.276 525.48 546.32 532.819 568.159 532.819C637.809 532.819 725.913 501.597 831.79 438.47L837.22 435.232Z" stroke-width="45.9" stroke="white" fill="url(#paint1_linear)"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M1330.29 904.593L1209.15 1215.27L364.858 1353.12L-61.2648 1213.57L-219.92 899.462L-145.825 643.856L-9.03537 470.708L6.7009 504.431C55.8427 609.743 146.501 661.864 282.781 661.864C329.547 661.864 381.083 648.428 442.057 621.903C468.145 610.555 495.849 596.896 527.974 579.78C551.638 567.172 563.257 560.723 616.62 530.821C697.141 485.701 739.588 463.402 788.368 442.319C861.983 410.502 926.779 393.919 988.777 393.919C1048.59 393.919 1114.93 410.503 1186.23 441.23C1247.52 467.645 1311.37 504.067 1375.12 547.703C1428.85 584.49 1480.81 625.299 1525.27 664.739C1563.84 698.958 1593.82 729.623 1605.92 747.058C1618.62 765.362 1617.25 786.36 1603.06 804.119C1592.3 817.573 1574.18 829.582 1548.38 841.326C1502.72 862.114 1430.21 883.087 1330.29 904.593Z" stroke-width="45.9" stroke="white" fill="url(#paint2_linear)"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M33.5712 861.045C91.9801 962.446 189.107 1015.46 327.916 1020.61C376.556 1022.42 427.808 1012.52 486.243 991.534C511.304 982.535 537.617 971.552 567.489 957.836C590.296 947.363 608.672 938.464 649.865 918.168C656.14 915.076 658.82 913.756 662.255 912.066C733.629 876.952 773.758 858.73 818.411 842.699C876.877 821.709 929.55 810.789 980.63 810.789C1136.65 810.789 1241.04 887.17 1289.22 1036.5L1295.48 1055.89L553.356 1396.84L-28.9996 1154.5L-51.0364 862.8L25.239 846.58L33.5712 861.045Z" stroke-width="45.9" stroke="white" fill="url(#paint3_linear)"/>
</g>
<g transform="matrix(1, 0, 0, 1, -351.687775, 1358.597656)">
<path d="M 3663.486 -1099.182 L 3718.887 -1099.182 L 3718.887 -1089.48 L 3663.486 -1089.48 L 3663.486 -1099.182 Z" style="stroke: rgb(255, 255, 255); stroke-width: 50px; stroke-linejoin: round; stroke-linecap: round;" fill="#273B49"/>
<path d="M 3899.507 -1149.841 C 3913.448 -1149.841 3924.366 -1145.745 3932.272 -1137.553 C 3940.32 -1129.362 3944.345 -1117.578 3944.345 -1102.2 L 3944.345 -1036.451 L 3933.566 -1036.451 L 3933.566 -1101.339 C 3933.566 -1113.985 3930.477 -1123.614 3924.298 -1130.223 C 3918.116 -1136.835 3909.493 -1140.141 3898.43 -1140.141 C 3885.78 -1140.141 3875.721 -1136.189 3868.25 -1128.284 C 3860.918 -1120.38 3857.255 -1109.744 3857.255 -1096.378 L 3857.255 -1036.451 L 3846.476 -1036.451 L 3846.476 -1101.339 C 3846.476 -1113.985 3843.385 -1123.614 3837.205 -1130.223 C 3831.025 -1136.835 3822.403 -1140.141 3811.336 -1140.141 C 3798.691 -1140.141 3788.628 -1136.189 3781.157 -1128.284 C 3773.826 -1120.38 3770.165 -1109.744 3770.165 -1096.378 L 3770.165 -1036.451 L 3759.385 -1036.451 L 3759.385 -1148.978 L 3769.732 -1148.978 L 3769.732 -1124.835 C 3773.467 -1132.739 3779.001 -1138.846 3786.333 -1143.159 C 3793.805 -1147.614 3802.641 -1149.841 3812.846 -1149.841 C 3823.048 -1149.841 3831.671 -1147.541 3838.716 -1142.943 C 3845.9 -1138.343 3851.003 -1131.589 3854.021 -1122.68 C 3857.755 -1131.016 3863.578 -1137.625 3871.483 -1142.511 C 3879.529 -1147.398 3888.87 -1149.841 3899.507 -1149.841 Z" style="stroke: rgb(255, 255, 255); stroke-width: 50px; stroke-linejoin: round; stroke-linecap: round;" fill="#273B49"/>
<path d="M 3993.16 -1196.404 L 4003.939 -1196.404 L 4003.939 -1036.451 L 3993.16 -1036.451 L 3993.16 -1196.404 Z" style="stroke: rgb(255, 255, 255); stroke-width: 50px; stroke-linejoin: round; stroke-linecap: round;" fill="#273B49"/>
<path d="M 2507.014 -1167.401 C 2512.008 -1177.988 2519.399 -1185.98 2529.187 -1191.372 C 2539.172 -1196.766 2551.458 -1199.461 2566.042 -1199.461 L 2566.042 -1178.788 L 2560.948 -1179.087 C 2544.366 -1179.087 2531.385 -1173.993 2521.997 -1163.805 C 2512.607 -1153.618 2507.911 -1139.335 2507.911 -1120.957 L 2507.911 -1040.654 L 2486.637 -1040.654 L 2486.637 -1198.264 L 2507.014 -1198.264 L 2507.014 -1167.401 Z" style="stroke: rgb(255, 255, 255); stroke-width: 50px; stroke-linejoin: round; stroke-linecap: round;" fill="#273B49"/>
<path d="M 2751.927 -1198.264 L 2751.927 -1040.654 L 2731.55 -1040.654 L 2731.55 -1069.42 C 2725.96 -1059.831 2718.268 -1052.341 2708.481 -1046.947 C 2698.692 -1041.752 2687.506 -1039.156 2674.919 -1039.156 C 2654.344 -1039.156 2638.065 -1044.849 2626.079 -1056.235 C 2614.292 -1067.821 2608.401 -1084.701 2608.401 -1106.874 L 2608.401 -1198.264 L 2629.673 -1198.264 L 2629.673 -1108.972 C 2629.673 -1092.392 2633.768 -1079.806 2641.959 -1071.218 C 2650.149 -1062.628 2661.834 -1058.332 2677.017 -1058.332 C 2693.597 -1058.332 2706.681 -1063.326 2716.272 -1073.315 C 2725.856 -1083.502 2730.653 -1097.586 2730.653 -1115.564 L 2730.653 -1198.264 L 2751.927 -1198.264 Z" style="stroke: rgb(255, 255, 255); stroke-width: 50px; stroke-linejoin: round; stroke-linecap: round;" fill="#273B49"/>
<path d="M 2895.709 -1199.461 C 2910.489 -1199.461 2923.875 -1196.066 2935.86 -1189.274 C 2947.845 -1182.682 2957.233 -1173.293 2964.025 -1161.109 C 2970.818 -1148.924 2974.215 -1135.041 2974.215 -1119.458 C 2974.215 -1103.877 2970.818 -1089.994 2964.025 -1077.81 C 2957.233 -1065.624 2947.845 -1056.136 2935.86 -1049.344 C 2923.875 -1042.552 2910.489 -1039.156 2895.709 -1039.156 C 2882.525 -1039.156 2870.638 -1041.953 2860.052 -1047.546 C 2849.663 -1053.139 2841.276 -1061.23 2834.884 -1071.817 L 2834.884 -1040.654 L 2814.505 -1040.654 L 2814.505 -1262.984 L 2835.78 -1262.984 L 2835.78 -1168.3 C 2842.374 -1178.487 2850.763 -1186.179 2860.95 -1191.372 C 2871.337 -1196.766 2882.924 -1199.461 2895.709 -1199.461 Z M 2894.21 -1058.033 C 2905.196 -1058.033 2915.185 -1060.53 2924.175 -1065.524 C 2933.165 -1070.719 2940.156 -1078.009 2945.149 -1087.398 C 2950.342 -1096.788 2952.941 -1107.473 2952.941 -1119.458 C 2952.941 -1131.443 2950.342 -1142.132 2945.149 -1151.52 C 2940.156 -1160.91 2933.165 -1168.1 2924.175 -1173.094 C 2915.185 -1178.287 2905.196 -1180.884 2894.21 -1180.884 C 2883.023 -1180.884 2872.935 -1178.287 2863.946 -1173.094 C 2855.157 -1168.1 2848.166 -1160.91 2842.972 -1151.52 C 2837.979 -1142.132 2835.48 -1131.443 2835.48 -1119.458 C 2835.48 -1107.473 2837.979 -1096.788 2842.972 -1087.398 C 2848.166 -1078.009 2855.157 -1070.719 2863.946 -1065.524 C 2872.935 -1060.53 2883.023 -1058.033 2894.21 -1058.033 Z" style="stroke: rgb(255, 255, 255); stroke-width: 50px; stroke-linejoin: round; stroke-linecap: round;" fill="#273B49"/>
<path d="M 3020.577 -1198.264 L 3041.851 -1198.264 L 3041.851 -1040.654 L 3020.577 -1040.654 L 3020.577 -1198.264 Z M 3031.366 -1232.722 C 3026.97 -1232.722 3023.274 -1234.22 3020.277 -1237.217 C 3017.281 -1240.213 3015.782 -1243.808 3015.782 -1248.005 C 3015.782 -1251.999 3017.281 -1255.494 3020.277 -1258.49 C 3023.274 -1261.488 3026.97 -1262.984 3031.366 -1262.984 C 3035.761 -1262.984 3039.457 -1261.488 3042.452 -1258.49 C 3045.45 -1255.694 3046.947 -1252.299 3046.947 -1248.304 C 3046.947 -1243.908 3045.45 -1240.213 3042.452 -1237.217 C 3039.457 -1234.22 3035.761 -1232.722 3031.366 -1232.722 Z" style="stroke: rgb(255, 255, 255); stroke-width: 50px; stroke-linejoin: round; stroke-linecap: round;" fill="#273B49"/>
<path d="M 3169.365 -1039.156 C 3153.785 -1039.156 3139.799 -1042.552 3127.414 -1049.344 C 3115.23 -1056.136 3105.641 -1065.624 3098.65 -1077.81 C 3091.659 -1090.195 3088.161 -1104.078 3088.161 -1119.458 C 3088.161 -1134.84 3091.659 -1148.624 3098.65 -1160.81 C 3105.641 -1172.994 3115.23 -1182.483 3127.414 -1189.274 C 3139.799 -1196.066 3153.785 -1199.461 3169.365 -1199.461 C 3182.95 -1199.461 3195.033 -1196.766 3205.62 -1191.372 C 3216.408 -1186.179 3224.899 -1178.487 3231.09 -1168.3 L 3215.209 -1157.512 C 3210.016 -1165.305 3203.422 -1171.095 3195.433 -1174.892 C 3187.443 -1178.887 3178.753 -1180.884 3169.365 -1180.884 C 3157.979 -1180.884 3147.689 -1178.287 3138.501 -1173.094 C 3129.513 -1168.1 3122.422 -1160.91 3117.227 -1151.52 C 3112.235 -1142.132 3109.735 -1131.443 3109.735 -1119.458 C 3109.735 -1107.273 3112.235 -1096.486 3117.227 -1087.098 C 3122.422 -1077.911 3129.513 -1070.719 3138.501 -1065.524 C 3147.689 -1060.53 3157.979 -1058.033 3169.365 -1058.033 C 3178.753 -1058.033 3187.443 -1059.931 3195.433 -1063.728 C 3203.422 -1067.521 3210.016 -1073.315 3215.209 -1081.105 L 3231.09 -1070.319 C 3224.899 -1060.13 3216.408 -1052.341 3205.62 -1046.947 C 3194.833 -1041.752 3182.747 -1039.156 3169.365 -1039.156 Z" style="stroke: rgb(255, 255, 255); stroke-width: 50px; stroke-linejoin: round; stroke-linecap: round;" fill="#273B49"/>
<path d="M 3337.668 -1039.156 C 3322.486 -1039.156 3308.804 -1042.552 3296.616 -1049.344 C 3284.432 -1056.335 3274.843 -1065.924 3267.851 -1078.11 C 3260.861 -1090.294 3257.363 -1104.078 3257.363 -1119.458 C 3257.363 -1134.84 3260.861 -1148.624 3267.851 -1160.81 C 3274.843 -1172.994 3284.432 -1182.483 3296.616 -1189.274 C 3308.804 -1196.066 3322.486 -1199.461 3337.668 -1199.461 C 3352.849 -1199.461 3366.533 -1196.066 3378.717 -1189.274 C 3390.904 -1182.483 3400.391 -1172.994 3407.182 -1160.81 C 3414.176 -1148.624 3417.67 -1134.84 3417.67 -1119.458 C 3417.67 -1104.078 3414.176 -1090.294 3407.182 -1078.11 C 3400.391 -1065.924 3390.904 -1056.335 3378.717 -1049.344 C 3366.533 -1042.552 3352.849 -1039.156 3337.668 -1039.156 Z M 3337.668 -1058.033 C 3348.855 -1058.033 3358.841 -1060.53 3367.633 -1065.524 C 3376.621 -1070.719 3383.61 -1078.009 3388.607 -1087.398 C 3393.6 -1096.788 3396.097 -1107.473 3396.097 -1119.458 C 3396.097 -1131.443 3393.6 -1142.132 3388.607 -1151.52 C 3383.61 -1160.91 3376.621 -1168.1 3367.633 -1173.094 C 3358.841 -1178.287 3348.855 -1180.884 3337.668 -1180.884 C 3326.48 -1180.884 3316.392 -1178.287 3307.403 -1173.094 C 3298.614 -1168.1 3291.624 -1160.91 3286.43 -1151.52 C 3281.436 -1142.132 3278.938 -1131.443 3278.938 -1119.458 C 3278.938 -1107.473 3281.436 -1096.788 3286.43 -1087.398 C 3291.624 -1078.009 3298.614 -1070.719 3307.403 -1065.524 C 3316.392 -1060.53 3326.48 -1058.033 3337.668 -1058.033 Z" style="stroke: rgb(255, 255, 255); stroke-width: 50px; stroke-linejoin: round; stroke-linecap: round;" fill="#273B49"/>
<path d="M 3544.403 -1199.461 C 3564.18 -1199.461 3579.862 -1193.669 3591.448 -1182.084 C 3603.232 -1170.697 3609.125 -1154.018 3609.125 -1132.044 L 3609.125 -1040.654 L 3587.85 -1040.654 L 3587.85 -1129.946 C 3587.85 -1146.327 3583.756 -1158.811 3575.566 -1167.401 C 3567.375 -1175.99 3555.69 -1180.285 3540.509 -1180.285 C 3523.527 -1180.285 3510.044 -1175.192 3500.058 -1165.005 C 3490.268 -1155.016 3485.373 -1141.133 3485.373 -1123.354 L 3485.373 -1040.654 L 3464.102 -1040.654 L 3464.102 -1198.264 L 3484.474 -1198.264 L 3484.474 -1169.199 C 3490.268 -1178.788 3498.26 -1186.179 3508.447 -1191.372 C 3518.834 -1196.766 3530.821 -1199.461 3544.403 -1199.461 Z" style="stroke: rgb(255, 255, 255); stroke-width: 50px; stroke-linejoin: round; stroke-linecap: round;" fill="#273B49"/>
</g>
<path d="M 3311.71 260.343 L 3367.111 260.343 L 3367.111 270.045 L 3311.71 270.045 L 3311.71 260.343 Z" style="stroke: rgb(255, 255, 255); stroke-linecap: round; stroke-linejoin: round; stroke-width: 0px;" fill="#273B49"/>
<path d="M 3547.731 209.684 C 3561.672 209.684 3572.59 213.78 3580.496 221.972 C 3588.544 230.163 3592.569 241.947 3592.569 257.325 L 3592.569 323.074 L 3581.79 323.074 L 3581.79 258.186 C 3581.79 245.54 3578.701 235.911 3572.522 229.302 C 3566.34 222.69 3557.717 219.384 3546.654 219.384 C 3534.004 219.384 3523.945 223.336 3516.474 231.241 C 3509.142 239.145 3505.479 249.781 3505.479 263.147 L 3505.479 323.074 L 3494.7 323.074 L 3494.7 258.186 C 3494.7 245.54 3491.609 235.911 3485.429 229.302 C 3479.249 222.69 3470.627 219.384 3459.56 219.384 C 3446.915 219.384 3436.852 223.336 3429.381 231.241 C 3422.05 239.145 3418.389 249.781 3418.389 263.147 L 3418.389 323.074 L 3407.609 323.074 L 3407.609 210.547 L 3417.956 210.547 L 3417.956 234.69 C 3421.691 226.786 3427.225 220.679 3434.557 216.366 C 3442.029 211.911 3450.865 209.684 3461.07 209.684 C 3471.272 209.684 3479.895 211.984 3486.94 216.582 C 3494.124 221.182 3499.227 227.936 3502.245 236.845 C 3505.979 228.509 3511.802 221.9 3519.707 217.014 C 3527.753 212.127 3537.094 209.684 3547.731 209.684 Z" style="stroke: rgb(255, 255, 255); stroke-linecap: round; stroke-linejoin: round; stroke-width: 0px;" fill="#273B49"/>
<path d="M 3641.384 163.121 L 3652.163 163.121 L 3652.163 323.074 L 3641.384 323.074 L 3641.384 163.121 Z" style="stroke: rgb(255, 255, 255); stroke-linecap: round; stroke-linejoin: round; stroke-width: 0px;" fill="#273B49"/>
<path d="M 2155.238 192.124 C 2160.232 181.537 2167.623 173.545 2177.411 168.153 C 2187.396 162.759 2199.682 160.064 2214.266 160.064 L 2214.266 180.737 L 2209.172 180.438 C 2192.59 180.438 2179.609 185.532 2170.221 195.72 C 2160.831 205.907 2156.135 220.19 2156.135 238.568 L 2156.135 318.871 L 2134.861 318.871 L 2134.861 161.261 L 2155.238 161.261 L 2155.238 192.124 Z" style="stroke: rgb(255, 255, 255); stroke-linecap: round; stroke-linejoin: round; stroke-width: 0px;" fill="#273B49"/>
<path d="M 2400.151 161.261 L 2400.151 318.871 L 2379.774 318.871 L 2379.774 290.105 C 2374.184 299.694 2366.492 307.184 2356.705 312.578 C 2346.916 317.773 2335.73 320.369 2323.143 320.369 C 2302.568 320.369 2286.289 314.676 2274.303 303.29 C 2262.516 291.704 2256.625 274.824 2256.625 252.651 L 2256.625 161.261 L 2277.897 161.261 L 2277.897 250.553 C 2277.897 267.133 2281.992 279.719 2290.183 288.307 C 2298.373 296.897 2310.058 301.193 2325.241 301.193 C 2341.821 301.193 2354.905 296.199 2364.496 286.21 C 2374.08 276.023 2378.877 261.939 2378.877 243.961 L 2378.877 161.261 L 2400.151 161.261 Z" style="stroke: rgb(255, 255, 255); stroke-linecap: round; stroke-linejoin: round; stroke-width: 0px;" fill="#273B49"/>
<path d="M 2543.933 160.064 C 2558.713 160.064 2572.099 163.459 2584.084 170.251 C 2596.069 176.843 2605.457 186.232 2612.249 198.416 C 2619.042 210.601 2622.439 224.484 2622.439 240.067 C 2622.439 255.648 2619.042 269.531 2612.249 281.715 C 2605.457 293.901 2596.069 303.389 2584.084 310.181 C 2572.099 316.973 2558.713 320.369 2543.933 320.369 C 2530.749 320.369 2518.862 317.572 2508.276 311.979 C 2497.887 306.386 2489.5 298.295 2483.108 287.708 L 2483.108 318.871 L 2462.729 318.871 L 2462.729 96.541 L 2484.004 96.541 L 2484.004 191.225 C 2490.598 181.038 2498.987 173.346 2509.174 168.153 C 2519.561 162.759 2531.148 160.064 2543.933 160.064 Z M 2542.434 301.492 C 2553.42 301.492 2563.409 298.995 2572.399 294.001 C 2581.389 288.806 2588.38 281.516 2593.373 272.127 C 2598.566 262.737 2601.165 252.052 2601.165 240.067 C 2601.165 228.082 2598.566 217.393 2593.373 208.005 C 2588.38 198.615 2581.389 191.425 2572.399 186.431 C 2563.409 181.238 2553.42 178.641 2542.434 178.641 C 2531.247 178.641 2521.159 181.238 2512.17 186.431 C 2503.381 191.425 2496.39 198.615 2491.196 208.005 C 2486.203 217.393 2483.704 228.082 2483.704 240.067 C 2483.704 252.052 2486.203 262.737 2491.196 272.127 C 2496.39 281.516 2503.381 288.806 2512.17 294.001 C 2521.159 298.995 2531.247 301.492 2542.434 301.492 Z" style="stroke: rgb(255, 255, 255); stroke-linecap: round; stroke-linejoin: round; stroke-width: 0px;" fill="#273B49"/>
<path d="M 2668.801 161.261 L 2690.075 161.261 L 2690.075 318.871 L 2668.801 318.871 L 2668.801 161.261 Z M 2679.59 126.803 C 2675.194 126.803 2671.498 125.305 2668.501 122.308 C 2665.505 119.312 2664.006 115.717 2664.006 111.52 C 2664.006 107.526 2665.505 104.031 2668.501 101.035 C 2671.498 98.037 2675.194 96.541 2679.59 96.541 C 2683.985 96.541 2687.681 98.037 2690.676 101.035 C 2693.674 103.831 2695.171 107.226 2695.171 111.221 C 2695.171 115.617 2693.674 119.312 2690.676 122.308 C 2687.681 125.305 2683.985 126.803 2679.59 126.803 Z" style="stroke: rgb(255, 255, 255); stroke-linecap: round; stroke-linejoin: round; stroke-width: 0px;" fill="#273B49"/>
<path d="M 2817.589 320.369 C 2802.009 320.369 2788.023 316.973 2775.638 310.181 C 2763.454 303.389 2753.865 293.901 2746.874 281.715 C 2739.883 269.33 2736.385 255.447 2736.385 240.067 C 2736.385 224.685 2739.883 210.901 2746.874 198.715 C 2753.865 186.531 2763.454 177.042 2775.638 170.251 C 2788.023 163.459 2802.009 160.064 2817.589 160.064 C 2831.174 160.064 2843.257 162.759 2853.844 168.153 C 2864.632 173.346 2873.123 181.038 2879.314 191.225 L 2863.433 202.013 C 2858.24 194.22 2851.646 188.43 2843.657 184.633 C 2835.667 180.638 2826.977 178.641 2817.589 178.641 C 2806.203 178.641 2795.913 181.238 2786.725 186.431 C 2777.737 191.425 2770.646 198.615 2765.451 208.005 C 2760.459 217.393 2757.959 228.082 2757.959 240.067 C 2757.959 252.252 2760.459 263.039 2765.451 272.427 C 2770.646 281.614 2777.737 288.806 2786.725 294.001 C 2795.913 298.995 2806.203 301.492 2817.589 301.492 C 2826.977 301.492 2835.667 299.594 2843.657 295.797 C 2851.646 292.004 2858.24 286.21 2863.433 278.42 L 2879.314 289.206 C 2873.123 299.395 2864.632 307.184 2853.844 312.578 C 2843.057 317.773 2830.971 320.369 2817.589 320.369 Z" style="stroke: rgb(255, 255, 255); stroke-linecap: round; stroke-linejoin: round; stroke-width: 0px;" fill="#273B49"/>
<path d="M 2985.892 320.369 C 2970.71 320.369 2957.028 316.973 2944.84 310.181 C 2932.656 303.19 2923.067 293.601 2916.075 281.415 C 2909.085 269.231 2905.587 255.447 2905.587 240.067 C 2905.587 224.685 2909.085 210.901 2916.075 198.715 C 2923.067 186.531 2932.656 177.042 2944.84 170.251 C 2957.028 163.459 2970.71 160.064 2985.892 160.064 C 3001.073 160.064 3014.757 163.459 3026.941 170.251 C 3039.128 177.042 3048.615 186.531 3055.406 198.715 C 3062.4 210.901 3065.894 224.685 3065.894 240.067 C 3065.894 255.447 3062.4 269.231 3055.406 281.415 C 3048.615 293.601 3039.128 303.19 3026.941 310.181 C 3014.757 316.973 3001.073 320.369 2985.892 320.369 Z M 2985.892 301.492 C 2997.079 301.492 3007.065 298.995 3015.857 294.001 C 3024.845 288.806 3031.834 281.516 3036.831 272.127 C 3041.824 262.737 3044.321 252.052 3044.321 240.067 C 3044.321 228.082 3041.824 217.393 3036.831 208.005 C 3031.834 198.615 3024.845 191.425 3015.857 186.431 C 3007.065 181.238 2997.079 178.641 2985.892 178.641 C 2974.704 178.641 2964.616 181.238 2955.627 186.431 C 2946.838 191.425 2939.848 198.615 2934.654 208.005 C 2929.66 217.393 2927.162 228.082 2927.162 240.067 C 2927.162 252.052 2929.66 262.737 2934.654 272.127 C 2939.848 281.516 2946.838 288.806 2955.627 294.001 C 2964.616 298.995 2974.704 301.492 2985.892 301.492 Z" style="stroke: rgb(255, 255, 255); stroke-linecap: round; stroke-linejoin: round; stroke-width: 0px;" fill="#273B49"/>
<path d="M 3192.627 160.064 C 3212.404 160.064 3228.086 165.856 3239.672 177.441 C 3251.456 188.828 3257.349 205.507 3257.349 227.481 L 3257.349 318.871 L 3236.074 318.871 L 3236.074 229.579 C 3236.074 213.198 3231.98 200.714 3223.79 192.124 C 3215.599 183.535 3203.914 179.24 3188.733 179.24 C 3171.751 179.24 3158.268 184.333 3148.282 194.52 C 3138.492 204.509 3133.597 218.392 3133.597 236.171 L 3133.597 318.871 L 3112.326 318.871 L 3112.326 161.261 L 3132.698 161.261 L 3132.698 190.326 C 3138.492 180.737 3146.484 173.346 3156.671 168.153 C 3167.058 162.759 3179.045 160.064 3192.627 160.064 Z" style="stroke: rgb(255, 255, 255); stroke-linecap: round; stroke-linejoin: round; stroke-width: 0px;" fill="#273B49"/>
</svg> |
0 | capitalone_repos/rubicon-ml/docs/source/_static | capitalone_repos/rubicon-ml/docs/source/_static/images/rubicon_ml_logo_only.svg | <?xml version="1.0" encoding="utf-8"?>
<svg viewBox="2225.974 -45.413 1307.186 1313.609" fill="none" xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient id="paint0_linear" x1="612.729" y1="0" x2="612.729" y2="1224" gradientUnits="userSpaceOnUse">
<stop stop-color="#E2F4FE"/>
<stop offset="1" stop-color="#97D6ED"/>
</linearGradient>
<linearGradient id="paint1_linear" x1="-56.8245" y1="299.696" x2="-4.63461" y2="834.312" gradientUnits="userSpaceOnUse">
<stop stop-color="#019ED5"/>
<stop offset="1" stop-color="#003362"/>
</linearGradient>
<linearGradient id="paint2_linear" x1="746.205" y1="437.978" x2="807.142" y2="893.844" gradientUnits="userSpaceOnUse">
<stop stop-color="#009ED5"/>
<stop offset="1" stop-color="#003362"/>
</linearGradient>
<linearGradient id="paint3_linear" x1="664.533" y1="810.789" x2="704.345" y2="1179.18" gradientUnits="userSpaceOnUse">
<stop stop-color="#009ED5"/>
<stop offset="1" stop-color="#003362"/>
</linearGradient>
</defs>
<mask id="mask0" mask-type="alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="1226" height="1224">
<path d="M612.729 1224C951.129 1224 1225.46 949.998 1225.46 612C1225.46 274.002 951.129 0 612.729 0C274.328 0 0 274.002 0 612C0 949.998 274.328 1224 612.729 1224Z" fill="white"/>
</mask>
<circle style="fill: rgb(255, 255, 255);" cx="2879.961" cy="610.774" r="652.849"/>
<g mask="url(#mask0)" transform="matrix(1, 0, 0, 1, 2266.402832, 2.070756)">
<path d="M612.729 1224C951.129 1224 1225.46 949.998 1225.46 612C1225.46 274.002 951.129 0 612.729 0C274.328 0 0 274.002 0 612C0 949.998 274.328 1224 612.729 1224Z" fill="url(#paint0_linear)"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M837.22 435.232H900.153L1143.78 505.688L1121.3 1031.5L-673.418 804.379L-617.239 770.25C-402.345 639.698 -229.15 541.72 -97.5173 476.264C36.646 409.55 128.11 376.181 180.447 376.181C217.065 376.181 254.259 385.277 294.511 402.507C325.056 415.582 353.008 430.905 397.713 457.78C401.595 460.114 417.778 469.878 421.952 472.386C431.186 477.935 438.529 482.295 445.533 486.37C462.753 496.386 477.103 504.173 490.475 510.623C521.276 525.48 546.32 532.819 568.159 532.819C637.809 532.819 725.913 501.597 831.79 438.47L837.22 435.232Z" stroke-width="45.9" stroke="white" fill="url(#paint1_linear)"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M1330.29 904.593L1209.15 1215.27L364.858 1353.12L-61.2648 1213.57L-219.92 899.462L-145.825 643.856L-9.03537 470.708L6.7009 504.431C55.8427 609.743 146.501 661.864 282.781 661.864C329.547 661.864 381.083 648.428 442.057 621.903C468.145 610.555 495.849 596.896 527.974 579.78C551.638 567.172 563.257 560.723 616.62 530.821C697.141 485.701 739.588 463.402 788.368 442.319C861.983 410.502 926.779 393.919 988.777 393.919C1048.59 393.919 1114.93 410.503 1186.23 441.23C1247.52 467.645 1311.37 504.067 1375.12 547.703C1428.85 584.49 1480.81 625.299 1525.27 664.739C1563.84 698.958 1593.82 729.623 1605.92 747.058C1618.62 765.362 1617.25 786.36 1603.06 804.119C1592.3 817.573 1574.18 829.582 1548.38 841.326C1502.72 862.114 1430.21 883.087 1330.29 904.593Z" stroke-width="45.9" stroke="white" fill="url(#paint2_linear)"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M33.5712 861.045C91.9801 962.446 189.107 1015.46 327.916 1020.61C376.556 1022.42 427.808 1012.52 486.243 991.534C511.304 982.535 537.617 971.552 567.489 957.836C590.296 947.363 608.672 938.464 649.865 918.168C656.14 915.076 658.82 913.756 662.255 912.066C733.629 876.952 773.758 858.73 818.411 842.699C876.877 821.709 929.55 810.789 980.63 810.789C1136.65 810.789 1241.04 887.17 1289.22 1036.5L1295.48 1055.89L553.356 1396.84L-28.9996 1154.5L-51.0364 862.8L25.239 846.58L33.5712 861.045Z" stroke-width="45.9" stroke="white" fill="url(#paint3_linear)"/>
</g>
</svg> |
0 | capitalone_repos/rubicon-ml/docs/source/_static | capitalone_repos/rubicon-ml/docs/source/_static/images/rubicon_ml_logo_offset_dark.svg | <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="5503.0942"
height="1224"
viewBox="0 0 5503.0942 1224"
fill="none"
version="1.1"
id="svg888"
sodipodi:docname="rubicon_ml_logo_offset_dark.svg"
inkscape:version="1.0.2 (e86c8708, 2021-01-15)">
<metadata
id="metadata892">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1680"
inkscape:window-height="997"
id="namedview890"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:zoom="0.10076935"
inkscape:cx="3314.5"
inkscape:cy="612"
inkscape:window-x="0"
inkscape:window-y="25"
inkscape:window-maximized="1"
inkscape:current-layer="svg888" />
<mask
id="mask0"
mask-type="alpha"
maskUnits="userSpaceOnUse"
x="0"
y="0"
width="1226"
height="1224">
<path
d="m 612.729,1224 c 338.4,0 612.731,-274.002 612.731,-612 C 1225.46,274.002 951.129,0 612.729,0 274.328,0 0,274.002 0,612 c 0,337.998 274.328,612 612.729,612 z"
fill="#ffffff"
id="path833" />
</mask>
<g
mask="url(#mask0)"
id="g844">
<path
d="m 612.729,1224 c 338.4,0 612.731,-274.002 612.731,-612 C 1225.46,274.002 951.129,0 612.729,0 274.328,0 0,274.002 0,612 c 0,337.998 274.328,612 612.729,612 z"
fill="url(#paint0_linear)"
id="path836"
style="fill:url(#paint0_linear)" />
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="m 837.22,435.232 h 62.933 L 1143.78,505.688 1121.3,1031.5 -673.418,804.379 -617.239,770.25 C -402.345,639.698 -229.15,541.72 -97.5173,476.264 36.646,409.55 128.11,376.181 180.447,376.181 c 36.618,0 73.812,9.096 114.064,26.326 30.545,13.075 58.497,28.398 103.202,55.273 3.882,2.334 20.065,12.098 24.239,14.606 9.234,5.549 16.577,9.909 23.581,13.984 17.22,10.016 31.57,17.803 44.942,24.253 30.801,14.857 55.845,22.196 77.684,22.196 69.65,0 157.754,-31.222 263.631,-94.349 z"
fill="url(#paint1_linear)"
stroke="#ffffff"
stroke-width="45.9"
id="path838"
style="fill:url(#paint1_linear)" />
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M 1330.29,904.593 1209.15,1215.27 364.858,1353.12 -61.2648,1213.57 -219.92,899.462 -145.825,643.856 -9.03537,470.708 6.7009,504.431 c 49.1418,105.312 139.8001,157.433 276.0801,157.433 46.766,0 98.302,-13.436 159.276,-39.961 26.088,-11.348 53.792,-25.007 85.917,-42.123 23.664,-12.608 35.283,-19.057 88.646,-48.959 80.521,-45.12 122.968,-67.419 171.748,-88.502 73.615,-31.817 138.411,-48.4 200.409,-48.4 59.813,0 126.153,16.584 197.453,47.311 61.29,26.415 125.14,62.837 188.89,106.473 53.73,36.787 105.69,77.596 150.15,117.036 38.57,34.219 68.55,64.884 80.65,82.319 12.7,18.304 11.33,39.302 -2.86,57.061 -10.76,13.454 -28.88,25.463 -54.68,37.207 -45.66,20.788 -118.17,41.761 -218.09,63.267 z"
fill="url(#paint2_linear)"
stroke="#ffffff"
stroke-width="45.9"
id="path840"
style="fill:url(#paint2_linear)" />
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="m 33.5712,861.045 c 58.4089,101.401 155.5358,154.415 294.3448,159.565 48.64,1.81 99.892,-8.09 158.327,-29.076 25.061,-8.999 51.374,-19.982 81.246,-33.698 22.807,-10.473 41.183,-19.372 82.376,-39.668 6.275,-3.092 8.955,-4.412 12.39,-6.102 71.374,-35.114 111.503,-53.336 156.156,-69.367 58.466,-20.99 111.139,-31.91 162.219,-31.91 156.02,0 260.41,76.381 308.59,225.711 l 6.26,19.39 L 553.356,1396.84 -28.9996,1154.5 -51.0364,862.8 25.239,846.58 Z"
fill="url(#paint3_linear)"
stroke="#ffffff"
stroke-width="45.9"
id="path842"
style="fill:url(#paint3_linear)" />
</g>
<path
d="m 4595.942,523.398 h 147.616 v 25.848 h -147.616 z"
fill="#ffffff"
id="path846"
style="stroke-width:0.8" />
<path
d="m 5224.83,388.414 c 37.144,0 66.24,10.9136 87.304,32.7408 21.448,21.8272 32.168,53.228 32.168,94.2016 v 175.192 h -28.72 V 517.654 c 0,-33.6984 -8.232,-59.3544 -24.696,-76.9696 -16.472,-17.6152 -39.448,-26.4224 -68.928,-26.4224 -33.704,0 -60.504,10.5304 -80.416,31.592 -19.536,21.0616 -29.296,49.3984 -29.296,85.0112 v 159.6832 h -28.72 V 517.654 c 0,-33.6984 -8.232,-59.3544 -24.704,-76.9696 -16.464,-17.6152 -39.44,-26.4224 -68.928,-26.4224 -33.696,0 -60.504,10.5304 -80.416,31.592 -19.528,21.0616 -29.288,49.3984 -29.288,85.0112 v 159.6832 h -28.72 V 390.7116 h 27.568 v 64.3328 c 9.952,-21.0616 24.696,-37.336 44.232,-48.824 19.912,-11.8712 43.456,-17.8064 70.648,-17.8064 27.184,0 50.16,6.1272 68.928,18.3808 19.144,12.2544 32.744,30.252 40.784,53.9936 9.952,-22.2104 25.464,-39.8248 46.528,-52.8448 21.44,-13.02 46.328,-19.5296 74.672,-19.5296 z"
fill="#ffffff"
id="path848"
style="stroke-width:0.8" />
<path
d="m 5474.374,264.3436 h 28.72 v 426.2048 h -28.72 z"
fill="#ffffff"
id="path850"
style="stroke-width:0.8" />
<path
d="m 1514.462,341.6252 c 13.304,-28.2104 33,-49.5008 59.08,-63.872 26.608,-14.3712 59.344,-21.5568 98.2,-21.5568 v 55.0896 l -13.568,-0.7984 c -44.184,0 -78.776,13.5728 -103.792,40.7184 -25.016,27.1456 -37.528,65.2024 -37.528,114.1712 v 213.9712 h -56.688 V 259.39 h 54.296 z"
fill="#ffffff"
id="path852"
style="stroke-width:0.8" />
<path
d="M 2167.046,259.39 V 679.3484 H 2112.75 V 602.702 c -14.896,25.5488 -35.392,45.5088 -61.472,59.88 -26.08,13.8392 -55.888,20.7584 -89.424,20.7584 -54.824,0 -98.2,-15.1696 -130.136,-45.5088 -31.408,-30.8712 -47.104,-75.848 -47.104,-134.9296 V 259.39 h 56.68 v 237.9232 c 0,44.1784 10.912,77.7112 32.736,100.5984 21.824,22.8872 52.96,34.3312 93.416,34.3312 44.176,0 79.04,-13.3064 104.592,-39.92 25.544,-27.1456 38.32,-64.6704 38.32,-112.5744 V 259.39 Z"
fill="#ffffff"
id="path854"
style="stroke-width:0.8" />
<path
d="m 2550.158,256.1964 c 39.384,0 75.048,9.0488 106.984,27.1456 31.936,17.5648 56.952,42.5816 75.048,75.0496 18.104,32.468 27.152,69.4608 27.152,110.9776 0,41.5168 -9.048,78.5096 -27.152,110.9776 -18.096,32.468 -43.112,57.7512 -75.048,75.848 -31.936,18.0968 -67.6,27.1456 -106.984,27.1456 -35.128,0 -66.8,-7.452 -95.008,-22.3552 -27.68,-14.9032 -50.032,-36.46 -67.064,-64.6704 v 83.0336 H 2333.79 V 86.9356 h 56.688 V 339.23 c 17.568,-27.1456 39.92,-47.6376 67.064,-61.4768 27.68,-14.3712 58.552,-21.5568 92.616,-21.5568 z m -3.992,376.8448 c 29.272,0 55.888,-6.6536 79.84,-19.96 23.952,-13.8392 42.584,-33.2664 55.888,-58.2832 13.84,-25.0168 20.76,-53.4928 20.76,-85.4288 0,-31.936 -6.92,-60.412 -20.76,-85.4288 -13.304,-25.0168 -31.936,-44.1784 -55.888,-57.4848 -23.952,-13.8392 -50.568,-20.7584 -79.84,-20.7584 -29.808,0 -56.688,6.9192 -80.64,20.7584 -23.416,13.3064 -42.048,32.468 -55.888,57.4848 -13.304,25.0168 -19.96,53.4928 -19.96,85.4288 0,31.936 6.656,60.412 19.96,85.4288 13.84,25.0168 32.472,44.444 55.888,58.2832 23.952,13.3064 50.832,19.96 80.64,19.96 z"
fill="#ffffff"
id="path856"
style="stroke-width:0.8" />
<path
d="m 2882.878,259.39 h 56.688 v 419.9584 h -56.688 z m 28.744,-91.816 c -11.712,0 -21.56,-3.992 -29.544,-11.976 -7.984,-7.984 -11.976,-17.5648 -11.976,-28.7424 0,-10.6456 3.992,-19.96 11.976,-27.944 7.984,-7.984 17.832,-11.976 29.544,-11.976 11.712,0 21.56,3.992 29.544,11.976 7.984,7.452 11.976,16.5 11.976,27.1456 0,11.7096 -3.992,21.5568 -11.976,29.5408 -7.984,7.984 -17.832,11.976 -29.544,11.976 z"
fill="#ffffff"
id="path858"
style="stroke-width:0.8" />
<path
d="m 3279.326,683.3404 c -41.512,0 -78.776,-9.0488 -111.776,-27.1456 -32.464,-18.0968 -58.016,-43.38 -76.648,-75.848 -18.624,-33.0008 -27.944,-69.9928 -27.944,-110.9776 0,-40.9848 9.32,-77.7112 27.944,-110.1792 18.632,-32.468 44.184,-57.7512 76.648,-75.848 33,-18.0968 70.264,-27.1456 111.776,-27.1456 36.2,0 68.4,7.1856 96.608,21.5568 28.744,13.8392 51.368,34.3312 67.864,61.4768 l -42.312,28.7424 c -13.84,-20.7584 -31.408,-36.1944 -52.696,-46.3072 -21.288,-10.6456 -44.448,-15.968 -69.464,-15.968 -30.336,0 -57.752,6.9192 -82.232,20.7584 -23.952,13.3064 -42.848,32.468 -56.688,57.4848 -13.304,25.0168 -19.96,53.4928 -19.96,85.4288 0,32.468 6.656,61.2104 19.96,86.2272 13.84,24.484 32.736,43.6456 56.688,57.4848 24.48,13.3064 51.896,19.96 82.232,19.96 25.016,0 48.176,-5.0568 69.464,-15.1696 21.288,-10.1128 38.856,-25.5488 52.696,-46.3072 l 42.312,28.7424 c -16.496,27.1456 -39.12,47.904 -67.864,62.2752 -28.744,13.8392 -60.944,20.7584 -96.608,20.7584 z"
fill="#ffffff"
id="path860"
style="stroke-width:0.8" />
<path
d="m 3727.782,683.3404 c -40.456,0 -76.912,-9.0488 -109.384,-27.1456 -32.464,-18.6296 -58.016,-44.1784 -76.648,-76.6464 -18.624,-32.468 -27.944,-69.1944 -27.944,-110.1792 0,-40.9848 9.32,-77.7112 27.944,-110.1792 18.632,-32.468 44.184,-57.7512 76.648,-75.848 32.472,-18.0968 68.928,-27.1456 109.384,-27.1456 40.448,0 76.912,9.0488 109.376,27.1456 32.472,18.0968 57.752,43.38 75.848,75.848 18.632,32.468 27.944,69.1944 27.944,110.1792 0,40.9848 -9.312,77.7112 -27.944,110.1792 -18.096,32.468 -43.376,58.0168 -75.848,76.6464 -32.464,18.0968 -68.928,27.1456 -109.376,27.1456 z m 0,-50.2992 c 29.808,0 56.416,-6.6536 79.84,-19.96 23.952,-13.8392 42.576,-33.2664 55.888,-58.2832 13.304,-25.0168 19.96,-53.4928 19.96,-85.4288 0,-31.936 -6.656,-60.412 -19.96,-85.4288 -13.312,-25.0168 -31.936,-44.1784 -55.888,-57.4848 -23.424,-13.8392 -50.032,-20.7584 -79.84,-20.7584 -29.808,0 -56.688,6.9192 -80.64,20.7584 -23.424,13.3064 -42.048,32.468 -55.888,57.4848 -13.304,25.0168 -19.96,53.4928 -19.96,85.4288 0,31.936 6.656,60.412 19.96,85.4288 13.84,25.0168 32.464,44.444 55.888,58.2832 23.952,13.3064 50.832,19.96 80.64,19.96 z"
fill="#ffffff"
id="path862"
style="stroke-width:0.8" />
<path
d="m 4278.638,256.1964 c 52.696,0 94.48,15.436 125.352,46.3072 31.4,30.3392 47.104,74.7832 47.104,133.3328 v 243.512 h -56.688 V 441.4252 c 0,-43.6456 -10.912,-76.9128 -32.736,-99.8 -21.824,-22.8872 -52.96,-34.3312 -93.408,-34.3312 -45.248,0 -81.176,13.5728 -107.784,40.7184 -26.088,26.6136 -39.128,63.6056 -39.128,110.9776 v 220.3584 h -56.68 V 259.39 h 54.288 v 77.4448 c 15.432,-25.5488 36.728,-45.2424 63.872,-59.0816 27.68,-14.3712 59.616,-21.5568 95.808,-21.5568 z"
fill="#ffffff"
id="path864"
style="stroke-width:0.8" />
<defs
id="defs886">
<linearGradient
id="paint0_linear"
x1="612.729"
y1="0"
x2="612.729"
y2="1224"
gradientUnits="userSpaceOnUse">
<stop
stop-color="#E2F4FE"
id="stop866" />
<stop
offset="1"
stop-color="#97D6ED"
id="stop868" />
</linearGradient>
<linearGradient
id="paint1_linear"
x1="-56.824501"
y1="299.69601"
x2="-4.6346102"
y2="834.31201"
gradientUnits="userSpaceOnUse">
<stop
stop-color="#019ED5"
id="stop871" />
<stop
offset="1"
stop-color="#003362"
id="stop873" />
</linearGradient>
<linearGradient
id="paint2_linear"
x1="746.20502"
y1="437.978"
x2="807.14203"
y2="893.84399"
gradientUnits="userSpaceOnUse">
<stop
stop-color="#009ED5"
id="stop876" />
<stop
offset="1"
stop-color="#003362"
id="stop878" />
</linearGradient>
<linearGradient
id="paint3_linear"
x1="664.53302"
y1="810.789"
x2="704.34497"
y2="1179.1801"
gradientUnits="userSpaceOnUse">
<stop
stop-color="#009ED5"
id="stop881" />
<stop
offset="1"
stop-color="#003362"
id="stop883" />
</linearGradient>
</defs>
</svg>
|
0 | capitalone_repos/rubicon-ml/docs/source/_static | capitalone_repos/rubicon-ml/docs/source/_static/images/rubicon_ml_logo_offset_light.svg | <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="5483.0942"
height="1224"
viewBox="0 0 5483.0942 1224"
fill="none"
version="1.1"
id="svg2195"
sodipodi:docname="rubicon_ml_logo_offset_light.svg"
inkscape:version="1.0.2 (e86c8708, 2021-01-15)">
<metadata
id="metadata2199">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1680"
inkscape:window-height="997"
id="namedview2197"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:zoom="0.15869664"
inkscape:cx="3314.5"
inkscape:cy="612"
inkscape:window-x="0"
inkscape:window-y="25"
inkscape:window-maximized="1"
inkscape:current-layer="svg2195" />
<mask
id="mask0"
mask-type="alpha"
maskUnits="userSpaceOnUse"
x="0"
y="0"
width="1226"
height="1224">
<path
d="m 612.729,1224 c 338.4,0 612.731,-274.002 612.731,-612 C 1225.46,274.002 951.129,0 612.729,0 274.328,0 0,274.002 0,612 c 0,337.998 274.328,612 612.729,612 z"
fill="#ffffff"
id="path2140" />
</mask>
<g
mask="url(#mask0)"
id="g2151">
<path
d="m 612.729,1224 c 338.4,0 612.731,-274.002 612.731,-612 C 1225.46,274.002 951.129,0 612.729,0 274.328,0 0,274.002 0,612 c 0,337.998 274.328,612 612.729,612 z"
fill="url(#paint0_linear)"
id="path2143"
style="fill:url(#paint0_linear)" />
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="m 837.22,435.232 h 62.933 L 1143.78,505.688 1121.3,1031.5 -673.418,804.379 -617.239,770.25 C -402.345,639.698 -229.15,541.72 -97.5173,476.264 36.646,409.55 128.11,376.181 180.447,376.181 c 36.618,0 73.812,9.096 114.064,26.326 30.545,13.075 58.497,28.398 103.202,55.273 3.882,2.334 20.065,12.098 24.239,14.606 9.234,5.549 16.577,9.909 23.581,13.984 17.22,10.016 31.57,17.803 44.942,24.253 30.801,14.857 55.845,22.196 77.684,22.196 69.65,0 157.754,-31.222 263.631,-94.349 z"
fill="url(#paint1_linear)"
stroke="#ffffff"
stroke-width="45.9"
id="path2145"
style="fill:url(#paint1_linear)" />
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M 1330.29,904.593 1209.15,1215.27 364.858,1353.12 -61.2648,1213.57 -219.92,899.462 -145.825,643.856 -9.03537,470.708 6.7009,504.431 c 49.1418,105.312 139.8001,157.433 276.0801,157.433 46.766,0 98.302,-13.436 159.276,-39.961 26.088,-11.348 53.792,-25.007 85.917,-42.123 23.664,-12.608 35.283,-19.057 88.646,-48.959 80.521,-45.12 122.968,-67.419 171.748,-88.502 73.615,-31.817 138.411,-48.4 200.409,-48.4 59.813,0 126.153,16.584 197.453,47.311 61.29,26.415 125.14,62.837 188.89,106.473 53.73,36.787 105.69,77.596 150.15,117.036 38.57,34.219 68.55,64.884 80.65,82.319 12.7,18.304 11.33,39.302 -2.86,57.061 -10.76,13.454 -28.88,25.463 -54.68,37.207 -45.66,20.788 -118.17,41.761 -218.09,63.267 z"
fill="url(#paint2_linear)"
stroke="#ffffff"
stroke-width="45.9"
id="path2147"
style="fill:url(#paint2_linear)" />
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="m 33.5712,861.045 c 58.4089,101.401 155.5358,154.415 294.3448,159.565 48.64,1.81 99.892,-8.09 158.327,-29.076 25.061,-8.999 51.374,-19.982 81.246,-33.698 22.807,-10.473 41.183,-19.372 82.376,-39.668 6.275,-3.092 8.955,-4.412 12.39,-6.102 71.374,-35.114 111.503,-53.336 156.156,-69.367 58.466,-20.99 111.139,-31.91 162.219,-31.91 156.02,0 260.41,76.381 308.59,225.711 l 6.26,19.39 L 553.356,1396.84 -28.9996,1154.5 -51.0364,862.8 25.239,846.58 Z"
fill="url(#paint3_linear)"
stroke="#ffffff"
stroke-width="45.9"
id="path2149"
style="fill:url(#paint3_linear)" />
</g>
<path
d="m 4575.942,523.398 h 147.616 v 25.848 h -147.616 z"
fill="#273b49"
id="path2153"
style="stroke-width:0.8" />
<path
d="m 5204.83,388.414 c 37.144,0 66.24,10.9136 87.304,32.7408 21.448,21.8272 32.168,53.228 32.168,94.2016 v 175.192 h -28.72 V 517.654 c 0,-33.6984 -8.232,-59.3544 -24.696,-76.9696 -16.472,-17.6152 -39.448,-26.4224 -68.928,-26.4224 -33.704,0 -60.504,10.5304 -80.416,31.592 -19.536,21.0616 -29.296,49.3984 -29.296,85.0112 v 159.6832 h -28.72 V 517.654 c 0,-33.6984 -8.232,-59.3544 -24.704,-76.9696 -16.464,-17.6152 -39.44,-26.4224 -68.928,-26.4224 -33.696,0 -60.504,10.5304 -80.416,31.592 -19.528,21.0616 -29.288,49.3984 -29.288,85.0112 v 159.6832 h -28.72 V 390.7116 h 27.568 v 64.3328 c 9.952,-21.0616 24.696,-37.336 44.232,-48.824 19.912,-11.8712 43.456,-17.8064 70.648,-17.8064 27.184,0 50.16,6.1272 68.928,18.3808 19.144,12.2544 32.744,30.252 40.784,53.9936 9.952,-22.2104 25.464,-39.8248 46.528,-52.8448 21.44,-13.02 46.328,-19.5296 74.672,-19.5296 z"
fill="#273b49"
id="path2155"
style="stroke-width:0.8" />
<path
d="m 5454.374,264.3436 h 28.72 v 426.2048 h -28.72 z"
fill="#273b49"
id="path2157"
style="stroke-width:0.8" />
<path
d="m 1494.462,341.6252 c 13.304,-28.2104 33,-49.5008 59.08,-63.872 26.608,-14.3712 59.344,-21.5568 98.2,-21.5568 v 55.0896 l -13.568,-0.7984 c -44.184,0 -78.776,13.5728 -103.792,40.7184 -25.016,27.1456 -37.528,65.2024 -37.528,114.1712 v 213.9712 h -56.688 V 259.39 h 54.296 z"
fill="#273b49"
id="path2159"
style="stroke-width:0.8" />
<path
d="M 2147.046,259.39 V 679.3484 H 2092.75 V 602.702 c -14.896,25.5488 -35.392,45.5088 -61.472,59.88 -26.08,13.8392 -55.888,20.7584 -89.424,20.7584 -54.824,0 -98.2,-15.1696 -130.136,-45.5088 -31.408,-30.8712 -47.104,-75.848 -47.104,-134.9296 V 259.39 h 56.68 v 237.9232 c 0,44.1784 10.912,77.7112 32.736,100.5984 21.824,22.8872 52.96,34.3312 93.416,34.3312 44.176,0 79.04,-13.3064 104.592,-39.92 25.544,-27.1456 38.32,-64.6704 38.32,-112.5744 V 259.39 Z"
fill="#273b49"
id="path2161"
style="stroke-width:0.8" />
<path
d="m 2530.158,256.1964 c 39.384,0 75.048,9.0488 106.984,27.1456 31.936,17.5648 56.952,42.5816 75.048,75.0496 18.104,32.468 27.152,69.4608 27.152,110.9776 0,41.5168 -9.048,78.5096 -27.152,110.9776 -18.096,32.468 -43.112,57.7512 -75.048,75.848 -31.936,18.0968 -67.6,27.1456 -106.984,27.1456 -35.128,0 -66.8,-7.452 -95.008,-22.3552 -27.68,-14.9032 -50.032,-36.46 -67.064,-64.6704 v 83.0336 H 2313.79 V 86.9356 h 56.688 V 339.23 c 17.568,-27.1456 39.92,-47.6376 67.064,-61.4768 27.68,-14.3712 58.552,-21.5568 92.616,-21.5568 z m -3.992,376.8448 c 29.272,0 55.888,-6.6536 79.84,-19.96 23.952,-13.8392 42.584,-33.2664 55.888,-58.2832 13.84,-25.0168 20.76,-53.4928 20.76,-85.4288 0,-31.936 -6.92,-60.412 -20.76,-85.4288 -13.304,-25.0168 -31.936,-44.1784 -55.888,-57.4848 -23.952,-13.8392 -50.568,-20.7584 -79.84,-20.7584 -29.808,0 -56.688,6.9192 -80.64,20.7584 -23.416,13.3064 -42.048,32.468 -55.888,57.4848 -13.304,25.0168 -19.96,53.4928 -19.96,85.4288 0,31.936 6.656,60.412 19.96,85.4288 13.84,25.0168 32.472,44.444 55.888,58.2832 23.952,13.3064 50.832,19.96 80.64,19.96 z"
fill="#273b49"
id="path2163"
style="stroke-width:0.8" />
<path
d="m 2862.878,259.39 h 56.688 v 419.9584 h -56.688 z m 28.744,-91.816 c -11.712,0 -21.56,-3.992 -29.544,-11.976 -7.984,-7.984 -11.976,-17.5648 -11.976,-28.7424 0,-10.6456 3.992,-19.96 11.976,-27.944 7.984,-7.984 17.832,-11.976 29.544,-11.976 11.712,0 21.56,3.992 29.544,11.976 7.984,7.452 11.976,16.5 11.976,27.1456 0,11.7096 -3.992,21.5568 -11.976,29.5408 -7.984,7.984 -17.832,11.976 -29.544,11.976 z"
fill="#273b49"
id="path2165"
style="stroke-width:0.8" />
<path
d="m 3259.326,683.3404 c -41.512,0 -78.776,-9.0488 -111.776,-27.1456 -32.464,-18.0968 -58.016,-43.38 -76.648,-75.848 -18.624,-33.0008 -27.944,-69.9928 -27.944,-110.9776 0,-40.9848 9.32,-77.7112 27.944,-110.1792 18.632,-32.468 44.184,-57.7512 76.648,-75.848 33,-18.0968 70.264,-27.1456 111.776,-27.1456 36.2,0 68.4,7.1856 96.608,21.5568 28.744,13.8392 51.368,34.3312 67.864,61.4768 l -42.312,28.7424 c -13.84,-20.7584 -31.408,-36.1944 -52.696,-46.3072 -21.288,-10.6456 -44.448,-15.968 -69.464,-15.968 -30.336,0 -57.752,6.9192 -82.232,20.7584 -23.952,13.3064 -42.848,32.468 -56.688,57.4848 -13.304,25.0168 -19.96,53.4928 -19.96,85.4288 0,32.468 6.656,61.2104 19.96,86.2272 13.84,24.484 32.736,43.6456 56.688,57.4848 24.48,13.3064 51.896,19.96 82.232,19.96 25.016,0 48.176,-5.0568 69.464,-15.1696 21.288,-10.1128 38.856,-25.5488 52.696,-46.3072 l 42.312,28.7424 c -16.496,27.1456 -39.12,47.904 -67.864,62.2752 -28.744,13.8392 -60.944,20.7584 -96.608,20.7584 z"
fill="#273b49"
id="path2167"
style="stroke-width:0.8" />
<path
d="m 3707.782,683.3404 c -40.456,0 -76.912,-9.0488 -109.384,-27.1456 -32.464,-18.6296 -58.016,-44.1784 -76.648,-76.6464 -18.624,-32.468 -27.944,-69.1944 -27.944,-110.1792 0,-40.9848 9.32,-77.7112 27.944,-110.1792 18.632,-32.468 44.184,-57.7512 76.648,-75.848 32.472,-18.0968 68.928,-27.1456 109.384,-27.1456 40.448,0 76.912,9.0488 109.376,27.1456 32.472,18.0968 57.752,43.38 75.848,75.848 18.632,32.468 27.944,69.1944 27.944,110.1792 0,40.9848 -9.312,77.7112 -27.944,110.1792 -18.096,32.468 -43.376,58.0168 -75.848,76.6464 -32.464,18.0968 -68.928,27.1456 -109.376,27.1456 z m 0,-50.2992 c 29.808,0 56.416,-6.6536 79.84,-19.96 23.952,-13.8392 42.576,-33.2664 55.888,-58.2832 13.304,-25.0168 19.96,-53.4928 19.96,-85.4288 0,-31.936 -6.656,-60.412 -19.96,-85.4288 -13.312,-25.0168 -31.936,-44.1784 -55.888,-57.4848 -23.424,-13.8392 -50.032,-20.7584 -79.84,-20.7584 -29.808,0 -56.688,6.9192 -80.64,20.7584 -23.424,13.3064 -42.048,32.468 -55.888,57.4848 -13.304,25.0168 -19.96,53.4928 -19.96,85.4288 0,31.936 6.656,60.412 19.96,85.4288 13.84,25.0168 32.464,44.444 55.888,58.2832 23.952,13.3064 50.832,19.96 80.64,19.96 z"
fill="#273b49"
id="path2169"
style="stroke-width:0.8" />
<path
d="m 4258.638,256.1964 c 52.696,0 94.48,15.436 125.352,46.3072 31.4,30.3392 47.104,74.7832 47.104,133.3328 v 243.512 h -56.688 V 441.4252 c 0,-43.6456 -10.912,-76.9128 -32.736,-99.8 -21.824,-22.8872 -52.96,-34.3312 -93.408,-34.3312 -45.248,0 -81.176,13.5728 -107.784,40.7184 -26.088,26.6136 -39.128,63.6056 -39.128,110.9776 v 220.3584 h -56.68 V 259.39 h 54.288 v 77.4448 c 15.432,-25.5488 36.728,-45.2424 63.872,-59.0816 27.68,-14.3712 59.616,-21.5568 95.808,-21.5568 z"
fill="#273b49"
id="path2171"
style="stroke-width:0.8" />
<defs
id="defs2193">
<linearGradient
id="paint0_linear"
x1="612.729"
y1="0"
x2="612.729"
y2="1224"
gradientUnits="userSpaceOnUse">
<stop
stop-color="#E2F4FE"
id="stop2173" />
<stop
offset="1"
stop-color="#97D6ED"
id="stop2175" />
</linearGradient>
<linearGradient
id="paint1_linear"
x1="-56.824501"
y1="299.69601"
x2="-4.6346102"
y2="834.31201"
gradientUnits="userSpaceOnUse">
<stop
stop-color="#019ED5"
id="stop2178" />
<stop
offset="1"
stop-color="#003362"
id="stop2180" />
</linearGradient>
<linearGradient
id="paint2_linear"
x1="746.20502"
y1="437.978"
x2="807.14203"
y2="893.84399"
gradientUnits="userSpaceOnUse">
<stop
stop-color="#009ED5"
id="stop2183" />
<stop
offset="1"
stop-color="#003362"
id="stop2185" />
</linearGradient>
<linearGradient
id="paint3_linear"
x1="664.53302"
y1="810.789"
x2="704.34497"
y2="1179.1801"
gradientUnits="userSpaceOnUse">
<stop
stop-color="#009ED5"
id="stop2188" />
<stop
offset="1"
stop-color="#003362"
id="stop2190" />
</linearGradient>
</defs>
</svg>
|
0 | capitalone_repos/rubicon-ml/docs/source/_static | capitalone_repos/rubicon-ml/docs/source/_static/images/rubicon_ml_logo_dark.svg | <svg width="6629" height="1224" viewBox="0 0 6629 1224" fill="none" xmlns="http://www.w3.org/2000/svg">
<mask id="mask0" mask-type="alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="1226" height="1224">
<path d="M612.729 1224C951.129 1224 1225.46 949.998 1225.46 612C1225.46 274.002 951.129 0 612.729 0C274.328 0 0 274.002 0 612C0 949.998 274.328 1224 612.729 1224Z" fill="white"/>
</mask>
<g mask="url(#mask0)">
<path d="M612.729 1224C951.129 1224 1225.46 949.998 1225.46 612C1225.46 274.002 951.129 0 612.729 0C274.328 0 0 274.002 0 612C0 949.998 274.328 1224 612.729 1224Z" fill="url(#paint0_linear)"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M837.22 435.232H900.153L1143.78 505.688L1121.3 1031.5L-673.418 804.379L-617.239 770.25C-402.345 639.698 -229.15 541.72 -97.5173 476.264C36.646 409.55 128.11 376.181 180.447 376.181C217.065 376.181 254.259 385.277 294.511 402.507C325.056 415.582 353.008 430.905 397.713 457.78C401.595 460.114 417.778 469.878 421.952 472.386C431.186 477.935 438.529 482.295 445.533 486.37C462.753 496.386 477.103 504.173 490.475 510.623C521.276 525.48 546.32 532.819 568.159 532.819C637.809 532.819 725.913 501.597 831.79 438.47L837.22 435.232Z" fill="url(#paint1_linear)" stroke="white" stroke-width="45.9"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M1330.29 904.593L1209.15 1215.27L364.858 1353.12L-61.2648 1213.57L-219.92 899.462L-145.825 643.856L-9.03537 470.708L6.7009 504.431C55.8427 609.743 146.501 661.864 282.781 661.864C329.547 661.864 381.083 648.428 442.057 621.903C468.145 610.555 495.849 596.896 527.974 579.78C551.638 567.172 563.257 560.723 616.62 530.821C697.141 485.701 739.588 463.402 788.368 442.319C861.983 410.502 926.779 393.919 988.777 393.919C1048.59 393.919 1114.93 410.503 1186.23 441.23C1247.52 467.645 1311.37 504.067 1375.12 547.703C1428.85 584.49 1480.81 625.299 1525.27 664.739C1563.84 698.958 1593.82 729.623 1605.92 747.058C1618.62 765.362 1617.25 786.36 1603.06 804.119C1592.3 817.573 1574.18 829.582 1548.38 841.326C1502.72 862.114 1430.21 883.087 1330.29 904.593Z" fill="url(#paint2_linear)" stroke="white" stroke-width="45.9"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M33.5712 861.045C91.9801 962.446 189.107 1015.46 327.916 1020.61C376.556 1022.42 427.808 1012.52 486.243 991.534C511.304 982.535 537.617 971.552 567.489 957.836C590.296 947.363 608.672 938.464 649.865 918.168C656.14 915.076 658.82 913.756 662.255 912.066C733.629 876.952 773.758 858.73 818.411 842.699C876.877 821.709 929.55 810.789 980.63 810.789C1136.65 810.789 1241.04 887.17 1289.22 1036.5L1295.48 1055.89L553.356 1396.84L-28.9996 1154.5L-51.0364 862.8L25.239 846.58L33.5712 861.045Z" fill="url(#paint3_linear)" stroke="white" stroke-width="45.9"/>
</g>
<path d="M5494.52 757.062H5679.04V789.372H5494.52V757.062Z" fill="#ffffff"/>
<path d="M6280.63 588.332C6327.06 588.332 6363.43 601.974 6389.76 629.258C6416.57 656.542 6429.97 695.793 6429.97 747.01V966H6394.07V749.882C6394.07 707.759 6383.78 675.689 6363.2 653.67C6342.61 631.651 6313.89 620.642 6277.04 620.642C6234.91 620.642 6201.41 633.805 6176.52 660.132C6152.1 686.459 6139.9 721.88 6139.9 766.396V966H6104V749.882C6104 707.759 6093.71 675.689 6073.12 653.67C6052.54 631.651 6023.82 620.642 5986.96 620.642C5944.84 620.642 5911.33 633.805 5886.44 660.132C5862.03 686.459 5849.83 721.88 5849.83 766.396V966H5813.93V591.204H5848.39V671.62C5860.83 645.293 5879.26 624.95 5903.68 610.59C5928.57 595.751 5958 588.332 5991.99 588.332C6025.97 588.332 6054.69 595.991 6078.15 611.308C6102.08 626.626 6119.08 649.123 6129.13 678.8C6141.57 651.037 6160.96 629.019 6187.29 612.744C6214.09 596.469 6245.2 588.332 6280.63 588.332Z" fill="#ffffff"/>
<path d="M6592.56 433.244H6628.46V966H6592.56V433.244Z" fill="#ffffff"/>
<path d="M1642.67 529.846C1659.3 494.583 1683.92 467.97 1716.52 450.006C1749.78 432.042 1790.7 423.06 1839.27 423.06V491.922L1822.31 490.924C1767.08 490.924 1723.84 507.89 1692.57 541.822C1661.3 575.754 1645.66 623.325 1645.66 684.536V952H1574.8V427.052H1642.67V529.846Z" fill="#ffffff"/>
<path d="M2458.4 427.052V952H2390.53V856.192C2371.91 888.128 2346.29 913.078 2313.69 931.042C2281.09 948.341 2243.83 956.99 2201.91 956.99C2133.38 956.99 2079.16 938.028 2039.24 900.104C1999.98 861.515 1980.36 805.294 1980.36 731.442V427.052H2051.21V724.456C2051.21 779.679 2064.85 821.595 2092.13 850.204C2119.41 878.813 2158.33 893.118 2208.9 893.118C2264.12 893.118 2307.7 876.485 2339.64 843.218C2371.57 809.286 2387.54 762.38 2387.54 702.5V427.052H2458.4Z" fill="#ffffff"/>
<path d="M2937.29 423.06C2986.52 423.06 3031.1 434.371 3071.02 456.992C3110.94 478.948 3142.21 510.219 3164.83 550.804C3187.46 591.389 3198.77 637.63 3198.77 689.526C3198.77 741.422 3187.46 787.663 3164.83 828.248C3142.21 868.833 3110.94 900.437 3071.02 923.058C3031.1 945.679 2986.52 956.99 2937.29 956.99C2893.38 956.99 2853.79 947.675 2818.53 929.046C2783.93 910.417 2755.99 883.471 2734.7 848.208V952H2666.83V211.484H2737.69V526.852C2759.65 492.92 2787.59 467.305 2821.52 450.006C2856.12 432.042 2894.71 423.06 2937.29 423.06ZM2932.3 894.116C2968.89 894.116 3002.16 885.799 3032.1 869.166C3062.04 851.867 3085.33 827.583 3101.96 796.312C3119.26 765.041 3127.91 729.446 3127.91 689.526C3127.91 649.606 3119.26 614.011 3101.96 582.74C3085.33 551.469 3062.04 527.517 3032.1 510.884C3002.16 493.585 2968.89 484.936 2932.3 484.936C2895.04 484.936 2861.44 493.585 2831.5 510.884C2802.23 527.517 2778.94 551.469 2761.64 582.74C2745.01 614.011 2736.69 649.606 2736.69 689.526C2736.69 729.446 2745.01 765.041 2761.64 796.312C2778.94 827.583 2802.23 851.867 2831.5 869.166C2861.44 885.799 2895.04 894.116 2932.3 894.116Z" fill="#ffffff"/>
<path d="M3353.19 427.052H3424.05V952H3353.19V427.052ZM3389.12 312.282C3374.48 312.282 3362.17 307.292 3352.19 297.312C3342.21 287.332 3337.22 275.356 3337.22 261.384C3337.22 248.077 3342.21 236.434 3352.19 226.454C3362.17 216.474 3374.48 211.484 3389.12 211.484C3403.76 211.484 3416.07 216.474 3426.05 226.454C3436.03 235.769 3441.02 247.079 3441.02 260.386C3441.02 275.023 3436.03 287.332 3426.05 297.312C3416.07 307.292 3403.76 312.282 3389.12 312.282Z" fill="#ffffff"/>
<path d="M3848.75 956.99C3796.86 956.99 3750.28 945.679 3709.03 923.058C3668.45 900.437 3636.51 868.833 3613.22 828.248C3589.94 786.997 3578.29 740.757 3578.29 689.526C3578.29 638.295 3589.94 592.387 3613.22 551.802C3636.51 511.217 3668.45 479.613 3709.03 456.992C3750.28 434.371 3796.86 423.06 3848.75 423.06C3894 423.06 3934.25 432.042 3969.51 450.006C4005.44 467.305 4033.72 492.92 4054.34 526.852L4001.45 562.78C3984.15 536.832 3962.19 517.537 3935.58 504.896C3908.97 491.589 3880.02 484.936 3848.75 484.936C3810.83 484.936 3776.56 493.585 3745.96 510.884C3716.02 527.517 3692.4 551.469 3675.1 582.74C3658.47 614.011 3650.15 649.606 3650.15 689.526C3650.15 730.111 3658.47 766.039 3675.1 797.31C3692.4 827.915 3716.02 851.867 3745.96 869.166C3776.56 885.799 3810.83 894.116 3848.75 894.116C3880.02 894.116 3908.97 887.795 3935.58 875.154C3962.19 862.513 3984.15 843.218 4001.45 817.27L4054.34 853.198C4033.72 887.13 4005.44 913.078 3969.51 931.042C3933.58 948.341 3893.33 956.99 3848.75 956.99Z" fill="#ffffff"/>
<path d="M4409.32 956.99C4358.75 956.99 4313.18 945.679 4272.59 923.058C4232.01 899.771 4200.07 867.835 4176.78 827.25C4153.5 786.665 4141.85 740.757 4141.85 689.526C4141.85 638.295 4153.5 592.387 4176.78 551.802C4200.07 511.217 4232.01 479.613 4272.59 456.992C4313.18 434.371 4358.75 423.06 4409.32 423.06C4459.88 423.06 4505.46 434.371 4546.04 456.992C4586.63 479.613 4618.23 511.217 4640.85 551.802C4664.14 592.387 4675.78 638.295 4675.78 689.526C4675.78 740.757 4664.14 786.665 4640.85 827.25C4618.23 867.835 4586.63 899.771 4546.04 923.058C4505.46 945.679 4459.88 956.99 4409.32 956.99ZM4409.32 894.116C4446.58 894.116 4479.84 885.799 4509.12 869.166C4539.06 851.867 4562.34 827.583 4578.98 796.312C4595.61 765.041 4603.93 729.446 4603.93 689.526C4603.93 649.606 4595.61 614.011 4578.98 582.74C4562.34 551.469 4539.06 527.517 4509.12 510.884C4479.84 493.585 4446.58 484.936 4409.32 484.936C4372.06 484.936 4338.46 493.585 4308.52 510.884C4279.24 527.517 4255.96 551.469 4238.66 582.74C4222.03 614.011 4213.71 649.606 4213.71 689.526C4213.71 729.446 4222.03 765.041 4238.66 796.312C4255.96 827.583 4279.24 851.867 4308.52 869.166C4338.46 885.799 4372.06 894.116 4409.32 894.116Z" fill="#ffffff"/>
<path d="M5097.89 423.06C5163.76 423.06 5215.99 442.355 5254.58 480.944C5293.83 518.868 5313.46 574.423 5313.46 647.61V952H5242.6V654.596C5242.6 600.039 5228.96 558.455 5201.68 529.846C5174.4 501.237 5135.48 486.932 5084.92 486.932C5028.36 486.932 4983.45 503.898 4950.19 537.83C4917.58 571.097 4901.28 617.337 4901.28 676.552V952H4830.43V427.052H4898.29V523.858C4917.58 491.922 4944.2 467.305 4978.13 450.006C5012.73 432.042 5052.65 423.06 5097.89 423.06Z" fill="#ffffff"/>
<defs>
<linearGradient id="paint0_linear" x1="612.729" y1="0" x2="612.729" y2="1224" gradientUnits="userSpaceOnUse">
<stop stop-color="#E2F4FE"/>
<stop offset="1" stop-color="#97D6ED"/>
</linearGradient>
<linearGradient id="paint1_linear" x1="-56.8245" y1="299.696" x2="-4.63461" y2="834.312" gradientUnits="userSpaceOnUse">
<stop stop-color="#019ED5"/>
<stop offset="1" stop-color="#003362"/>
</linearGradient>
<linearGradient id="paint2_linear" x1="746.205" y1="437.978" x2="807.142" y2="893.844" gradientUnits="userSpaceOnUse">
<stop stop-color="#009ED5"/>
<stop offset="1" stop-color="#003362"/>
</linearGradient>
<linearGradient id="paint3_linear" x1="664.533" y1="810.789" x2="704.345" y2="1179.18" gradientUnits="userSpaceOnUse">
<stop stop-color="#009ED5"/>
<stop offset="1" stop-color="#003362"/>
</linearGradient>
</defs>
</svg>
|
0 | capitalone_repos/rubicon-ml/docs/source/_static | capitalone_repos/rubicon-ml/docs/source/_static/images/rubicon_ml_logo_light.svg | <svg width="6629" height="1224" viewBox="0 0 6629 1224" fill="none" xmlns="http://www.w3.org/2000/svg">
<mask id="mask0" mask-type="alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="1226" height="1224">
<path d="M612.729 1224C951.129 1224 1225.46 949.998 1225.46 612C1225.46 274.002 951.129 0 612.729 0C274.328 0 0 274.002 0 612C0 949.998 274.328 1224 612.729 1224Z" fill="white"/>
</mask>
<g mask="url(#mask0)">
<path d="M612.729 1224C951.129 1224 1225.46 949.998 1225.46 612C1225.46 274.002 951.129 0 612.729 0C274.328 0 0 274.002 0 612C0 949.998 274.328 1224 612.729 1224Z" fill="url(#paint0_linear)"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M837.22 435.232H900.153L1143.78 505.688L1121.3 1031.5L-673.418 804.379L-617.239 770.25C-402.345 639.698 -229.15 541.72 -97.5173 476.264C36.646 409.55 128.11 376.181 180.447 376.181C217.065 376.181 254.259 385.277 294.511 402.507C325.056 415.582 353.008 430.905 397.713 457.78C401.595 460.114 417.778 469.878 421.952 472.386C431.186 477.935 438.529 482.295 445.533 486.37C462.753 496.386 477.103 504.173 490.475 510.623C521.276 525.48 546.32 532.819 568.159 532.819C637.809 532.819 725.913 501.597 831.79 438.47L837.22 435.232Z" fill="url(#paint1_linear)" stroke="white" stroke-width="45.9"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M1330.29 904.593L1209.15 1215.27L364.858 1353.12L-61.2648 1213.57L-219.92 899.462L-145.825 643.856L-9.03537 470.708L6.7009 504.431C55.8427 609.743 146.501 661.864 282.781 661.864C329.547 661.864 381.083 648.428 442.057 621.903C468.145 610.555 495.849 596.896 527.974 579.78C551.638 567.172 563.257 560.723 616.62 530.821C697.141 485.701 739.588 463.402 788.368 442.319C861.983 410.502 926.779 393.919 988.777 393.919C1048.59 393.919 1114.93 410.503 1186.23 441.23C1247.52 467.645 1311.37 504.067 1375.12 547.703C1428.85 584.49 1480.81 625.299 1525.27 664.739C1563.84 698.958 1593.82 729.623 1605.92 747.058C1618.62 765.362 1617.25 786.36 1603.06 804.119C1592.3 817.573 1574.18 829.582 1548.38 841.326C1502.72 862.114 1430.21 883.087 1330.29 904.593Z" fill="url(#paint2_linear)" stroke="white" stroke-width="45.9"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M33.5712 861.045C91.9801 962.446 189.107 1015.46 327.916 1020.61C376.556 1022.42 427.808 1012.52 486.243 991.534C511.304 982.535 537.617 971.552 567.489 957.836C590.296 947.363 608.672 938.464 649.865 918.168C656.14 915.076 658.82 913.756 662.255 912.066C733.629 876.952 773.758 858.73 818.411 842.699C876.877 821.709 929.55 810.789 980.63 810.789C1136.65 810.789 1241.04 887.17 1289.22 1036.5L1295.48 1055.89L553.356 1396.84L-28.9996 1154.5L-51.0364 862.8L25.239 846.58L33.5712 861.045Z" fill="url(#paint3_linear)" stroke="white" stroke-width="45.9"/>
</g>
<path d="M5494.52 757.062H5679.04V789.372H5494.52V757.062Z" fill="#273B49"/>
<path d="M6280.63 588.332C6327.06 588.332 6363.43 601.974 6389.76 629.258C6416.57 656.542 6429.97 695.793 6429.97 747.01V966H6394.07V749.882C6394.07 707.759 6383.78 675.689 6363.2 653.67C6342.61 631.651 6313.89 620.642 6277.04 620.642C6234.91 620.642 6201.41 633.805 6176.52 660.132C6152.1 686.459 6139.9 721.88 6139.9 766.396V966H6104V749.882C6104 707.759 6093.71 675.689 6073.12 653.67C6052.54 631.651 6023.82 620.642 5986.96 620.642C5944.84 620.642 5911.33 633.805 5886.44 660.132C5862.03 686.459 5849.83 721.88 5849.83 766.396V966H5813.93V591.204H5848.39V671.62C5860.83 645.293 5879.26 624.95 5903.68 610.59C5928.57 595.751 5958 588.332 5991.99 588.332C6025.97 588.332 6054.69 595.991 6078.15 611.308C6102.08 626.626 6119.08 649.123 6129.13 678.8C6141.57 651.037 6160.96 629.019 6187.29 612.744C6214.09 596.469 6245.2 588.332 6280.63 588.332Z" fill="#273B49"/>
<path d="M6592.56 433.244H6628.46V966H6592.56V433.244Z" fill="#273B49"/>
<path d="M1642.67 529.846C1659.3 494.583 1683.92 467.97 1716.52 450.006C1749.78 432.042 1790.7 423.06 1839.27 423.06V491.922L1822.31 490.924C1767.08 490.924 1723.84 507.89 1692.57 541.822C1661.3 575.754 1645.66 623.325 1645.66 684.536V952H1574.8V427.052H1642.67V529.846Z" fill="#273B49"/>
<path d="M2458.4 427.052V952H2390.53V856.192C2371.91 888.128 2346.29 913.078 2313.69 931.042C2281.09 948.341 2243.83 956.99 2201.91 956.99C2133.38 956.99 2079.16 938.028 2039.24 900.104C1999.98 861.515 1980.36 805.294 1980.36 731.442V427.052H2051.21V724.456C2051.21 779.679 2064.85 821.595 2092.13 850.204C2119.41 878.813 2158.33 893.118 2208.9 893.118C2264.12 893.118 2307.7 876.485 2339.64 843.218C2371.57 809.286 2387.54 762.38 2387.54 702.5V427.052H2458.4Z" fill="#273B49"/>
<path d="M2937.29 423.06C2986.52 423.06 3031.1 434.371 3071.02 456.992C3110.94 478.948 3142.21 510.219 3164.83 550.804C3187.46 591.389 3198.77 637.63 3198.77 689.526C3198.77 741.422 3187.46 787.663 3164.83 828.248C3142.21 868.833 3110.94 900.437 3071.02 923.058C3031.1 945.679 2986.52 956.99 2937.29 956.99C2893.38 956.99 2853.79 947.675 2818.53 929.046C2783.93 910.417 2755.99 883.471 2734.7 848.208V952H2666.83V211.484H2737.69V526.852C2759.65 492.92 2787.59 467.305 2821.52 450.006C2856.12 432.042 2894.71 423.06 2937.29 423.06ZM2932.3 894.116C2968.89 894.116 3002.16 885.799 3032.1 869.166C3062.04 851.867 3085.33 827.583 3101.96 796.312C3119.26 765.041 3127.91 729.446 3127.91 689.526C3127.91 649.606 3119.26 614.011 3101.96 582.74C3085.33 551.469 3062.04 527.517 3032.1 510.884C3002.16 493.585 2968.89 484.936 2932.3 484.936C2895.04 484.936 2861.44 493.585 2831.5 510.884C2802.23 527.517 2778.94 551.469 2761.64 582.74C2745.01 614.011 2736.69 649.606 2736.69 689.526C2736.69 729.446 2745.01 765.041 2761.64 796.312C2778.94 827.583 2802.23 851.867 2831.5 869.166C2861.44 885.799 2895.04 894.116 2932.3 894.116Z" fill="#273B49"/>
<path d="M3353.19 427.052H3424.05V952H3353.19V427.052ZM3389.12 312.282C3374.48 312.282 3362.17 307.292 3352.19 297.312C3342.21 287.332 3337.22 275.356 3337.22 261.384C3337.22 248.077 3342.21 236.434 3352.19 226.454C3362.17 216.474 3374.48 211.484 3389.12 211.484C3403.76 211.484 3416.07 216.474 3426.05 226.454C3436.03 235.769 3441.02 247.079 3441.02 260.386C3441.02 275.023 3436.03 287.332 3426.05 297.312C3416.07 307.292 3403.76 312.282 3389.12 312.282Z" fill="#273B49"/>
<path d="M3848.75 956.99C3796.86 956.99 3750.28 945.679 3709.03 923.058C3668.45 900.437 3636.51 868.833 3613.22 828.248C3589.94 786.997 3578.29 740.757 3578.29 689.526C3578.29 638.295 3589.94 592.387 3613.22 551.802C3636.51 511.217 3668.45 479.613 3709.03 456.992C3750.28 434.371 3796.86 423.06 3848.75 423.06C3894 423.06 3934.25 432.042 3969.51 450.006C4005.44 467.305 4033.72 492.92 4054.34 526.852L4001.45 562.78C3984.15 536.832 3962.19 517.537 3935.58 504.896C3908.97 491.589 3880.02 484.936 3848.75 484.936C3810.83 484.936 3776.56 493.585 3745.96 510.884C3716.02 527.517 3692.4 551.469 3675.1 582.74C3658.47 614.011 3650.15 649.606 3650.15 689.526C3650.15 730.111 3658.47 766.039 3675.1 797.31C3692.4 827.915 3716.02 851.867 3745.96 869.166C3776.56 885.799 3810.83 894.116 3848.75 894.116C3880.02 894.116 3908.97 887.795 3935.58 875.154C3962.19 862.513 3984.15 843.218 4001.45 817.27L4054.34 853.198C4033.72 887.13 4005.44 913.078 3969.51 931.042C3933.58 948.341 3893.33 956.99 3848.75 956.99Z" fill="#273B49"/>
<path d="M4409.32 956.99C4358.75 956.99 4313.18 945.679 4272.59 923.058C4232.01 899.771 4200.07 867.835 4176.78 827.25C4153.5 786.665 4141.85 740.757 4141.85 689.526C4141.85 638.295 4153.5 592.387 4176.78 551.802C4200.07 511.217 4232.01 479.613 4272.59 456.992C4313.18 434.371 4358.75 423.06 4409.32 423.06C4459.88 423.06 4505.46 434.371 4546.04 456.992C4586.63 479.613 4618.23 511.217 4640.85 551.802C4664.14 592.387 4675.78 638.295 4675.78 689.526C4675.78 740.757 4664.14 786.665 4640.85 827.25C4618.23 867.835 4586.63 899.771 4546.04 923.058C4505.46 945.679 4459.88 956.99 4409.32 956.99ZM4409.32 894.116C4446.58 894.116 4479.84 885.799 4509.12 869.166C4539.06 851.867 4562.34 827.583 4578.98 796.312C4595.61 765.041 4603.93 729.446 4603.93 689.526C4603.93 649.606 4595.61 614.011 4578.98 582.74C4562.34 551.469 4539.06 527.517 4509.12 510.884C4479.84 493.585 4446.58 484.936 4409.32 484.936C4372.06 484.936 4338.46 493.585 4308.52 510.884C4279.24 527.517 4255.96 551.469 4238.66 582.74C4222.03 614.011 4213.71 649.606 4213.71 689.526C4213.71 729.446 4222.03 765.041 4238.66 796.312C4255.96 827.583 4279.24 851.867 4308.52 869.166C4338.46 885.799 4372.06 894.116 4409.32 894.116Z" fill="#273B49"/>
<path d="M5097.89 423.06C5163.76 423.06 5215.99 442.355 5254.58 480.944C5293.83 518.868 5313.46 574.423 5313.46 647.61V952H5242.6V654.596C5242.6 600.039 5228.96 558.455 5201.68 529.846C5174.4 501.237 5135.48 486.932 5084.92 486.932C5028.36 486.932 4983.45 503.898 4950.19 537.83C4917.58 571.097 4901.28 617.337 4901.28 676.552V952H4830.43V427.052H4898.29V523.858C4917.58 491.922 4944.2 467.305 4978.13 450.006C5012.73 432.042 5052.65 423.06 5097.89 423.06Z" fill="#273B49"/>
<defs>
<linearGradient id="paint0_linear" x1="612.729" y1="0" x2="612.729" y2="1224" gradientUnits="userSpaceOnUse">
<stop stop-color="#E2F4FE"/>
<stop offset="1" stop-color="#97D6ED"/>
</linearGradient>
<linearGradient id="paint1_linear" x1="-56.8245" y1="299.696" x2="-4.63461" y2="834.312" gradientUnits="userSpaceOnUse">
<stop stop-color="#019ED5"/>
<stop offset="1" stop-color="#003362"/>
</linearGradient>
<linearGradient id="paint2_linear" x1="746.205" y1="437.978" x2="807.142" y2="893.844" gradientUnits="userSpaceOnUse">
<stop stop-color="#009ED5"/>
<stop offset="1" stop-color="#003362"/>
</linearGradient>
<linearGradient id="paint3_linear" x1="664.533" y1="810.789" x2="704.345" y2="1179.18" gradientUnits="userSpaceOnUse">
<stop stop-color="#009ED5"/>
<stop offset="1" stop-color="#003362"/>
</linearGradient>
</defs>
</svg>
|
0 | capitalone_repos/rubicon-ml | capitalone_repos/rubicon-ml/binder/welcome.ipynb | import os
from rubicon_ml import Rubicon
from rubicon_ml.viz import ExperimentsTable
default_server_url = "https://hub.gke2.mybinder.org/"
# default_server_url = "https://hub-binder.mybinder.ovh"
port = 8050
requests_pathname_prefix = f"{os.environ['JUPYTERHUB_SERVICE_PREFIX']}proxy/{port}/"
dash_kwargs = {"requests_pathname_prefix": requests_pathname_prefix}
run_server_kwargs = {"proxy": f"http://127.0.0.1:{port}::{default_server_url}", "port": port}
rubicon = Rubicon(persistence="filesystem", root_dir=f"{os.getcwd()}/rubicon-root")
project = rubicon.get_project(name="Classifying Penguins")
experiments_table = ExperimentsTable(experiments=project.experiments())
experiments_table.show(dash_kwargs=dash_kwargs, run_server_kwargs=run_server_kwargs)session_base_url = os.path.dirname(os.path.dirname(os.path.dirname((
default_server_url + requests_pathname_prefix
))))
print(f"Quick Look: \t{session_base_url}/tree/notebooks/quick-look")
print(f"Examples: \t{session_base_url}/tree/notebooks/logging-examples")
print(f"Integrations: \t{session_base_url}/tree/notebooks/integrations")
print(f"Visualizations: {session_base_url}/tree/notebooks/viz") |
0 | capitalone_repos/rubicon-ml | capitalone_repos/rubicon-ml/binder/postBuild | git clone -b rubicon-logs https://github.com/ryanSoley/experimenting-with-rubicon.git binder/rubicon-root
|
0 | capitalone_repos/rubicon-ml | capitalone_repos/rubicon-ml/binder/environment.yml | name: rubicon-ml-binder
channels:
- conda-forge
dependencies:
- python>=3.8
- pip
- jupyter-server-proxy
- rubicon-ml
|
0 | capitalone_repos | capitalone_repos/federated-model-aggregation/LICENSE | Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
|
0 | capitalone_repos | capitalone_repos/federated-model-aggregation/CODEOWNERS | * @JGSweets @ksneab7 @taylorfturner @micdavis @tyfarnan |
0 | capitalone_repos | capitalone_repos/federated-model-aggregation/pre-commit-hook.sh | #!/usr/bin/env bash
# declare submodules to validate
declare -a submodules=("aggregator" "api_service" "fma-core" "connectors/django" "clients/python_client")
# start templated
INSTALL_PYTHON=python3
EXIT_CODE=0
# end templated
# loop through each submodule
for SUBMODULE_DIR in "${submodules[@]}"
do
HERE="$(cd "$(dirname "$0")" && pwd)"
ARGS=(hook-impl --hook-type=pre-commit)
ARGS+=(--config "$SUBMODULE_DIR/.pre-commit-config.yaml")
ARGS+=(--hook-dir "$HERE" -- "$@")
echo
echo Submodule: $SUBMODULE_DIR
echo Args: "${ARGS[@]}"
if [ -x "$INSTALL_PYTHON" ]; then
"$INSTALL_PYTHON" -mpre_commit "${ARGS[@]}"
elif command -v pre-commit > /dev/null; then
pre-commit "${ARGS[@]}"
else
echo '`pre-commit` not found. Did you forget to activate your virtualenv?' 1>&2
exit 1
fi
EXIT_CODE=$(( $EXIT_CODE ? $EXIT_CODE : $? ))
done
exit $EXIT_CODE
|
0 | capitalone_repos | capitalone_repos/federated-model-aggregation/README.md | # Federated Model Aggregation
## Purpose
The Federated Model Aggregation (FMA) Service is a collection of installable python components that make up the generic
workflow/infrastructure needed for federated learning.
The main goal is to take a distributed model training workflow and convert it into a federated learning paradigm with
very little changes to your training code.
Each component can be used by changing a few settings within the components and then simply deploying with a terraform
based deployment script.
The main components that make up the FMA Service are:
* FMA Core
* FMA Connectors
* FMA Clients
* Aggregator
* API Service
Additionally, the FMA contains deployable serverless infrastructure intended to provide a foundation for
federated learning deployment capabilities, thus offering users the capability to quickly stand up the FMA service using
these pre-made components. Users also have the ability to configure different components in a variety of ways in order to
customize deployments for varying cloud platforms or develop their own components to support their own infrastructure such as new:
* Metadata Connectors
* Model Data Connectors
* Clients
Due to the agnostic design of the FMA framework, users can pick and choose which components to work with. Whether it's
developing aggregation techniques, modifying infrastructure deployment steps, or creating new connectors to orchestrate
communication between components, contributors are encouraged to contribute wherever there is interest or need.
## Repository Breakdown
### Aggregator
The Aggregator component is used for aggregation service. Functionality includes:
- Pushing and pulling models and their metadata.
- Executing model aggregation between all clients' updates pushed to service for an experiment.
### API Service
The API Service component does the following:
- Handles all API interactions/calls from outside the service (developer and client API calls)
- Hosts the static webpage for developers to analyze experiments.
### Clients
The Clients component is a set of webclients that are ready-made to be integrated with the developer's client code.
A webclient enables client-service interactions through the developer's code.
The intent of this component is to make service connection seamless with the use of ready-made API calls. Users are
encouraged to build and contribute their own client to suit the needs of their use case.
### FMA Core
The FMA-Core component is a collection of building blocks use for agnostically building an FMA service.
Algorithms and workflows are agnostic in the sense that users can build their own algorithms/workflows
and use them in the FMA Service.
### Connectors
The Connectors component is a set of subcomponents used to facilitate the communication to and from a variety of other
components in the service. Users are encouraged to contribute additions and modifications to the connectors component
as interest or need suits.
## Generalized System Diagram
![](images/Abstract_FMA_Diagram.png)
## Getting Started
To find out more about each component and how to use them,
visit their respective documentation located in the links below:
- [Aggregator](aggregator/README.md)
- [API Service](api_service/README.md)
- Web Clients
- [Python Client](clients/python_client/README.md)
- [FMA Core](fma-core/README.md)
- Connectors
- [Django](connectors/django/README.md)
## Examples
To see documentation around examples and deployments, visit the
links with their respective documentation:
- [Local Setup Tutorial Video](https://www.youtube.com/watch?v=TFdem9lY7jw)
- [Client Example](examples/client_examples/python_client/dataprofiler_developer/README.md)
- [Django Example](examples/django-deployment/README.md)
- [Remote Terraform Deployment](terraform_deploy/README.md)
|
0 | capitalone_repos/federated-model-aggregation | capitalone_repos/federated-model-aggregation/fma-core/.pre-commit-config.yaml | files: fma-core/fma_core
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: end-of-file-fixer
name: EOF for fma-core
- id: trailing-whitespace
name: Whitespace for fma-core
- id: check-ast
name: Check python parse valid for fma-core
- id: check-docstring-first
name: Check docstring first in fma-core
- repo: https://github.com/psf/black
rev: 22.8.0
hooks:
- id: black
name: Black for fma-core
- repo: https://github.com/pycqa/flake8
rev: '5.0.4' # pick a git hash / tag to point to
hooks:
- id: flake8
name: Flake8 for fma-core
files: fma-core/
# https://github.com/PyCQA/pydocstyle/issues/68 for ignore of D401
# https://github.com/OCA/maintainer-quality-tools/issues/552 for ignore of W503
args: ["--config=fma-core/setup.cfg", "--ignore=D401,W503"]
additional_dependencies: [flake8-docstrings]
exclude: (^.*/tests|^.*/__init__.py)
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort for fma-core
|
0 | capitalone_repos/federated-model-aggregation | capitalone_repos/federated-model-aggregation/fma-core/setup.cfg | [metadata]
name = fma-core
description = Core functionality of federated learning algorithms for the FMA
long_description = file: README.md
license = Apache License 2.0
classifiers =
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
Intended Audience :: Education
Intended Audience :: Information Technology
Intended Audience :: Science/Research
Topic :: Education
Topic :: Scientific/Engineering
Topic :: Scientific/Engineering :: Information Analysis
License :: OSI Approved :: Apache Software License
Programming Language :: Python :: 3
[flake8]
max-line-length = 88
extend-ignore = E203
[isort]
multi_line_output=3
profile=black
skip=venv
src_paths=fma_core
|
0 | capitalone_repos/federated-model-aggregation | capitalone_repos/federated-model-aggregation/fma-core/requirements.txt | numpy==1.22.2
|
0 | capitalone_repos/federated-model-aggregation | capitalone_repos/federated-model-aggregation/fma-core/.coveragerc | [run]
omit = */tests/*,conftest.py,fma_django/migrations/*,setup.py
branch = True
|
0 | capitalone_repos/federated-model-aggregation | capitalone_repos/federated-model-aggregation/fma-core/CODEOWNERS | * @ksneab7 @tyfarnan @taylorfturner @micdavis @JGSweets
|
0 | capitalone_repos/federated-model-aggregation | capitalone_repos/federated-model-aggregation/fma-core/Pipfile | [[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"
[packages]
numpy = "1.22.2"
[dev-packages]
pytest = "*"
pytest-cov = "*"
black = "*"
flake8 = "*"
pre-commit = "*"
isort = "*"
[requires]
python_version = "3"
|
0 | capitalone_repos/federated-model-aggregation | capitalone_repos/federated-model-aggregation/fma-core/README.md | # FMA-Core
The FMA-Core component is a collection of building blocks use for agnostically building an FMA service.
Algorithms and workflows are agnostic in the sense that users can build their own algorithms/workflows
and use them in the FMA Service.
Quick start
-----------
For installation:
```console
pip install fma-core
```
Testing
-------
Inside a virtualenv:
```
make install
make test
```
For testing and coverage reports:
```
make test-and-coverage
```
## FMA-Algorithms
A sub-part of FMA-Core is FMA-Algorithms.
This component is an agnostic implementation of the model aggregation function for the FMA service.
## FMA-Workflows
FMA-Workflow is the principal component of the service: gluing together the
`aggregator`, `api`, `model`, and `metadata` connectors for the various parts of the service
to communicate with each other.
|
0 | capitalone_repos/federated-model-aggregation | capitalone_repos/federated-model-aggregation/fma-core/Makefile | .PHONY: install
install:
pipenv --rm || true
pipenv --clear
rm -f Pipfile.lock
pipenv install --dev
pipenv run pre-commit install
.PHONY: test
test:
pipenv run pytest
.PHONY: test-and-coverage
test-and-coverage:
pipenv run pytest --junit-xml=junit_xml_test_report.xml --cov-branch --cov=fma_core .
pipenv run coverage xml -i
pipenv run coverage report --fail-under 80
|
0 | capitalone_repos/federated-model-aggregation | capitalone_repos/federated-model-aggregation/fma-core/requirements-dev.txt | pytest
pytest-cov
pytest-mock
black
flake8
pre-commit
isort
|
0 | capitalone_repos/federated-model-aggregation | capitalone_repos/federated-model-aggregation/fma-core/setup.py | """Setup.py for fma algorithms."""
import os
from setuptools import find_packages, setup
from fma_core.version import __version__
project_path = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(project_path, "requirements.txt"), encoding="utf-8") as f:
required_packages = f.read().splitlines()
with open(os.path.join(project_path, "README.md"), encoding="utf-8") as f:
LONG_DESCRIPTION = f.read()
DESCRIPTION = "Federated Model Aggregation's Core Functionality"
packages = find_packages(exclude=["*.tests"])
setup(
author="Kenny Bean, Tyler Farnan, Taylor Turner, Michael Davis, Jeremy Goodsitt ",
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Intended Audience :: Education",
"Intended Audience :: Information Technology",
"Intended Audience :: Science/Research",
"Topic :: Education",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Information Analysis",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3",
],
data_files=None,
description=DESCRIPTION,
include_package_data=True,
install_requires=required_packages,
keywords="Federated Learning",
license="Apache License, Version 2.0",
long_description=LONG_DESCRIPTION,
long_description_content_type="text/markdown",
name="fma-core",
packages=packages,
python_requires=">=3.8",
url="https://github.com/capitalone/federated-model-aggregation",
version=__version__,
)
print("find_packages():", packages)
|
0 | capitalone_repos/federated-model-aggregation/fma-core | capitalone_repos/federated-model-aggregation/fma-core/fma_core/version.py | """File contains the version number for the package."""
MAJOR = 0
MINOR = 0
MICRO = 1
VERSION = "%d.%d.%d" % (MAJOR, MINOR, MICRO)
__version__ = VERSION
|
0 | capitalone_repos/federated-model-aggregation/fma-core | capitalone_repos/federated-model-aggregation/fma-core/fma_core/conf.py | """Configuration for the fma-core library."""
import copy
import importlib
import os
class Settings:
"""Settings Module for the fma-core library."""
def __init__(self):
"""Imports user specified settings file from env."""
settings_module = os.environ.get("FMA_SETTINGS_MODULE", None)
if not settings_module:
raise ImportError("The `FMA_SETTINGS_MODULE` was not set.")
mod = importlib.import_module(settings_module)
agg_settings = getattr(mod, "AGGREGATOR_SETTINGS", None)
if not agg_settings or not isinstance(agg_settings, dict):
raise ValueError(
"`FMA_SETTINGS_MODULE` is improperly configured and must "
"contain the dict `AGGREGATOR_SETTINGS`"
)
for attr in dir(mod):
value = getattr(mod, attr)
# avoids issues if modules imported
if isinstance(value, (list, dict)):
value = copy.deepcopy(value)
setattr(self, attr, value)
settings = Settings()
|
0 | capitalone_repos/federated-model-aggregation/fma-core | capitalone_repos/federated-model-aggregation/fma-core/fma_core/__init__.py | from .version import __version__
def setup():
"""Loads packages required for the fma-core listed in the settings."""
import importlib
from fma_core.conf import settings
packages = getattr(settings, "INSTALLED_PACKAGES", [])
for package in packages:
importlib.import_module(package)
|
0 | capitalone_repos/federated-model-aggregation/fma-core/fma_core | capitalone_repos/federated-model-aggregation/fma-core/fma_core/tests/test_base.py | import os
import unittest
from unittest import mock
import fma_core
from fma_core.conf import Settings
class TestBaseInfo(unittest.TestCase):
def test_has_version(self):
hasattr(fma_core, "__version__")
self.assertIsNotNone(fma_core.__version__)
def test_import_settings(self):
from fma_core.conf import settings
expected_settings = {
"aggregator_connector_type": "BaseAggConnector",
"metadata_connector": {
"type": "FakeMetadataConnector",
},
"model_data_connector": {
"type": "FakeModelDataConnector",
},
}
self.assertDictEqual(expected_settings, settings.AGGREGATOR_SETTINGS)
with self.assertRaises(AttributeError):
settings.VALUE_THAT_DOESNT_EXIST
@mock.patch.dict(os.environ, {"FMA_SETTINGS_MODULE": ""}, clear=True)
def test_import_not_set(self):
with self.assertRaisesRegex(
ImportError, "The `FMA_SETTINGS_MODULE` was not set."
):
Settings()
@mock.patch("fma_core.tests.fma_settings.AGGREGATOR_SETTINGS", None)
def test_fma_settings_module_not_set(self):
with self.assertRaisesRegex(
ValueError,
"`FMA_SETTINGS_MODULE` is improperly configured and must contain the dict `AGGREGATOR_SETTINGS`",
):
Settings()
def test_setup(self):
from fma_core.conf import settings
# with no packages specified
with mock.patch("importlib.import_module") as mock_import:
fma_core.setup()
mock_import.assert_not_called()
# with package that doesn't exist
INSTALLED_PACKAGES = ["fake-package-no-exist-123"]
with mock.patch("fma_core.conf.settings") as mock_settings:
mock_settings.INSTALLED_PACKAGES = ["fake-package-no-exist-123"]
with self.assertRaisesRegex(ImportError, "fake-package-no-exist-123"):
fma_core.setup()
# with package that does exist
with mock.patch("fma_core.conf.settings") as mock_settings:
mock_settings.INSTALLED_PACKAGES = ["fma_core"]
fma_core.setup()
|
0 | capitalone_repos/federated-model-aggregation/fma-core/fma_core | capitalone_repos/federated-model-aggregation/fma-core/fma_core/tests/conftest.py | import os
import sys
from os.path import abspath, dirname
root_dir = dirname(dirname(dirname(abspath(__file__))))
print(root_dir)
sys.path.append(root_dir)
os.environ["FMA_SETTINGS_MODULE"] = "fma_core.tests.fma_settings"
|
0 | capitalone_repos/federated-model-aggregation/fma-core/fma_core | capitalone_repos/federated-model-aggregation/fma-core/fma_core/tests/fma_settings.py | """Abstract aggregator settings."""
from os import * # included to test imports
AGGREGATOR_SETTINGS = {
"aggregator_connector_type": "BaseAggConnector",
"metadata_connector": {
"type": "FakeMetadataConnector",
},
"model_data_connector": {
"type": "FakeModelDataConnector",
},
}
API_SERVICE_SETTINGS = {"handler": "fake_handler"}
|
0 | capitalone_repos/federated-model-aggregation/fma-core/fma_core | capitalone_repos/federated-model-aggregation/fma-core/fma_core/tests/utils.py | from __future__ import annotations
import json
from dataclasses import dataclass, field
from io import StringIO
@dataclass
class ModelData:
data: list
def open(self, *args):
return StringIO(json.dumps(self.data))
@dataclass(frozen=True)
class Client:
id: str
@dataclass
class ModelUpdate:
data: list | np.ndarray
client: Client
@dataclass
class ModelAggregate:
result: any
id: int | None = None
@dataclass
class ModelArtifact:
values: ModelData
@dataclass
class ClientList:
clients: list[Client]
def all(self):
return self.clients
@dataclass
class FederatedModel:
clients: ClientList
aggregates: list[ModelAggregate] = field(default_factory=list)
current_artifact: ModelArtifact | None = None
aggregator: str | None = None
def create_model_file(data: list[int | float]):
"""Simulation of creating a model file"""
return ModelData(data=data)
@dataclass
class Task:
"""Used to run construct a valid parameter for the post_agg_service function."""
args: list
success: bool
def __init__(self, args, success):
"""Initialization of the Task class.
:param args: Arguments
:type args: Dict, optional
:param success: The initial task success status
:type success: bool
"""
self.args = args
self.success = success
|
0 | capitalone_repos/federated-model-aggregation/fma-core/fma_core/tests | capitalone_repos/federated-model-aggregation/fma-core/fma_core/tests/workflows/test_api_handler_factory.py | import unittest
from unittest import mock
from fma_core.conf import settings as fma_settings
from fma_core.workflows import api_handler_factory, api_handler_utils
class TestAPIHandler(unittest.TestCase):
@mock.patch.dict(api_handler_utils._registry, {}, clear=True)
def test_register(self):
self.assertDictEqual({}, api_handler_utils._registry)
@api_handler_utils.register()
def fake_func():
pass
self.assertIn("fake_func", api_handler_utils._registry)
@mock.patch.object(fma_settings, "API_SERVICE_SETTINGS", None)
def test_handler_settings_not_set(self):
with self.assertRaisesRegex(
ValueError,
"API_SERVICE_SETTINGS` settings are not specified in settings",
):
api_handler_factory.call_api_handler()
@mock.patch.object(fma_settings, "API_SERVICE_SETTINGS", {"fake": "test"})
def test_handler_fcn_not_set(self):
with self.assertRaisesRegex(
ValueError,
"`handler` is not specified in settings",
):
api_handler_factory.call_api_handler()
def test_call_api_handler(self):
mock_handler = mock.Mock()
mock_registry = {"fake_handler": mock_handler}
with mock.patch.dict(api_handler_utils._registry, mock_registry, clear=True):
api_handler_factory.call_api_handler("fake", data="test")
mock_handler.assert_called_with("fake", data="test")
|
0 | capitalone_repos/federated-model-aggregation/fma-core/fma_core/tests | capitalone_repos/federated-model-aggregation/fma-core/fma_core/tests/workflows/test_tasks.py | import datetime
import os
import sys
import unittest
from unittest import mock
from fma_core.tests import utils
from fma_core.workflows.aggregator_connectors_factory import BaseAggConnector
from fma_core.workflows.metadata_connectors_factory import BaseMetadataConnector
from fma_core.workflows.model_data_connectors_factory import BaseModelDataConnector
from fma_core.workflows.tasks import (
agg_service,
post_agg_service_hook,
update_metadata_db,
)
@mock.patch(
"fma_core.workflows.aggregator_connectors_factory.BaseAggConnector._BaseAggConnector__subclasses",
{"baseaggconnector": BaseAggConnector},
)
@mock.patch(
"fma_core.workflows.metadata_connectors_factory.BaseMetadataConnector.create"
)
@mock.patch(
"fma_core.workflows.model_data_connectors_factory.BaseModelDataConnector.create"
)
class TestAggService(unittest.TestCase):
def setup_mock_connectors(self, mock_model_create, mock_meta_create):
mock_meta = mock.Mock(spec=BaseMetadataConnector)
mock_meta_create.return_value = mock_meta
mock_model = mock.Mock(spec=BaseModelDataConnector)
mock_model_create.return_value = mock_model
return mock_model, mock_meta
def test_no_aggregates(self, mock_model_create, mock_meta_create, *mocks):
# federated object setup
mock_model, mock_meta = self.setup_mock_connectors(
mock_model_create, mock_meta_create
)
mock_meta.pull_federated_model_w_id.return_value = utils.FederatedModel(
aggregator="avg_values_if_data",
clients=utils.ClientList([utils.Client("test")]),
)
mock_meta.pull_model_updates_ready_for_aggregation.return_value = []
# Assert no model_updates
actual_result = agg_service(model_id=1)
self.assertIsNone(actual_result)
mock_meta.pull_model_requirements.return_value = None, None
model_update_data = [
utils.ModelUpdate(data=[[2], [2]], client=utils.Client("id=1")),
utils.ModelUpdate(data=[[3], [1]], client=utils.Client("id=2")),
]
mock_meta.pull_model_updates_ready_for_aggregation.return_value = (
model_update_data
)
mock_model.pull_model_updates_data.return_value = model_update_data
# ensure results stay the same for checking
mock_model.prep_model_data_for_storage.side_effect = lambda x: x
mock_model.push_model_data_to_storage.side_effect = lambda x: x
# set results / id for output since we aren't using an external system
mock_meta.post_new_model_aggregate.side_effect = (
lambda model, parent_agg, results: utils.ModelAggregate(
id=300, result=results
)
)
actual_result = agg_service(model_id=1)
actual_agg_result = mock_meta.post_new_model_aggregate.call_args[0][2]
self.assertEqual(300, actual_result)
self.assertEqual([[2.5], [1.5]], actual_agg_result)
# TODO: add test for req_str not being None
# mock_meta.pull_model_requirements.return_value = None, None
def test_post_agg_service_hook(self, mock_model_create, mock_meta_create, *mocks):
mock_model, mock_meta = self.setup_mock_connectors(
mock_model_create, mock_meta_create
)
# no model
mock_meta.pull_federated_model_w_id.return_value = None
task = utils.Task(args=[0], success=False)
actual_result = post_agg_service_hook(task)
mock_meta.pull_model_updates_registered_for_aggregation.assert_not_called()
# assert model, but no updates
mock_meta.pull_federated_model_w_id.return_value = utils.FederatedModel(
aggregator="avg_values_if_data",
clients=utils.ClientList([utils.Client("test")]),
)
mock_meta.pull_model_updates_registered_for_aggregation.return_value = None
actual_result = post_agg_service_hook(task)
mock_meta.pull_model_updates_registered_for_aggregation.assert_called()
mock_meta.register_model_updates_use_in_aggregation_complete.assert_not_called()
# failed task
model_updates = [
utils.ModelUpdate(data=[[2], [2]], client=utils.Client("id=1")),
]
mock_meta.pull_model_updates_registered_for_aggregation.return_value = (
model_updates
)
actual_result = post_agg_service_hook(task)
mock_meta.register_model_updates_use_in_aggregation_complete.assert_called_with(
model_updates, False
)
# successful task
mock_meta.register_model_updates_use_in_aggregation_complete.reset_mock()
model_updates = [
utils.ModelUpdate(data=[[2], [2]], client=utils.Client("id=1")),
]
mock_meta.register_model_updates_use_in_aggregation_complete.return_value = (
model_updates
)
task = utils.Task(args=[0], success=True)
actual_result = post_agg_service_hook(task)
mock_meta.register_model_updates_use_in_aggregation_complete.assert_called_with(
model_updates, True
)
def test_update_metadata_db(self, mock_model_create, mock_meta_create, *mocks):
mock_model, mock_meta = self.setup_mock_connectors(
mock_model_create, mock_meta_create
)
actual_result = update_metadata_db()
mock_meta.update_database.assert_called()
|
0 | capitalone_repos/federated-model-aggregation/fma-core/fma_core/tests | capitalone_repos/federated-model-aggregation/fma-core/fma_core/tests/workflows/test_aggregator_connectors_factory.py | import unittest
from unittest import mock
from fma_core.workflows.aggregator_connectors_factory import BaseAggConnector
from fma_core.workflows.aggregator_utils import AutoSubRegistrationMeta
class TestBaseAggreagtorFactory(unittest.TestCase):
@mock.patch(
"fma_core.workflows.aggregator_connectors_factory.BaseAggConnector."
"_BaseAggConnector__subclasses",
new_callable=mock.PropertyMock,
)
def test_auto_register_subclass(self, mock_subclasses, *mocks):
# create fake class
class FakeAggConn(BaseAggConnector, metaclass=AutoSubRegistrationMeta):
def __init__(self, settings=None):
pass
# assert registered
BaseAggConnector._BaseAggConnector__subclasses.__setitem__.assert_called_with(
"fakeaggconn", FakeAggConn
)
# assert can get after register
mock_subclasses.return_value = {"fakeaggconn": FakeAggConn}
value = BaseAggConnector.create("fakeaggconn")
self.assertIsInstance(value, FakeAggConn)
|
0 | capitalone_repos/federated-model-aggregation/fma-core/fma_core/tests/algorithms | capitalone_repos/federated-model-aggregation/fma-core/fma_core/tests/algorithms/requirements/test_common_reqs.py | from __future__ import annotations
import os
import sys
import unittest
from unittest import mock
import numpy as np
from fma_core.algorithms.requirements.common import all_clients, require_x_updates
from fma_core.tests import utils
class TestAllClients(unittest.TestCase):
def test_no_model_updates(self):
model = utils.FederatedModel(clients=utils.ClientList([utils.Client("test")]))
model_updates = []
actual_result = all_clients(model, model_updates)
self.assertFalse(actual_result)
def test_fail_req(self):
model = utils.FederatedModel(
clients=utils.ClientList(
[
utils.Client("id=1"),
utils.Client("id=2"),
]
)
)
model_updates = [utils.ModelUpdate(client=utils.Client("id=2"), data=None)]
actual_result = all_clients(model, model_updates)
self.assertFalse(actual_result)
def test_pass_req(self):
model = utils.FederatedModel(
clients=utils.ClientList(
[
utils.Client("id=1"),
utils.Client("id=2"),
]
)
)
model_updates = [
utils.ModelUpdate(client=utils.Client("id=1"), data=None),
utils.ModelUpdate(client=utils.Client("id=2"), data=None),
]
actual_result = all_clients(model, model_updates)
self.assertTrue(actual_result)
class TestRequireXUpdates(unittest.TestCase):
def test_no_model_updates(self):
model = utils.FederatedModel(clients=utils.ClientList([utils.Client("test")]))
model_updates = []
actual_result = require_x_updates(model, model_updates, x=3)
self.assertFalse(actual_result)
def test_fail_req(self):
model = utils.FederatedModel(
clients=utils.ClientList(
[
utils.Client("id=1"),
utils.Client("id=2"),
]
)
)
model_updates = [utils.ModelUpdate(client=utils.Client("id=2"), data=None)]
actual_result = require_x_updates(model, model_updates, x=2)
self.assertFalse(actual_result)
def test_pass_req(self):
model = utils.FederatedModel(
clients=utils.ClientList(
[
utils.Client("id=1"),
utils.Client("id=2"),
utils.Client("id=3"),
]
)
)
# meet by having == 2
model_updates = [
utils.ModelUpdate(client=utils.Client("id=1"), data=None),
utils.ModelUpdate(client=utils.Client("id=2"), data=None),
]
actual_result = require_x_updates(model, model_updates, x=2)
self.assertTrue(actual_result)
# meet by having >= 2
model_updates = [
utils.ModelUpdate(client=utils.Client("id=1"), data=None),
utils.ModelUpdate(client=utils.Client("id=2"), data=None),
utils.ModelUpdate(client=utils.Client("id=3"), data=None),
]
actual_result = require_x_updates(model, model_updates, x=2)
self.assertTrue(actual_result)
|
0 | capitalone_repos/federated-model-aggregation/fma-core/fma_core/tests/algorithms | capitalone_repos/federated-model-aggregation/fma-core/fma_core/tests/algorithms/aggregators/test_common_aggs.py | from __future__ import annotations
import os
import sys
import unittest
from dataclasses import dataclass
from unittest import mock
import numpy as np
from fma_core.algorithms.aggregators.common import average_layers, avg_values_if_data
from fma_core.tests import utils
class TestAvgValues(unittest.TestCase):
def test_no_model_updates(self, *mocks):
model = None
model_updates = []
actual_result = avg_values_if_data(model, model_updates)
self.assertTrue(np.isnan(actual_result))
def test_multilayer_array(self, *mocks):
model = None
model_updates = [
utils.ModelUpdate(data=[[2], [2]], client=utils.Client("id=1")),
utils.ModelUpdate(data=[[3], [1]], client=utils.Client("id=2")),
]
expected_result = [[2.5], [1.5]]
actual_result = average_layers(model, model_updates)
self.assertListEqual(expected_result, actual_result)
class TestAvgLayers(unittest.TestCase):
def test_no_model_updates(self, *mocks):
model = None
model_updates = []
actual_result = average_layers(model, model_updates)
self.assertIsNone(actual_result)
def test_multilayer_array(self, *mocks):
model = None
model_updates = [
utils.ModelUpdate(data=[[2], [2, 4, 5], [2]], client=utils.Client("id=1")),
utils.ModelUpdate(data=[[3], [1, 3, 4], [1]], client=utils.Client("id=2")),
]
expected_result = [[2.5], [1.5, 3.5, 4.5], [1.5]]
actual_result = average_layers(model, model_updates)
self.assertListEqual(expected_result, actual_result)
|
0 | capitalone_repos/federated-model-aggregation/fma-core/fma_core | capitalone_repos/federated-model-aggregation/fma-core/fma_core/workflows/api_handler_factory.py | """Factory function for calling registered api handlers specified in settings."""
from typing import Any
import fma_core
from fma_core.conf import settings as fma_settings
from fma_core.workflows.api_handler_utils import _registry
def call_api_handler(*args, **kwargs) -> Any:
"""Abstract call to API handler of a connector."""
fma_core.setup()
handler_settings = getattr(fma_settings, "API_SERVICE_SETTINGS", None)
if not handler_settings:
raise ValueError(
"`API_SERVICE_SETTINGS` settings are not specified in settings"
)
handler_fcn_str = handler_settings.get("handler", None)
if handler_fcn_str is None:
raise ValueError("`handler` is not specified in settings")
handler_fcn = _registry[handler_fcn_str]
return handler_fcn(*args, **kwargs)
|
0 | capitalone_repos/federated-model-aggregation/fma-core/fma_core | capitalone_repos/federated-model-aggregation/fma-core/fma_core/workflows/model_data_connectors_factory.py | """The base factory class that allows for creation of the model data connector."""
import inspect
from abc import ABC, abstractmethod
from typing import Any, ClassVar, Dict
class BaseModelDataConnector(ABC):
"""The metadata connector object used for connection to FMA setup."""
__subclasses = {}
def __init__(self, settings: Dict):
"""Initialization function for the model data connector.
:param settings: The settings that will be used to initialize the
model data connector
:type settings: Dict
"""
self.settings = settings
@classmethod
def create(
cls, model_connector_type: str, model_connector_settings: Dict = None
) -> ClassVar:
"""Creates subclass of aggregation connector.
:param model_connector_type: The subclass of model data connector to be created
:type model_connector_type: str
:param model_connector_settings: The settings to initialize the connector,
defaults to None
:type model_connector_settings: Dict, optional
:raises ValueError: meta_connector_type not in BaseMetadataConnector subclass
:return: A valid subclass object of BaseModelDataConnector
:rtype: ClassVar
"""
if model_connector_type.lower() not in cls._BaseModelDataConnector__subclasses:
raise ValueError
return cls._BaseModelDataConnector__subclasses[model_connector_type.lower()](
model_connector_settings
)
@classmethod
def _register_subclass(cls) -> None:
"""Register a subclass for the class factory."""
if not inspect.isabstract(cls):
cls._BaseModelDataConnector__subclasses[ # type: ignore
cls.__name__.lower()
] = cls
@abstractmethod
def push_model_data_to_storage(self, model_data: Any):
"""Pushes model data associated with the metadata of a model.
:param model_data: An object containing model data associated with
the metadata of a model
:type model_data: Any
:raises NotImplementedError: method to be implemented in subclass
"""
raise NotImplementedError()
@abstractmethod
def pull_model_updates_data(self, model_updates: Any) -> Any:
"""Pull Model weights that have been pushed by the clients as model updates.
:param model_updates: A list of model updates
:type model_updates: Any
:raises NotImplementedError: method to be implemented in subclass
"""
raise NotImplementedError()
@abstractmethod
def prep_model_data_for_storage(self, data: Any) -> Any:
"""Preps data created by aggregate by service to be stored in the model data.
:param data: The data that needs to be prepped for storage
:type data: Any
:raises NotImplementedError: method to be implemented in subclass
"""
raise NotImplementedError()
|
0 | capitalone_repos/federated-model-aggregation/fma-core/fma_core | capitalone_repos/federated-model-aggregation/fma-core/fma_core/workflows/tasks.py | """General aggregation tasks are created here."""
from typing import Any, Optional
import fma_core
from fma_core.algorithms.aggregators import common as common_aggregators
from fma_core.algorithms.requirements import common as common_requirements
from fma_core.conf import settings as fma_settings
from fma_core.workflows.aggregator_connectors_factory import BaseAggConnector
def agg_service(model_id: int) -> Optional[int]:
"""Runs aggregation for FMA.
:param model_id: The id of the Federated Model Experiment
:type model_id: int
:raises ValueError: Aggregator settings are not specified in settings
:raises ValueError: Aggregator type not specified in settings
:return: ID of newly created ModelAggregate
:rtype: int
"""
fma_core.setup()
agg_settings = getattr(fma_settings, "AGGREGATOR_SETTINGS")
if not agg_settings:
raise ValueError("Aggregator settings are not specified in settings")
agg_type = agg_settings.get("aggregator_connector_type", None)
if agg_type is None:
raise ValueError("Aggregator type not specified in settings")
aggregator_connector = BaseAggConnector.create(agg_type, agg_settings)
model = aggregator_connector.pull_federated_model_w_id(model_id)
# retrieve current latest aggregate for the aggregate hierarchy
parent_agg = aggregator_connector.pull_latest_model_aggregate(model)
# filter relative to task status (PENDING | FAILED) for a model
model_updates = aggregator_connector.pull_model_updates_ready_for_aggregation(
model, parent_agg
)
if not parent_agg:
parent_agg = None
if not model or not model_updates:
return None
# check the that the requirements are met if any
requirement_str, requirement_args = aggregator_connector.pull_model_requirements(
model
)
requirement = None
if isinstance(requirement_str, str):
requirement = getattr(common_requirements, requirement_str, None)
if requirement and not requirement(model, model_updates, *requirement_args):
return None
# set the updates to being used
aggregator_connector.register_model_updates_for_aggregation(model_updates)
# conduct the aggregation
model_updates = aggregator_connector.pull_model_updates_registered_for_aggregation(
model
)
# Read in model weights for aggregation
model_updates = aggregator_connector.pull_model_updates_data(model_updates)
aggregator = getattr(common_aggregators, model.aggregator)
results = aggregator(model, model_updates)
# Turn aggregation results into file
results = aggregator_connector.prep_model_data_for_storage(results)
aggregate = aggregator_connector.post_new_model_aggregate(
model, parent_agg, results
)
aggregator_connector.register_model_update_used_in_aggregate(
model_updates, aggregate
)
return aggregate.id
def post_agg_service_hook(task: Any):
"""Runs postprocessing after aggregation is complete.
:param task: Object containing info on the previously ran aggregation task
:type task: Any
:raise ValueError: Error: aggregator settings are not specified in settings
:raise ValueError: Error: aggregator type not specified in settings
"""
fma_core.setup()
model_id = task.args[0]
agg_settings = getattr(fma_settings, "AGGREGATOR_SETTINGS")
if not agg_settings:
raise ValueError("Error: aggregator settings are not specified in settings")
agg_type = agg_settings.get("aggregator_connector_type", None)
if agg_type is None:
raise ValueError("Error: aggregator type not specified in settings")
aggregator_connector = BaseAggConnector.create(agg_type, agg_settings)
model = aggregator_connector.pull_federated_model_w_id(model_id)
if not model:
return
model_updates = aggregator_connector.pull_model_updates_registered_for_aggregation(
model
)
if not model_updates:
return
aggregator_connector.register_model_updates_use_in_aggregation_complete(
model_updates, is_successful=task.success
)
def update_metadata_db() -> None:
"""Updates the architecture of the metadata database.
:raise ValueError: aggregator settings are not specified in settings
:raise ValueError: aggregator type not specified in settings
"""
fma_core.setup()
agg_settings = getattr(fma_settings, "AGGREGATOR_SETTINGS")
if not agg_settings:
raise ValueError("Aggregator settings are not specified in settings")
agg_type = agg_settings.get("aggregator_connector_type", None)
if agg_type is None:
raise ValueError("Aggregator type not specified in settings")
aggregator_connector = BaseAggConnector.create(agg_type, agg_settings)
aggregator_connector.update_metadata_database_arch()
|
0 | capitalone_repos/federated-model-aggregation/fma-core/fma_core | capitalone_repos/federated-model-aggregation/fma-core/fma_core/workflows/metadata_connectors_factory.py | """The base factory class that allows for creation of the metadata connector."""
import inspect
from abc import ABC, abstractmethod
from typing import Any, ClassVar, Dict, List, Optional
class BaseMetadataConnector(ABC):
"""The metadata connector object used for connection to FMA setup."""
__subclasses = {}
def __init__(self, settings: Dict):
"""Initialization function for the metadata connector.
:param settings: The settings that will be used to initialize the
metadata connector
:type settings: Dict
"""
self.settings = settings
@classmethod
def create(
cls, meta_connector_type: str, meta_connector_settings: Optional[Dict] = None
) -> ClassVar:
"""Creates subclass of metadata connector.
:param meta_connector_type: The subclass of metadata connector to be created
:type meta_connector_type: str
:param meta_connector_settings: The settings to initialize the connector,
defaults to None
:type meta_connector_settings: Dict, optional
:raises ValueError: meta_connector_type not in BaseMetadataConnector subclass
:return: A valid subclass object of BaseMetadataConnector
:rtype: ClassVar
"""
if meta_connector_type.lower() not in cls._BaseMetadataConnector__subclasses:
raise ValueError
return cls._BaseMetadataConnector__subclasses[meta_connector_type.lower()](
meta_connector_settings
)
@classmethod
def _register_subclass(cls) -> None:
"""Register a subclass for the class factory."""
if not inspect.isabstract(cls):
cls._BaseMetadataConnector__subclasses[ # type: ignore
cls.__name__.lower()
] = cls
@abstractmethod
def pull_federated_model_w_id(self, fed_model_id: int) -> Any:
"""Pulls a FederatedModel using its id.
:param fed_model_id: The id of the FederatedModel targeted for pull
:type fed_model_id: int
:raises NotImplementedError: method to be implemented in subclass
"""
raise NotImplementedError()
@abstractmethod
def pull_latest_model_aggregate(self, model: Any) -> Any:
"""Pulls the latest ModelAggregate in a FederatedModel.
:param model: FederatedModel object
:type model: Any
:raises NotImplementedError: method to be implemented in subclass
"""
raise NotImplementedError()
@abstractmethod
def pull_model_updates_ready_for_aggregation(
self, model: Any, parent_agg: Any
) -> List[Any]:
"""Pulls all ModelUpdates ready to be included in an aggregation.
:param model: FederatedModel object
:type model: Any
:param parent_agg: The parent aggregate of the ModelUpdates used
:type parent_agg: Any
:raises NotImplementedError: method to be implemented in subclass
"""
raise NotImplementedError()
@abstractmethod
def pull_model_requirements(self, model: Any) -> Any:
"""Pulls FederatedModel aggregation requirements and their args.
:param model: FederatedModel object
:type model: Any
:raises NotImplementedError: method to be implemented in subclass
"""
raise NotImplementedError()
@abstractmethod
def register_model_updates_for_aggregation(self, model_updates: List[Any]):
"""Updates status of a list of ModelUpdates to register for aggregation.
:param model_updates: A list of model updates
:type model_updates: List[Any]
:raises NotImplementedError: method to be implemented in subclass
"""
raise NotImplementedError()
@abstractmethod
def pull_model_updates_registered_for_aggregation(self, model: Any) -> List[Any]:
"""Pulls all ModelUpdates registered to be included in an aggregation.
:param model: FederatedModel object
:type model: Any
:raises NotImplementedError: method to be implemented in subclass
"""
raise NotImplementedError()
@abstractmethod
def post_new_model_aggregate(
self, model: Any, parent_agg: Any, results: List[Any]
) -> Any:
"""Creates an entry in a DB of a new ModelAggregate.
:param model: FederatedModel object
:type model: Any
:param parent_agg: The aggregate that the ModelUpdates included were
based on
:type parent_agg: Any
:param results: The data associated with the ModelAggregate being
stored
:type results: List[Any]
:raises NotImplementedError: method to be implemented in subclass
"""
raise NotImplementedError()
@abstractmethod
def pull_model_updates_pending_aggregation(self, model: Any) -> List[Any]:
"""Pulls all ModelUpdates pending inclusion to an aggregation task.
:param model: FederatedModel object
:type model: Any
:raises NotImplementedError: method to be implemented in subclass
"""
raise NotImplementedError()
@abstractmethod
def register_model_update_used_in_aggregate(
self, model_updates: List[Any], aggregate: Any
):
"""Registers that a list of ModelUpdates were used in an aggregate.
:param model_updates: List of model updates
:type model_updates: List[Any]
:param aggregate: ModelAggregate object
:type aggregate: Any
:raises NotImplementedError: method to be implemented in subclass
"""
raise NotImplementedError()
@abstractmethod
def register_model_updates_use_in_aggregation_complete(
self, model_updates: List[Any], is_successful: Any
):
"""Updates status of a list of ModelUpdates to "completed" on an aggregation.
:param model_updates: A list of model updates
:type model_updates: List[Any]
:param is_successful: Boolean value for if the aggregation task was completed
successfully
:type is_successful: Any
:raises NotImplementedError: method to be implemented in subclass
"""
raise NotImplementedError()
@abstractmethod
def update_database(self):
"""Updated the database.
:raises NotImplementedError: method to be implemented in subclass
"""
raise NotImplementedError()
|
0 | capitalone_repos/federated-model-aggregation/fma-core/fma_core | capitalone_repos/federated-model-aggregation/fma-core/fma_core/workflows/api_handler_utils.py | """Registry and registration functions related to the api handler factory."""
from typing import Callable
_registry = {}
def register() -> Callable:
"""Decorator for registering a function as an api_handler."""
def wrapper(fcn: Callable):
"""Wrapper inside the decorator for adding to the registry."""
fcn_name = fcn.__name__
if fcn_name not in _registry:
_registry[fcn_name] = fcn
return fcn
return wrapper
|
0 | capitalone_repos/federated-model-aggregation/fma-core/fma_core | capitalone_repos/federated-model-aggregation/fma-core/fma_core/workflows/aggregator_connectors_factory.py | """The base factory class that allows for creation of the aggregator connector."""
import inspect
from abc import ABC
from typing import Any, ClassVar, Dict, List
from fma_core.workflows.metadata_connectors_factory import BaseMetadataConnector
from fma_core.workflows.model_data_connectors_factory import BaseModelDataConnector
class BaseAggConnector(ABC):
"""The factory class to create the aggregator connectors."""
__subclasses = {}
def __init__(self, settings: Dict):
"""Initialization function for the aggregation connector.
:param settings: The settings that will be used to initialize the
aggregation connector
:type settings: Dict
:raises ValueError: metadata_connector not specified in settings
:raises Exception: model_data_connector not specified in settings
"""
# Initialize metadata connector
metadata_connector_settings = settings.get("metadata_connector", {})
metadata_connector_type = metadata_connector_settings.get("type", None)
if metadata_connector_type is None:
raise ValueError("metadata_connector not specified in settings")
self.metadata_connector = BaseMetadataConnector.create(
metadata_connector_type, metadata_connector_settings
)
model_data_connector_settings = settings.get("model_data_connector", {})
model_data_connector_type = model_data_connector_settings.get("type", None)
if model_data_connector_type is None:
raise Exception("model_data_connector not specified in settings")
self.model_data_connector = BaseModelDataConnector.create(
model_data_connector_type, model_data_connector_settings
)
@classmethod
def create(
cls, agg_connector_type: str, agg_connector_settings: Dict = None
) -> ClassVar:
"""Creates subclass of aggregation connector.
:param agg_connector_type: The subclass of aggregation connector to be created
:type agg_connector_type: str
:param agg_connector_settings: The settings to initialize the connector
:type agg_connector_settings: Dict
:raises ValueError: ValueError raised
:return: A valid subclass object of BaseAggConnector
:rtype: ClassVar
"""
if agg_connector_type.lower() not in cls._BaseAggConnector__subclasses:
raise ValueError
return cls._BaseAggConnector__subclasses[agg_connector_type.lower()](
agg_connector_settings
)
@classmethod
def _register_subclass(cls) -> None:
"""Register a subclass for the class factory."""
if not inspect.isabstract(cls):
cls._BaseAggConnector__subclasses[ # type: ignore
cls.__name__.lower()
] = cls
def pull_federated_model_w_id(self, fed_model_id: int) -> Any:
"""Pulls a FederatedModel using its id.
:param fed_model_id: The id of the FederatedModel targeted for pull
:type fed_model_id: int
:return: A FederatedModel object
:rtype: Any
"""
return self.metadata_connector.pull_federated_model_w_id(fed_model_id)
def pull_latest_model_aggregate(self, model: Any) -> Any:
"""Pulls the latest ModelAggregate in a FederatedModel.
:param model: FederatedModel object
:type model: Any
:return: A ModelAggregate object
:rtype: Any
"""
return self.metadata_connector.pull_latest_model_aggregate(model)
def pull_model_updates_ready_for_aggregation(
self, model: Any, parent_agg: Any
) -> List[Any]:
"""Pulls all ModelUpdates ready to be included in an aggregation.
:param model: FederatedModel object
:type model: Any
:param parent_agg: The parent aggregate of the ModelUpdates used
:type parent_agg: Any
:return: A List of ModelUpdates
:rtype: List[Any]
"""
model_updates = (
self.metadata_connector.pull_model_updates_ready_for_aggregation(
model,
parent_agg,
)
)
return model_updates
def pull_model_requirements(self, model: Any) -> Any:
"""Pulls FederatedModel aggregation requirements and their args.
:param model: FederatedModel object
:type model: Any
:return: Requirements for the aggregation process
:rtype: Any
"""
return self.metadata_connector.pull_model_requirements(model)
def register_model_updates_for_aggregation(self, model_updates: List[Any]):
"""Updates status of a list of ModelUpdates to register for aggregation.
:param model_updates: A list of model updates
:type model_updates: List[Any]
"""
self.metadata_connector.register_model_updates_for_aggregation(model_updates)
def pull_model_updates_registered_for_aggregation(self, model: Any) -> List[Any]:
"""Pulls all ModelUpdates registered to be included in an aggregation.
:param model: FederatedModel object
:type model: Any
:return: A list of ModelUpdates ready for aggregation
:rtype: List[Any]
"""
return self.metadata_connector.pull_model_updates_registered_for_aggregation(
model
)
def pull_model_updates_data(self, model_updates: List[Any]) -> Any:
"""Pull Model weights that have been pushed by the clients as model updates.
:param model_updates: A list of model updates
:type model_updates: List[Any]
:return: A list of data used to represent the models associated with a list of
Model Updates
:rtype: Any
"""
return self.model_data_connector.pull_model_updates_data(model_updates)
def prep_model_data_for_storage(self, data: List[Any]) -> Any:
"""Preps model data to be stored as a file object.
:param data: The model data to be stored in file form
:type data: List[Any]
:return: The data object stored in UploadedFile format
:rtype: Any
"""
data = self.model_data_connector.prep_model_data_for_storage(data)
return data
def post_new_model_aggregate(
self, model: Any, parent_agg: Any, results: List[Any]
) -> Any:
"""Creates an entry in a DB of a new ModelAggregate.
:param model: FederatedModel object
:type model: Any
:param parent_agg: The aggregate that the ModelUpdates included were
based on
:type parent_agg: Any
:param results: The data associated with the ModelAggregate being
stored
:type results: Any
:return: Object containing metadata on newly added ModelAggregate
:rtype: Any
"""
aggregate_storage_info = self.model_data_connector.push_model_data_to_storage(
results
)
return self.metadata_connector.post_new_model_aggregate(
model, parent_agg, aggregate_storage_info
)
def pull_model_updates_pending_aggregation(self, model: Any) -> List[Any]:
"""Pulls all ModelUpdates pending inclusion to an aggregation task.
:param model: FederatedModel object
:type model: Any
:return: List of ModelUpdates pulled/filtered
:rtype: List[Any]
"""
return self.metadata_connector.pull_model_updates_pending_aggregation(model)
def register_model_update_used_in_aggregate(
self, model_updates: List[Any], aggregate: Any
):
"""Registers that a list of ModelUpdates were used in an aggregate.
:param model_updates: List of model updates
:type model_updates: List[Any]
:param aggregate: ModelAggregate object
:type aggregate: Any
"""
self.metadata_connector.register_model_update_used_in_aggregate(
model_updates, aggregate
)
def register_model_updates_use_in_aggregation_complete(
self, model_updates: List[Any], is_successful: bool
):
"""Updates status of a list of ModelUpdates to "completed" on an aggregation.
:param model_updates: A list of model updates
:type model_updates: List[Any]
:param is_successful: Value for if the aggregation task was completed
successfully
:type is_successful: bool
"""
self.metadata_connector.register_model_updates_use_in_aggregation_complete(
model_updates, is_successful
)
def register_model_updates_use_in_aggregation_failed(self, model_updates: Any):
"""Updates status of a list of ModelUpdates to "completed" on an aggregation.
:param model_updates: A list of model updates
:type model_updates: Any
"""
self.metadata_connector.register_model_updates_use_in_aggregation_failed(
model_updates
)
def update_metadata_database_arch(self):
"""Used to update the architecture of the metadata database."""
self.metadata_connector.update_database()
|
0 | capitalone_repos/federated-model-aggregation/fma-core/fma_core | capitalone_repos/federated-model-aggregation/fma-core/fma_core/workflows/aggregator_utils.py | """These functions are used to assist in the aggregator connector functionality."""
import abc
from typing import Any, Dict, Tuple
class AutoSubRegistrationMeta(abc.ABCMeta):
"""For registering subclasses."""
def __new__(
mcs, clsname: str, bases: Tuple[type, ...], attrs: Dict[str, object]
) -> Any:
"""Create auto registration object and return new class.
:param clsname: Class name of the object that is being registered
:type clsname: str
:param bases: A tuple containing the base classes, in the order
of their occurrence in the base class list.
:type bases: Tuple[type, ...]
:param attrs: Attributes used to create the object
:type attrs: Dict[str, object]
:return: A newly created class
:rtype: Any
"""
new_class: Any = super(AutoSubRegistrationMeta, mcs).__new__(
mcs, clsname, bases, attrs
)
new_class._register_subclass()
return new_class
|
0 | capitalone_repos/federated-model-aggregation/fma-core/fma_core/algorithms | capitalone_repos/federated-model-aggregation/fma-core/fma_core/algorithms/requirements/common.py | """Used to specify requirements for the aggregation functionality to run."""
def all_clients(model, model_updates):
"""Requires all clients to push update before aggregation is executed.
:param model: Database FederatedModel object
:type model: task_queue_base.models.FederatedModel
:param model_updates: Database objects containing
the original weights used to initialize the shape of the layers
:type model_updates: task_queue_base.models.ModelUpdate
:return: A boolean assertion that indicates if all clients have pushed updates
:rtype: bool
"""
if not set(model.clients.all()).issubset(
set([update.client for update in model_updates])
):
return False
return True
def require_x_updates(model, model_updates, x):
"""Requires x clients to push update before aggregation is executed.
:param model: Database FederatedModel object
:type model: task_queue_base.models.FederatedModel
:param model_updates: Database objects containing
the original weights used to initialize the shape of the layers
:type model_updates: task_queue_base.models.ModelUpdate
:param x: The number of client updates needed
:type x: int
:return: A boolean assertion that indicates if x clients have pushed updates
:rtype: bool
"""
if len(model_updates) < x:
return False
return True
|
0 | capitalone_repos/federated-model-aggregation/fma-core/fma_core/algorithms | capitalone_repos/federated-model-aggregation/fma-core/fma_core/algorithms/aggregators/common.py | """Functions stored here for use in model aggregation."""
import numpy as np
def avg_values_if_data(model, model_updates):
"""
Averages values together if data exists within model_updates.
:param model: Database FederatedModel object
:type model: task_queue_base.models.FederatedModel
:param model_updates: Database objects containing
the original weights used to initialize the shape of the layers
:type model_updates: task_queue_base.models.ModelUpdate
:return: The average value for each update
:rtype: List[Any]
"""
data = [update.data for update in model_updates]
with np.errstate(divide="ignore", invalid="ignore"):
return np.average(data, axis=0).tolist()
def average_layers(model, model_updates):
"""Takes in the weights of multiple models and averages across layers.
:param model: Database FederatedModel object
:type model: task_queue_base.models.FederatedModel
:param model_updates: Database objects containing
the original weights used to initialize the shape of the layers
:type model_updates: task_queue_base.models.ModelUpdate
:returns: A weights obj that is the average of all weights across layers
:rtype: List[List[Any]]
"""
if not model_updates:
return None
avg_model = []
n_models = len(model_updates)
n_layers = len(model_updates[0].data)
for layer_ind in range(n_layers):
layers = []
for model_ind in range(n_models):
layers.append(model_updates[model_ind].data[layer_ind])
avg_model.append(np.average(layers, axis=0).tolist())
return avg_model
|
0 | capitalone_repos/federated-model-aggregation | capitalone_repos/federated-model-aggregation/connectors/README.md | # Connectors
Connectors are used to connect to data sources. Connectors specify both `Metadata`
and `Model Data` connector.
Currently implemented connectors are:
- Django
- Users can create their own!
## Metadata Connector
The metadata connector is used to connect all the service's components to the
metadata database, which is specified by the user in the `aggregator/fma_settings.py`
file.
## Model Data Connector
The model data connector connects to the specified model storage location to query,
load, and upload artifacts.
|
0 | capitalone_repos/federated-model-aggregation/connectors | capitalone_repos/federated-model-aggregation/connectors/django/.pre-commit-config.yaml | files: connectors/django
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: end-of-file-fixer
name: EOF for django
- id: trailing-whitespace
name: Whitespace for django
- id: check-ast
name: Check python parse valid for django
- id: check-docstring-first
name: Check docstring first in django
- repo: https://github.com/psf/black
rev: 22.8.0
hooks:
- id: black
name: Black for django
exclude: connectors/django/fma_django/migrations
- repo: https://github.com/pycqa/flake8
rev: '5.0.4' # pick a git hash / tag to point to
hooks:
- id: flake8
name: Flake8 for django
files: connectors/django/
# https://github.com/PyCQA/pydocstyle/issues/68 for ignore of D401
# https://github.com/OCA/maintainer-quality-tools/issues/552 for ignore of W503
args: ["--config=connectors/django/setup.cfg", "--ignore=D401,W503"]
additional_dependencies: [flake8-docstrings]
exclude: (^.*/tests|^.*/__init__.py|connectors/django/fma_django/migrations)
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort for django
|
0 | capitalone_repos/federated-model-aggregation/connectors | capitalone_repos/federated-model-aggregation/connectors/django/setup.cfg | [metadata]
name = fma-django
description = A Django app for db / model / API connections for the FMA.
long_description = file: README.md
license = Apache License 2.0
classifiers =
Framework :: Django
Framework :: Django :: 4.*
Intended Audience :: Developers
License :: OSI Approved :: Apache Software License
Operating System :: OS Independent
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Topic :: Internet :: WWW/HTTP
Topic :: Internet :: WWW/HTTP :: Dynamic Content
[options]
include_package_data = true
packages = find:
python_requires = >=3.8
[flake8]
exclude=*/migrations/*
extend-ignore = E203
max-line-length = 88
per-file-ignores =
./connectors/django/fma_django/models.py:D106,D107
./connectors/django/fma_django_api/v1/serializers.py:D106
./connectors/django/fma_django_api/v1/filters.py:D106
[isort]
multi_line_output = 3
profile = black
skip_glob = fma_django/migrations/*,aggregator/*,api_service/*,fma-core/*
src_paths = fma_django,fma_django_api,fma_django_connectors
|
0 | capitalone_repos/federated-model-aggregation/connectors | capitalone_repos/federated-model-aggregation/connectors/django/requirements.txt | Django==4.1.10
django-q==1.3.9
django-mptt==0.13.4
numpy==1.22.2
jsonschema==4.4.0
django-storages==1.12.3
boto3==1.26.11
psycopg2-binary==2.9.3
|
0 | capitalone_repos/federated-model-aggregation/connectors | capitalone_repos/federated-model-aggregation/connectors/django/.coveragerc | [run]
omit = */tests/*,conftest.py,fma_django/migrations/*,setup.py
branch = True
|
0 | capitalone_repos/federated-model-aggregation/connectors | capitalone_repos/federated-model-aggregation/connectors/django/conftest.py | """Sets root directory for repo."""
import logging
import os
import sys
from os.path import abspath, dirname, join
from django.conf import settings
log = logging.Logger(name=__file__)
root_dir = dirname(abspath(__file__))
sys.path.append(root_dir)
os.environ["FMA_SETTINGS_MODULE"] = "fma_django_connectors.tests.fma_settings"
os.environ["FMA_DB_SECRET_PATH"] = "fake/path"
settings.configure(
DEBUG=True,
DATABASES={
"default": {
"ENGINE": "django.db.backends.sqlite3",
}
},
ALLOWED_HOSTS=["127.0.0.1", "localhost"],
FIXTURE_DIRS=(join(root_dir, "tests/fixtures"),),
INSTALLED_APPS=(
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
# MPTT install
"mptt",
# REST API
"rest_framework",
"rest_framework.authtoken",
"django_filters",
# task management
"django_q",
# app
"fma_django",
),
SECRET_KEY="TESTING",
USE_TZ=True,
LANGUAGE_CODE="en-us",
TIME_ZONE="UTC",
USE_I18N=True,
IS_LOCAL_DEPLOYMENT=True,
# API reqs
ROOT_URLCONF="fma_django_api.urls",
MIDDLEWARE=[
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
],
REST_FRAMEWORK={
"DEFAULT_AUTHENTICATION_CLASSES": (
"rest_framework.authentication.BasicAuthentication",
"rest_framework.authentication.SessionAuthentication",
"fma_django.authenticators.ClientAuthentication",
"rest_framework.authentication.TokenAuthentication",
),
"DEFAULT_FILTER_BACKENDS": (
"django_filters.rest_framework.DjangoFilterBackend",
"rest_framework.filters.OrderingFilter",
),
},
MEDIA_URL="/mediafiles/",
)
|
0 | capitalone_repos/federated-model-aggregation/connectors | capitalone_repos/federated-model-aggregation/connectors/django/LICENSE | Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
|
0 | capitalone_repos/federated-model-aggregation/connectors | capitalone_repos/federated-model-aggregation/connectors/django/pyproject.toml | [build-system]
requires = ['setuptools>=40.8.0', 'wheel']
build-backend = 'setuptools.build_meta:__legacy__'
|
0 | capitalone_repos/federated-model-aggregation/connectors | capitalone_repos/federated-model-aggregation/connectors/django/CODEOWNERS | * @ksneab7 @tyfarnan @taylorfturner @micdavis @JGSweets
|
0 | capitalone_repos/federated-model-aggregation/connectors | capitalone_repos/federated-model-aggregation/connectors/django/MANIFEST.in | include LICENSE
include README.md
global-exclude .DS_Store
|
0 | capitalone_repos/federated-model-aggregation/connectors | capitalone_repos/federated-model-aggregation/connectors/django/Pipfile | [[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"
[dev-packages]
pytest = "*"
pytest-cov = "*"
pytest-mock = "*"
pytest-django = "*"
flake8 = "*"
pre-commit = "*"
fma-core = {path = "./../../fma-core", editable = true}
[packages]
Django = "4.1.10"
django-q = "1.3.9"
django-mptt = "0.13.4"
numpy = "1.22.2"
jsonschema = "4.4.0"
django-storages = "1.12.3"
boto3 = "1.26.11"
psycopg2-binary = "2.9.3"
djangorestframework = "3.13.1"
django-filter = "22.1"
apig-wsgi = "2.15.0"
[requires]
python_version = "3"
|
0 | capitalone_repos/federated-model-aggregation/connectors | capitalone_repos/federated-model-aggregation/connectors/django/README.md | # FMA-Django
The FMA-Django component is a Django app that connects the FMA to django controlled databases or storage devices.
Detailed documentation is in the `./docs` directory.
Quick start
-----------
1. For installation, choose between just installing the db components or including the API as well.
```console
# install just the db / model connection component
pip install fma-django
# install the db / model / API connection component
pip install "fma-django[api]"
```
2. Add "fma-django" and "fma-django-api" to your INSTALLED_APPS setting like this:
```
INSTALLED_APPS = [
...
'fma_django',
'fma_django_api', # if the API is needed as well
]
```
3. Run ``python manage.py migrate`` to create the polls models (Django database tables).
Testing
-------
Inside a virtualenv:
```
make install
make test
```
For testing and coverage reports:
```
make test-and-coverage
```
|
0 | capitalone_repos/federated-model-aggregation/connectors | capitalone_repos/federated-model-aggregation/connectors/django/Makefile | .PHONY: install
install:
pipenv --rm || true
pipenv --clear
rm -f Pipfile.lock
pipenv install --dev
pipenv run pre-commit install
.PHONY: test
test:
pipenv run pytest
.PHONY: test-and-coverage
test-and-coverage:
pipenv run pytest --junit-xml=junit_xml_test_report.xml --cov-branch --cov=. .
pipenv run coverage xml -i
pipenv run coverage report --fail-under 80
|
0 | capitalone_repos/federated-model-aggregation/connectors | capitalone_repos/federated-model-aggregation/connectors/django/api_endpoints.md | # Web App Endpoints
Local (default port - 8001): http://127.0.0.1:8001
## Command to generate tokens
`python manage.py drf_create_token <username>`
---
## Generate an authorization token
### Endpoint
`api-token-auth`
### Method
POST
### Content Type
application/json
### Data Params
- `username` (string) the username of an admin used to log in
- `password` (string) the password of an admin used to log in
---
## List Federated Models
### Endpoint
`/api/v1/models/`
### Method
GET
---
## Create a Federated Model
### Endpoint
`/api/v1/models/`
### Method
POST
### Content Type
application/json
### Data Params
- `name` (string), name of the model, required
- `allow_aggregation` (bool), boolean to notate if aggregation should be started immediately, required
- `aggregator` (string), method for aggregation, required
- `initial_model` (json), the initial values of model for experimentation, optional
- `clients` (list of string) list of UUIDs of existing clients to be registered, optional
- `requirement` (string) name of requirement to enforce on aggregation, optional
- `requirement_args` (json) args, kwargs to be passed to the aggregation function, optional
- `update_schema` (json), the expected structure of Model Updates, optional
- `client_agg_results_schema` (json), the layout of the results the client is pushing to the FMA service, optional
- `furthest_base_agg` (integer), the delta from the current FMA aggregate id which may be queried from the FMA service by clients for a valid model update, optional
---
## Get Federated Model
### Endpoint
`/api/v1/models/<id>/`
### Method
GET
---
## Get Register Client to a Federated Model
### Endpoint
`/api/v1/models/<id>/register_client`
### Method
POST
### Header Params
- `CLIENT_UUID` (string) UUID of Federated Client registering to model. If None,
gives client their UUID
Example:
```console
# for a new client, it will return their UUID
curl -X POST http://127.0.0.1:8000/api/v1/models/1/register_client/
# for an existing client
curl -X POST http://127.0.0.1:8000/api/v1/models/1/register_client/ -H 'CLIENT-UUID: <UUID>'
```
---
## Publish Aggregate
### Endpoint
`/api/v1/model_aggregates/<id>/publish_aggregate`
### Method
POST
### Data Param
- `version` (string), version for the aggregate, required
---
## Get latest model aggregate as a Client from a Federated Model
### Endpoint
`/api/v1/models/<id>/get_latest_aggregate`
### Method
GET
### Header Params
- `CLIENT_UUID` (string) UUID of Federated Client registering to model. If None,
gives client their UUID
Example:
```console
curl -X GET http://127.0.0.1:8000/api/v1/models/1/get_latest_aggregate/ -H 'CLIENT-UUID: <UUID>'
```
---
## Get latest model
### Endpoint
`/api/v1/models/<id>/get_latest_model`
### Method
GET
### Header Params
- `CLIENT_UUID` (string) UUID of Federated Client registering to model. If None,
gives client their UUID
Example:
```console
curl -X GET http://127.0.0.1:8000/api/v1/models/1/get_latest_model/ -H 'CLIENT-UUID: <UUID>'
```
---
## List Model Updates
### Endpoint
`/api/v1/model_updates/`
### Method
GET
### Header Params
- `CLIENT_UUID` (string) UUID of Federated Client registering to model. If None,
gives client their UUID
Example:
```console
curl -X GET http://127.0.0.1:8000/api/v1/model_updates/ -H 'CLIENT-UUID: <UUID>'
```
---
## Get Model Update
### Endpoint
`/api/v1/model_updates/<ID>/`
### Method
GET
---
## Create a Model Update
### Endpoint
`/api/v1/model_updates/`
### Method
POST
### Content Type
application/json
### Data Params
- `client` (string) UUID of client making the update, required
- `federated_model` (int) id of the model for which to add the update, required
- `data` (json), json of data for the update, required
- `base_aggregate` (ForeignKey), id of the aggregate to which the update was applied, optional
---
## Get Model Aggregates
### Endpoint
`/api/v1/model_aggregates/`
### Method
GET
---
## Get Model Update
### Endpoint
`/api/v1/model_aggregates/<ID>/`
### Method
GET
---
## Data Objects
### Client
- `id` (integer)
- `uuid` (uuid)
### FederatedModel
- `id` (integer)
- `name` (string)
- `developer` (User)
- `clients` (list of Client)
- `requirement` (string) name of requirement func
- `requirement_args` (json) args, kwrags of requirement func
- `update_schema` (json)
- `client_agg_results_schema` (json)
- `scheduler` (OnetoOne Field)
- `furthest_base_agg` (Positive Integer)
### ModelArtifact
- `id` (integer)
- `values` (File)
- `federated_model` (ForeignKey)
- `version` (string)
### ModelAggregate
- `id` (integer)
- `federated_model` (FederatedModel)
- `parent` (TreeForeignKey)
- `result` (json) output of aggregation
- `validation_score` (Float)
### ModelUpdate
- `id` (integer)
- `client` (Client)
- `federated_model` (FederatedModel)
- `data` (json)
- `status` (Integer)
- `base_aggregate` (ForeignKey)
- `applied_aggregate` (ForeignKey)
### ClientAggregateScore
- `id` (integer)
- `aggregate` (ForeignKey)
- `client` (ForeignKey)
- `validation_results` (json)
|
0 | capitalone_repos/federated-model-aggregation/connectors | capitalone_repos/federated-model-aggregation/connectors/django/requirements-dev.txt | pytest
pytest-cov
pytest-mock
pytest-django
flake8
black
pre-commit
isort
|
0 | capitalone_repos/federated-model-aggregation/connectors | capitalone_repos/federated-model-aggregation/connectors/django/setup.py | """Setup.py for fma-django."""
# To use a consistent encoding
import os
from codecs import open
# Always prefer setuptools over distutils
from setuptools import find_packages, setup
# Load package version
from fma_django.version import __version__
project_path = os.path.abspath(os.path.dirname(__file__))
# Get the long description from the README file
with open(os.path.join(project_path, "README.md"), encoding="utf-8") as f:
LONG_DESCRIPTION = f.read()
# Get the install_requirements from requirements.txt
with open(os.path.join(project_path, "requirements.txt"), encoding="utf-8") as f:
required_packages = f.read().splitlines()
# Get the api_install_requirements from requirements-api.txt
with open(os.path.join(project_path, "requirements-api.txt"), encoding="utf-8") as f:
api_required_packages = f.read().splitlines()
DESCRIPTION = "Federated Model Aggregation's Django Connectors"
packages = find_packages(exclude=["*.tests"])
setup(
name="fma-django",
author="Kenny Bean, Tyler Farnan, Taylor Turner, Michael Davis, Jeremy Goodsitt",
version=__version__,
python_requires=">=3.8",
description=DESCRIPTION,
long_description=LONG_DESCRIPTION,
long_description_content_type="text/markdown",
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Intended Audience :: Information Technology",
"Intended Audience :: Education",
"Intended Audience :: Science/Research",
"Topic :: Education",
"Topic :: Scientific/Engineering :: Information Analysis",
"License :: OSI Approved :: Apache Software License",
"Topic :: Scientific/Engineering",
"Programming Language :: Python :: 3",
],
# The project's main homepage.
url="https://github.com/capitalone/federated-model-aggregation",
# Choose your license
license="Apache License, Version 2.0",
keywords="Federated Learning",
# You can just specify the packages manually here if your project is
# simple. Or you can use find_packages().
# packages=find_packages(exclude=['src/test', 'src/sample']),
packages=packages,
# List run-time dependencies here. These will be installed by pip when
# requirements files see:
# your project is installed. For an analysis of "install_requires" vs pip's
# https://packaging.python.org/en/latest/requirements.html
install_requires=required_packages,
# List of run-time dependencies for the labeler. These will be installed
# by pip when someone installs the project[<label>].
extras_require={"api": api_required_packages},
# # If there are data files included in your packages that need to be
# # have to be included in MANIFEST.in as well.
# # installed, specify them here. If using Python 2.6 or less, then these
include_package_data=True,
data_files=None,
)
print("find_packages():", packages)
|
0 | capitalone_repos/federated-model-aggregation/connectors | capitalone_repos/federated-model-aggregation/connectors/django/requirements-api.txt | djangorestframework==3.13.1
jsonschema==4.4.0
django-filter==22.1
apig-wsgi==2.15.0
|
0 | capitalone_repos/federated-model-aggregation/connectors/django | capitalone_repos/federated-model-aggregation/connectors/django/tests/test_models.py | from unittest import mock
from django.test import TestCase, override_settings
from fma_django import models
from fma_django.models import (
create_model_aggregation_schedule_local,
create_model_aggregation_schedule_remote,
delete_model_aggregation_schedule_local,
)
def mock_schedule_exists(self):
return False
def client_api_mock(operation_name, *args, **kwargs):
if operation_name not in ["PutRule", "PutTargets", "DeleteRule"]:
raise Exception(f"Error: No mock api for {operation_name}")
def mock_for_call_test():
return True
@mock.patch(
"django.core.files.storage.FileSystemStorage.save", return_value="save_create"
)
class TestModelsFunctions(TestCase):
fixtures = [
"TaskQueue_client.json",
"DjangoQ_Schedule.json",
"TaskQueue_User.json",
"TaskQueue_FederatedModel.json",
"TaskQueue_ModelUpdate.json",
"TaskQueue_ModelAggregate.json",
]
@override_settings(IS_LOCAL_DEPLOYMENT=True)
@mock.patch(
"fma_django.models.create_model_aggregation_schedule_local",
side_effect=create_model_aggregation_schedule_local,
)
def test_create_model_aggregation_schedule_local(
self, mock_local_agg_task, save_create
):
# Ensure correct function is called when IS_LOCAL_DEPLOYMENT set True
user = models.User.objects.get(id=1)
fed_model = models.FederatedModel.objects.create(
name="temp_test", developer=user
)
# Called twice, once on creation and once on save to DB
self.assertEqual(2, mock_local_agg_task.call_count)
self.assertIsNotNone(fed_model.scheduler)
@override_settings(
IS_LOCAL_DEPLOYMENT=False,
AGGREGATOR_LAMBDA_ARN="<TMP_LAMBDA_ARN>",
TAGS={"TMP_KEY1": "TMP_VALUE1", "TMP_KEY2": "TMP_VALUE2"},
)
@mock.patch(
"botocore.client.BaseClient._make_api_call", side_effect=client_api_mock
)
@mock.patch(
"fma_django.models.create_model_aggregation_schedule_remote",
side_effect=create_model_aggregation_schedule_remote,
)
def test_create_model_aggregation_schedule_remote(
self, mock_remote_agg_task, mock_botocore_api, save_create
):
# Ensure correct function is called when IS_LOCAL_DEPLOYMENT set False
user = models.User.objects.get(id=1)
fed_model = models.FederatedModel.objects.create(
name="temp_test", developer=user
)
expected_value = [
{"Key": "TMP_KEY1", "Value": "TMP_VALUE1"},
{"Key": "TMP_KEY2", "Value": "TMP_VALUE2"},
]
# Called twice, once on creation and once on save to DB
self.assertEqual(1, mock_remote_agg_task.call_count)
self.assertIsNone(fed_model.scheduler)
# First index of call_args_list is "1" due to multiple calls to aws
self.assertListEqual(
expected_value, mock_botocore_api.call_args_list[1][0][1]["Tags"]
)
@override_settings(IS_LOCAL_DEPLOYMENT=True)
@mock.patch(
"fma_django.models.delete_model_aggregation_schedule_local",
side_effect=delete_model_aggregation_schedule_local,
)
def test_delete_model_aggregation_schedule_local(
self, mock_local_delete_task, save_create
):
# Model with scheduler, scheduler deleted
fed_model = models.FederatedModel.objects.get(id=1)
scheduler_id = fed_model.scheduler.id
fed_model.delete()
self.assertEqual(1, mock_local_delete_task.call_count)
self.assertEqual(0, models.Schedule.objects.filter(id=scheduler_id).count())
@override_settings(IS_LOCAL_DEPLOYMENT=False)
@mock.patch(
"botocore.client.BaseClient._make_api_call", side_effect=client_api_mock
)
@mock.patch(
"fma_django.models.delete_model_aggregation_schedule_remote",
side_effect=delete_model_aggregation_schedule_local,
)
def test_delete_model_aggregation_schedule_remote(
self, mock_remote_delete_task, mock_botocore_api, save_create
):
# Model with scheduler, scheduler deleted
fed_model = models.FederatedModel.objects.get(id=1)
fed_model.delete()
self.assertEqual(1, mock_remote_delete_task.call_count)
|
0 | capitalone_repos/federated-model-aggregation/connectors/django/tests | capitalone_repos/federated-model-aggregation/connectors/django/tests/fixtures/DjangoQ_Task.json | [
{
"model": "django_q.task",
"pk": "00e1e856f432482a8ec88766615c5764",
"fields": {
"name": "hotel-one-oregon-autumn",
"func": "fma_django_api.v1.aggregator_components.tasks.agg_service",
"hook": "fma_django_api.v1.aggregator_components.tasks.post_agg_service_hook",
"args": "gAWVBQAAAAAAAABLAYWULg==",
"kwargs": "gAV9lC4=",
"result": null,
"group": "1",
"started": "2022-11-03T15:47:25.437Z",
"stopped": "2022-11-03T15:47:25.555Z",
"success": true,
"attempt_count": 1
}
},
{
"model": "django_q.task",
"pk": "0246b30654ac4cc9b3eaa66835554dba",
"fields": {
"name": "washington-louisiana-nebraska-nebraska",
"func": "fma_django_api.v1.aggregator_components.tasks.agg_service",
"hook": "fma_django_api.v1.aggregator_components.tasks.post_agg_service_hook",
"args": "gAWVBQAAAAAAAABLAoWULg==",
"kwargs": "gAV9lC4=",
"result": null,
"group": "2",
"started": "2023-01-16T21:37:02.390Z",
"stopped": "2023-01-16T21:37:02.399Z",
"success": true,
"attempt_count": 1
}
},
{
"model": "django_q.task",
"pk": "03b637f07453428c82838f30e4f4c84c",
"fields": {
"name": "king-utah-sad-mountain",
"func": "fma_django_api.v1.aggregator_components.tasks.agg_service",
"hook": "fma_django_api.v1.aggregator_components.tasks.post_agg_service_hook",
"args": "gAWVBQAAAAAAAABLAYWULg==",
"kwargs": "gAV9lC4=",
"result": null,
"group": "1",
"started": "2022-12-13T23:32:25.130Z",
"stopped": "2022-12-13T23:32:25.285Z",
"success": true,
"attempt_count": 1
}
},
{
"model": "django_q.task",
"pk": "0524ce5f18684e3c809bce35490b21ca",
"fields": {
"name": "pizza-alanine-timing-oven",
"func": "fma_django_api.v1.aggregator_components.tasks.agg_service",
"hook": "fma_django_api.v1.aggregator_components.tasks.post_agg_service_hook",
"args": "gAWVBQAAAAAAAABLAYWULg==",
"kwargs": "gAV9lC4=",
"result": null,
"group": "1",
"started": "2022-12-11T23:34:25.975Z",
"stopped": "2022-12-11T23:34:26.130Z",
"success": true,
"attempt_count": 1
}
},
{
"model": "django_q.task",
"pk": "06fe00da1cfe4983b140a9fd8aac19ed",
"fields": {
"name": "carpet-cola-orange-spring",
"func": "fma_django_api.v1.aggregator_components.tasks.agg_service",
"hook": "fma_django_api.v1.aggregator_components.tasks.post_agg_service_hook",
"args": "gAWVBQAAAAAAAABLAYWULg==",
"kwargs": "gAV9lC4=",
"result": null,
"group": "1",
"started": "2022-11-29T16:31:15.312Z",
"stopped": "2022-11-29T16:31:15.318Z",
"success": true,
"attempt_count": 1
}
},
{
"model": "django_q.task",
"pk": "07d13f2f26af4abfbc8c96300418384b",
"fields": {
"name": "single-london-music-kansas",
"func": "fma_django_api.v1.aggregator_components.tasks.agg_service",
"hook": "fma_django_api.v1.aggregator_components.tasks.post_agg_service_hook",
"args": "gAWVBQAAAAAAAABLAYWULg==",
"kwargs": "gAV9lC4=",
"result": null,
"group": "1",
"started": "2023-01-09T15:39:21.762Z",
"stopped": "2023-01-09T15:39:21.769Z",
"success": true,
"attempt_count": 1
}
},
{
"model": "django_q.task",
"pk": "08b7aa01d6754ad7afd5afe0f164e049",
"fields": {
"name": "berlin-emma-double-eighteen",
"func": "fma_django_api.v1.aggregator_components.tasks.agg_service",
"hook": "fma_django_api.v1.aggregator_components.tasks.post_agg_service_hook",
"args": "gAWVBQAAAAAAAABLAYWULg==",
"kwargs": "gAV9lC4=",
"result": null,
"group": "1",
"started": "2023-01-23T15:10:08.631Z",
"stopped": "2023-01-23T15:10:08.639Z",
"success": true,
"attempt_count": 1
}
},
{
"model": "django_q.task",
"pk": "0b379ab5c37f4ef9b98ae950e617c39c",
"fields": {
"name": "beer-asparagus-mike-pennsylvania",
"func": "fma_django_api.v1.aggregator_components.tasks.agg_service",
"hook": "fma_django_api.v1.aggregator_components.tasks.post_agg_service_hook",
"args": "gAWVBQAAAAAAAABLAYWULg==",
"kwargs": "gAV9lC4=",
"result": null,
"group": "1",
"started": "2022-12-17T16:52:24.624Z",
"stopped": "2022-12-17T16:52:24.631Z",
"success": true,
"attempt_count": 1
}
},
{
"model": "django_q.task",
"pk": "0b81094263fb44fc91f61aa7c1aa4ac3",
"fields": {
"name": "september-cardinal-ten-twelve",
"func": "fma_django_api.v1.aggregator_components.tasks.agg_service",
"hook": "fma_django_api.v1.aggregator_components.tasks.post_agg_service_hook",
"args": "gAWVBQAAAAAAAABLAYWULg==",
"kwargs": "gAV9lC4=",
"result": null,
"group": "1",
"started": "2022-12-28T16:29:14.380Z",
"stopped": "2022-12-28T16:29:14.387Z",
"success": false,
"attempt_count": 1
}
}
]
|
0 | capitalone_repos/federated-model-aggregation/connectors/django/tests | capitalone_repos/federated-model-aggregation/connectors/django/tests/fixtures/TaskQueue_FederatedModel.json | [
{
"model": "fma_django.federatedmodel",
"pk": 1,
"fields": {
"name": "test",
"developer": 1,
"current_artifact": null,
"requirement": "require_x_updates",
"requirement_args": [
3
],
"aggregator": "avg_values_if_data",
"update_schema": {
"type": "array",
"prefixItems": [
{"type": "array", "minItems": 3, "maxItems": 3},
{"type": "array", "minItems": 3, "maxItems": 3}
],
"items": false
},
"client_agg_results_schema": {
"properties": {
"f1_score": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"description": {
"type": "string"
}
}
},
"scheduler": 1,
"created_on": "2022-12-15T23:08:28.693Z",
"last_modified": "2022-12-18T23:08:28.693Z",
"clients": [
"531580e6-ce6c-4f01-a5aa-9ed7af5ee768",
"ab359e5d-6991-4088-8815-a85d3e413c02",
"cbb6025f-c15c-4e90-b3fb-85626f7a79f1"
]
}
},
{
"model": "fma_django.federatedmodel",
"pk": 2,
"fields": {
"name": "test-non-admin",
"developer": 2,
"current_artifact": null,
"requirement": "all_clients",
"requirement_args": null,
"aggregator": "avg_values_if_data",
"update_schema": null,
"scheduler": 2,
"created_on": "2022-12-24T23:08:28.693Z",
"last_modified": "2022-12-28T23:08:28.693Z",
"clients": []
}
},
{
"model": "fma_django.federatedmodel",
"pk": 3,
"fields": {
"name": "test-no-aggregate",
"developer": 2,
"current_artifact": null,
"requirement": "all_clients",
"requirement_args": null,
"aggregator": "avg_values_if_data",
"update_schema": {
"type": "array",
"prefixItems": [
{"type": "array", "minItems": 3, "maxItems": 3},
{"type": "array", "minItems": 3, "maxItems": 3}
],
"items": false
},
"scheduler": 3,
"created_on": "2022-12-18T23:08:28.693Z",
"last_modified": "2022-12-19T23:08:28.693Z",
"clients": [
"cbb6025f-c15c-4e90-b3fb-85626f7a79f1"
]
}
}
]
|
0 | capitalone_repos/federated-model-aggregation/connectors/django/tests | capitalone_repos/federated-model-aggregation/connectors/django/tests/fixtures/TaskQueue_User.json | [
{
"model": "auth.user",
"pk": 1,
"fields": {
"password": "this_is_a_fake_password",
"last_login": "2023-01-21T00:37:10.275Z",
"is_superuser": true,
"username": "admin",
"first_name": "",
"last_name": "",
"email": "",
"is_staff": true,
"is_active": true,
"date_joined": "2023-01-09T19:00:10.922Z",
"groups": [],
"user_permissions": []
}
},
{
"model": "auth.user",
"pk": 2,
"fields": {
"password": "this_is_another_fake_password",
"last_login": null,
"is_superuser": false,
"username": "non_admin",
"first_name": "",
"last_name": "",
"email": "",
"is_staff": false,
"is_active": true,
"date_joined": "2022-12-26T03:14:46Z",
"groups": [],
"user_permissions": []
}
}
]
|
0 | capitalone_repos/federated-model-aggregation/connectors/django/tests | capitalone_repos/federated-model-aggregation/connectors/django/tests/fixtures/TaskQueue_ModelArtifact.json | [
{
"model": "fma_django.modelartifact",
"pk": 3,
"fields": {
"values": "fake/path/model_artifact/1",
"federated_model": 1,
"version": "1.0.0",
"created_on": "2022-12-12T23:55:34.066Z"
}
}
]
|
0 | capitalone_repos/federated-model-aggregation/connectors/django/tests | capitalone_repos/federated-model-aggregation/connectors/django/tests/fixtures/TaskQueue_ClientAggregateScore.json | [
{
"model": "fma_django.clientaggregatescore",
"pk": 1,
"fields": {
"client": "cbb6025f-c15c-4e90-b3fb-85626f7a79f1",
"validation_results": {
"f1_score": 0.8
},
"created_on": "2022-02-15T23:08:28.720Z",
"aggregate": 1
}
},
{
"model": "fma_django.clientaggregatescore",
"pk": 2,
"fields": {
"client": "cbb6025f-c15c-4e90-b3fb-85626f7a79f1",
"validation_results": {
"prec": 0.25,
"rec": 0.4,
"skew": 0.6
},
"created_on": "2022-02-15T23:08:28.720Z",
"aggregate": 2
}
}
]
|
0 | capitalone_repos/federated-model-aggregation/connectors/django/tests | capitalone_repos/federated-model-aggregation/connectors/django/tests/fixtures/TaskQueue_ModelUpdate.json | [
{
"model": "fma_django.modelupdate",
"pk": 1,
"fields": {
"client": "cbb6025f-c15c-4e90-b3fb-85626f7a79f1",
"federated_model": 1,
"data": "fake/path/model_updates/1",
"status": 2,
"created_on": "2022-12-15T23:08:28.720Z"
}
},
{
"model": "fma_django.modelupdate",
"pk": 2,
"fields": {
"client": "cbb6025f-c15c-4e90-b3fb-85626f7a79f1",
"federated_model": 1,
"data": "fake/path/model_updates/2",
"status": 2,
"created_on": "2023-01-10T23:10:33.720Z"
}
},
{
"model": "fma_django.modelupdate",
"pk": 3,
"fields": {
"client": "531580e6-ce6c-4f01-a5aa-9ed7af5ee768",
"federated_model": 1,
"data": "fake/path/model_updates/3",
"status": 2,
"created_on": "2023-01-16T23:17:35.480Z"
}
},
{
"model": "fma_django.modelupdate",
"pk": 4,
"fields": {
"client": "531580e6-ce6c-4f01-a5aa-9ed7af5ee768",
"federated_model": 1,
"data": "fake/path/model_updates/4",
"status": 3,
"created_on": "2022-02-17T17:58:13.819Z"
}
},
{
"model": "fma_django.modelupdate",
"pk": 5,
"fields": {
"client": "cbb6025f-c15c-4e90-b3fb-85626f7a79f1",
"federated_model": 2,
"data": "fake/path/model_updates/5",
"status": 0,
"created_on": "2022-02-17T17:58:44.441Z"
}
},
{
"model": "fma_django.modelupdate",
"pk": 6,
"fields": {
"client": "ab359e5d-6991-4088-8815-a85d3e413c02",
"federated_model": 2,
"data": "fake/path/model_updates/6",
"status": 0,
"base_aggregate": 2,
"created_on": "2022-02-28T00:36:54.803Z"
}
},
{
"model": "fma_django.modelupdate",
"pk": 7,
"fields": {
"client": "cbb6025f-c15c-4e90-b3fb-85626f7a79f1",
"federated_model": 3,
"data": "fake/path/model_updates/7",
"status": 0,
"created_on": "2022-12-26T01:12:55.467Z"
}
},
{
"model": "fma_django.modelupdate",
"pk": 8,
"fields": {
"client": "cbb6025f-c15c-4e90-b3fb-85626f7a79f1",
"federated_model": 3,
"data": "fake/path/model_updates/8",
"status": 0,
"created_on": "2022-12-08T13:22:24.557Z"
}
}
]
|
0 | capitalone_repos/federated-model-aggregation/connectors/django/tests | capitalone_repos/federated-model-aggregation/connectors/django/tests/fixtures/TaskQueue_client.json | [
{
"model": "fma_django.client",
"pk": "531580e6-ce6c-4f01-a5aa-9ed7af5ee768",
"fields": {}
},
{
"model": "fma_django.client",
"pk": "ab359e5d-6991-4088-8815-a85d3e413c02",
"fields": {}
},
{
"model": "fma_django.client",
"pk": "cbb6025f-c15c-4e90-b3fb-85626f7a79f1",
"fields": {}
}
]
|
0 | capitalone_repos/federated-model-aggregation/connectors/django/tests | capitalone_repos/federated-model-aggregation/connectors/django/tests/fixtures/DjangoQ_Schedule.json | [
{
"model": "django_q.schedule",
"pk": 1,
"fields": {
"name": "1 - test - Scheduled Aggregator",
"func": "fma_django_api.v1.aggregator_components.tasks.agg_service",
"hook": "fma_django_api.v1.aggregator_components.tasks.post_agg_service_hook",
"args": "(1,)",
"kwargs": "{}",
"schedule_type": "I",
"minutes": 1,
"repeats": -792,
"next_run": "2023-01-22T02:53:45Z",
"cron": null,
"task": "1da0e26c81b74b62a24d297483623668",
"cluster": null
}
},
{
"model": "django_q.schedule",
"pk": 2,
"fields": {
"name": "2 - test-non-admin - Scheduled Aggregator",
"func": "fma_django_api.v1.aggregator_components.tasks.agg_service",
"hook": "fma_django_api.v1.aggregator_components.tasks.post_agg_service_hook",
"args": "(1,)",
"kwargs": "{}",
"schedule_type": "I",
"minutes": 1,
"repeats": 0,
"next_run": "2022-12-10T05:15:00Z",
"cron": null,
"task": "1da0e26c81b74b62a24d297483623668",
"cluster": null
}
},
{
"model": "django_q.schedule",
"pk": 3,
"fields": {
"name": "3 - test-non-aggregate - Scheduled Aggregator",
"func": "fma_django_api.v1.aggregator_components.tasks.agg_service",
"hook": "fma_django_api.v1.aggregator_components.tasks.post_agg_service_hook",
"args": "(1,)",
"kwargs": "{}",
"schedule_type": "I",
"minutes": 1,
"repeats": -792,
"next_run": "2022-01-09T07:18:23Z",
"cron": null,
"task": "1da0e26c81b74b62a24d297483623668",
"cluster": null
}
}
]
|
0 | capitalone_repos/federated-model-aggregation/connectors/django/tests | capitalone_repos/federated-model-aggregation/connectors/django/tests/fixtures/TaskQueue_ModelAggregate.json | [
{
"model": "fma_django.modelaggregate",
"pk": 1,
"fields": {
"federated_model": 1,
"result": "fake/path/model_aggregate/1",
"validation_score": 1.0,
"created_on": "2023-01-13T23:08:28.712Z",
"parent": null,
"level": 0,
"lft": 1,
"rght": 2,
"tree_id": 0
}
},
{
"model": "fma_django.modelaggregate",
"pk": 2,
"fields": {
"federated_model": 2,
"result": "fake/path/model_aggregate/2",
"validation_score": null,
"created_on": "2023-01-20T23:08:28.712Z",
"parent": null,
"level": 0,
"lft": 1,
"rght": 2,
"tree_id": 1
}
}
]
|
0 | capitalone_repos/federated-model-aggregation/connectors/django | capitalone_repos/federated-model-aggregation/connectors/django/fma_django_connectors/aggregator_connector.py | """Objects used to connect the aggregator components."""
import json
from typing import Any, Dict, List
import django
from django.apps import apps
from django.conf import settings
from fma_core.workflows.aggregator_connectors_factory import BaseAggConnector
from fma_core.workflows.aggregator_utils import AutoSubRegistrationMeta
from fma_core.workflows.metadata_connectors_factory import BaseMetadataConnector
if not apps.ready and not settings.configured:
django.setup()
from fma_django.models import FederatedModel, ModelAggregate, ModelUpdate
from fma_django_connectors import utils
class DjangoAggConnector(BaseAggConnector, metaclass=AutoSubRegistrationMeta):
"""Dajngo version of the aggregator conenctor class."""
def __init__(self, settings: Dict):
"""Initialization function for the DajngoAggConnector class.
:param settings: The settings that will be used to initialize the
aggregation connector
:type settings: Dict
:raises ValueError: metadata_connector not specified in settings
"""
metadata_connector_settings = settings.get("metadata_connector", {})
metadata_connector_type = metadata_connector_settings.get("type", None)
if metadata_connector_type is None:
raise ValueError("metadata_connector not specified in settings")
self.metadata_connector = BaseMetadataConnector.create(
metadata_connector_type, metadata_connector_settings
)
def post_new_model_aggregate(
self, model: FederatedModel, parent_agg: ModelAggregate, results: List[Any]
) -> Any:
"""Creates an entry in a DB of a new ModelAggregate.
:param model: FederatedModel object
:type model: task_queue_base.models.FederatedModel
:param parent_agg: The aggregate that the ModelUpdates included were
based on
:type parent_agg: task_queue_base.models.ModelAggregate
:param results: The data associated with the ModelAggregate being
stored
:type results: List[Any]
:return: Object containing metadata on newly added ModelAggregate
:rtype: Any
"""
# Prep aggregation results for DB storage
aggregate = self.metadata_connector.post_new_model_aggregate(
model, parent_agg, results
)
return aggregate
def pull_model_updates_data(self, model_updates: List[ModelUpdate]) -> Any:
"""Pull Model weights that have been pushed by the clients as model updates.
:param model_updates: A list of model updates
:type model_updates: List[task_queue_base.models.ModelUpdate]
:return: A list of Model data associated with
the models in a list of Model Updates
:rtype: Any
"""
for model_update in model_updates:
with model_update.data.open("r") as f:
model_update.data = json.load(f)
return model_updates
def prep_model_data_for_storage(self, data: List[Any]) -> Any:
"""Preps model data to be stored as a file object.
:param data: The model data to be stored in file form
:type data: List[Any]
:return: The data object stored in UploadedFile format
:rtype: django.core.files.uploadedfile.UploadedFile
"""
data = utils.create_model_file(data)
return data
|
0 | capitalone_repos/federated-model-aggregation/connectors/django | capitalone_repos/federated-model-aggregation/connectors/django/fma_django_connectors/metadata_connector.py | """Objects used to connect to metadata components."""
from typing import Any, List
from django.core.management import call_command as django_call_command
from django.db.models import Q
from fma_core.workflows.aggregator_utils import AutoSubRegistrationMeta
from fma_core.workflows.metadata_connectors_factory import BaseMetadataConnector
from fma_django import models as fma_django_models
from fma_django.models import FederatedModel, ModelAggregate, ModelUpdate
class DjangoMetadataConnector(BaseMetadataConnector, metaclass=AutoSubRegistrationMeta):
"""The metadata connector object used for connection to Django FMA setup."""
def __init__(self, settings):
"""
Initialization of the DjangoMetadataConnector class.
:param settings: The settings that will be used to initialize the
aggregation connector
:type settings: Dict
"""
super().__init__(settings)
def pull_federated_model_w_id(self, fed_model_id: int) -> FederatedModel:
"""Pulls a FederatedModel using its id.
:param fed_model_id: The id of the FederatedModel targeted for pull
:type fed_model_id: int
:return: The FederatedModel object pulled from DB
:rtype: task_queue_base.models.FederatedModel
"""
return fma_django_models.FederatedModel.objects.filter(id=fed_model_id).first()
def pull_latest_model_aggregate(self, model: FederatedModel) -> ModelAggregate:
"""Pulls the latest ModelAggregate in a FederatedModel.
:param model: FederatedModel object
:type model: task_queue_base.models.FederatedModel
:return: The ModelAggregate registered with the FederatedModel most
recently
:rtype: task_queue_base.models.ModelAggregate
"""
return model.aggregates.order_by("-created_on").first()
def pull_model_updates_ready_for_aggregation(
self, model: FederatedModel, parent_agg: ModelAggregate
) -> List[ModelUpdate]:
"""Pulls all ModelUpdates ready to be included in an aggregation.
:param model: FederatedModel object
:type model: task_queue_base.models.FederatedModel
:param parent_agg: The parent aggregate of the ModelUpdates used
:type: task_queue_base.models.ModelAggregate
:return: List of ModelUpdates pulled/filtered
:rtype: List[task_queue_base.models.ModelUpdates]
"""
# Pulls for all ModelUpdates pending aggregation inclusion
model_updates = self.pull_model_updates_pending_aggregation(model)
# Filter updates based on the FederatedModel furthest_base_agg requirement
if (
parent_agg
and model.furthest_base_agg is not None
and model.aggregates.count()
):
allowed_base_aggs = parent_agg.get_ancestors(ascending=True)[
: model.furthest_base_agg
]
model_updates = model_updates.filter(base_aggregate__in=allowed_base_aggs)
return model_updates
def pull_model_requirements(self, model: FederatedModel) -> List:
"""Pulls FederatedModel aggregation requirements and their args.
:param model: FederatedModel object
:type model: task_queue_base.models.FederatedModel
:return: The requirements set for aggregation to occur
:rtype: List[Union[str, int, float, bool, None, List, Dict]]
"""
requirement = None
if model.requirement:
requirement = model.requirement
requirement_args = []
if model.requirement_args:
requirement_args = model.requirement_args
return [requirement, requirement_args]
def register_model_updates_for_aggregation(self, model_updates: ModelUpdate):
"""Updates status of a list of ModelUpdates to register for aggregation.
:param model_updates: A list of model updates
:type model_updates: task_queue_base.models.ModelUpdate
"""
model_updates.update(status=fma_django_models.ModelUpdate.TaskStatus.RUNNING)
def pull_model_updates_registered_for_aggregation(
self, model: FederatedModel
) -> List[ModelUpdate]:
"""Pulls all ModelUpdates registered to be included in an aggregation.
:param model: FederatedModel object
:type model: task_queue_base.models.FederatedModel
:return: List of ModelUpdates pulled/filtered
:rtype: List[task_queue_base.models.ModelUpdate]
"""
return model.model_updates.filter(
status=fma_django_models.ModelUpdate.TaskStatus.RUNNING
)
def post_new_model_aggregate(
self, model: FederatedModel, parent_agg: ModelAggregate, results: List[Any]
) -> ModelAggregate:
"""Creates an entry in a DB of a new ModelAggregate.
:param model: FederatedModel object
:type model: task_queue_base.models.FederatedModel
:param parent_agg: The aggregate that the ModelUpdates included were
based on
:type parent_agg: task_queue_base.models.ModelAggregate
:param results: The data associated with the ModelAggregate being
stored
:type results: List[Any]
:return: Object containing metadata on newly added ModelAggregate
:rtype: task_queue_base.models.ModelAggregate
"""
return fma_django_models.ModelAggregate.objects.create(
federated_model=model, result=results, parent=parent_agg
)
def pull_model_updates_pending_aggregation(
self, model: FederatedModel
) -> List[ModelUpdate]:
"""Pulls all ModelUpdates pending inclusion to an aggregation task.
:param model: FederatedModel object
:type model: task_queue_base.models.FederatedModel
:return: List of ModelUpdates pulled/filtered
:rtype: List[task_queue_base.models.ModelUpdates]
"""
# filter relative to task status (PENDING | FAILED) for a model
return model.model_updates.filter(
Q(status=fma_django_models.ModelUpdate.TaskStatus.PENDING)
| Q(status=fma_django_models.ModelUpdate.TaskStatus.FAILED)
).filter(client__in=model.clients.all())
def register_model_update_used_in_aggregate(
self, model_updates: List[ModelUpdate], aggregate: ModelAggregate
):
"""Registers whether a list of ModelUpdates were used in an aggregate.
:param model_updates: List of model updates
:type: List[task_queue_base.models.ModelUpdate]
:param aggregate: ModelAggregate object
:type: task_queue_base.models.ModelAggregate
"""
model_updates.update(applied_aggregate=aggregate)
def register_model_updates_use_in_aggregation_complete(
self, model_updates: List[Any], is_successful: bool
):
"""Updates status of a list of ModelUpdates to "completed" on an aggregation.
:param model_updates: A list of model updates
:type model_updates: List[Any]
:param is_successful: Boolean value for if the aggregation task was completed
successfully
:type is_successful: bool
"""
status = fma_django_models.ModelUpdate.TaskStatus.FAILED
if is_successful:
status = fma_django_models.ModelUpdate.TaskStatus.COMPLETE
model_updates.update(status=status)
def update_database(self):
"""Migrate django database."""
django_call_command("migrate")
|
0 | capitalone_repos/federated-model-aggregation/connectors/django | capitalone_repos/federated-model-aggregation/connectors/django/fma_django_connectors/api_handlers.py | """API Service Handlers for FMA Django."""
import logging
import django
from django.apps import apps
from django.conf import settings
from django.core.wsgi import get_wsgi_application
from fma_core.workflows.api_handler_utils import register as register_api_handler
try:
from apig_wsgi import make_lambda_handler
except ModuleNotFoundError as e:
# apig_wsgi is only needed for the api_handler
if "No module named 'apig_wsgi'" not in str(e):
raise
if not apps.ready and not settings.configured:
django.setup()
logger = logging.getLogger()
logger.setLevel(logging.INFO)
_real_handler = None
@register_api_handler()
def django_lambda_handler(event, context):
"""Entry point for web requests."""
global _real_handler
if _real_handler is None:
application = get_wsgi_application()
_real_handler = make_lambda_handler(application, binary_support=True)
try:
handler_ret_val = _real_handler(event, context)
except Exception as e:
logger.error(e)
raise
logger.warning(f"_real_handler return value {handler_ret_val}")
logger.warning(f"_real_handler type {type(handler_ret_val)}")
return handler_ret_val
|
0 | capitalone_repos/federated-model-aggregation/connectors/django | capitalone_repos/federated-model-aggregation/connectors/django/fma_django_connectors/utils.py | """General util functions for the django connector functionality."""
import json
import uuid
from io import BytesIO
from django.core.files.uploadedfile import UploadedFile
def create_model_file(data):
"""Create a django json file object of the model weights data.
:param data: Model weights data
:type data: Any
:return: a json object of the model weights and metadata expected by the API service
:rtype: django.core.files.uploadedfile.UploadedFile
"""
data_io = BytesIO(json.dumps(data).encode("utf-8"))
data = UploadedFile(data_io)
data.name = str(uuid.uuid4())
data.size = data_io.getbuffer().nbytes
return data
|
0 | capitalone_repos/federated-model-aggregation/connectors/django | capitalone_repos/federated-model-aggregation/connectors/django/fma_django_connectors/__init__.py | from fma_django_connectors.aggregator_connector import DjangoAggConnector
from fma_django_connectors.api_handlers import django_lambda_handler
from fma_django_connectors.metadata_connector import DjangoMetadataConnector
|
0 | capitalone_repos/federated-model-aggregation/connectors/django/fma_django_connectors | capitalone_repos/federated-model-aggregation/connectors/django/fma_django_connectors/tests/test_tasks.py | import datetime
import os
import sys
from unittest import mock
from django.test import TestCase
from django.utils import timezone
from fma_core.workflows.tasks import agg_service
from fma_django import models
from fma_django_connectors import utils
def mock_read_file(self, *args, **kwargs):
if "7" in self.name:
return "[1, 2, 4]"
elif "8" in self.name:
return "[5, 2, 3]"
return ""
def mock_file(self, *args, **kawrgs):
# Turn aggregation results into file
if "7" in self.name:
test_data = utils.create_model_file([1, 2, 4])
return test_data
if "8" in self.name:
test_data = utils.create_model_file([5, 2, 3])
return test_data
@mock.patch("django.db.models.fields.files.FieldFile.read", mock_read_file)
@mock.patch("django.db.models.fields.files.FieldFile.open", mock_file)
class TestAggService(TestCase):
fixtures = [
"TaskQueue_client.json",
"DjangoQ_Schedule.json",
"TaskQueue_User.json",
"TaskQueue_FederatedModel.json",
"TaskQueue_ModelUpdate.json",
"TaskQueue_ModelAggregate.json",
]
@classmethod
def setUpTestData(cls):
cls.fake_datetime = timezone.datetime(
2022, 1, 1, 0, 0, 0, tzinfo=datetime.timezone.utc
)
@mock.patch(
"django.core.files.storage.FileSystemStorage.save", return_value="save_create"
)
def test_no_aggregates(self, mock_save, *mocks):
# federated object setup
model = models.FederatedModel.objects.get(id=3)
model_agg_count = model.aggregates.count()
# Assert no aggregate
self.assertEqual(model_agg_count, 0)
expected_result = 3
with mock.patch(
"django.utils.timezone.now", mock.Mock(return_value=self.fake_datetime)
):
with mock.patch("uuid.uuid4") as mock_uuid:
mock_uuid.return_value = "9aff8e0e-e0c8-4127-88bb-5e479d2d26d2"
actual_result = agg_service(model.id)
self.assertEqual(expected_result, actual_result)
resultant_aggregate = models.ModelAggregate.objects.get(
federated_model_id=actual_result
)
actual_aggregate = {
"id": resultant_aggregate.id,
"federated_model_id": resultant_aggregate.federated_model_id,
"parent_id": resultant_aggregate.parent_id,
"lft": resultant_aggregate.lft,
"rght": resultant_aggregate.rght,
"tree_id": resultant_aggregate.tree_id,
"level": resultant_aggregate.level,
"created_on": resultant_aggregate.created_on,
}
expected_aggregate = {
"id": 3,
"federated_model_id": model.id,
"parent_id": None,
"lft": 1,
"rght": 2,
"tree_id": 2,
"level": 0,
"created_on": self.fake_datetime,
}
# Assert aggregate created correctly
self.assertDictEqual(expected_aggregate, actual_aggregate)
self.assertEqual(
"[3.0, 2.0, 3.5]", mock_save.call_args[0][1].file.read().decode()
)
# Test model_updates for applied aggregate assignment
# Assert aggregate created correctly
self.assertQuerysetEqual(
models.ModelUpdate.objects.filter(id__in=[7, 8]),
model.model_updates.filter(
applied_aggregate=expected_aggregate["id"],
status=models.ModelUpdate.TaskStatus.RUNNING,
),
ordered=False,
)
@mock.patch(
"django.core.files.storage.FileSystemStorage.save", return_value="save_create"
)
def test_existing_aggregates(self, mock_save, *mocks):
# federated object setup
model = models.FederatedModel.objects.get(id=3)
# Turn aggregation results into file
test_data = utils.create_model_file([5, 2, 3])
models.ModelAggregate.objects.create(
federated_model=model, result=test_data, parent=None
)
expected_result = 4
with mock.patch(
"django.utils.timezone.now", mock.Mock(return_value=self.fake_datetime)
):
with mock.patch("uuid.uuid4") as mock_uuid:
mock_uuid.return_value = "9aff8e0e-e0c8-4127-88bb-5e479d2d26d2"
actual_result = agg_service(model.id)
# Assert correct result
self.assertEqual(expected_result, actual_result)
resultant_aggregate = models.ModelAggregate.objects.get(id=4)
actual_aggregate = {
"id": resultant_aggregate.id,
"federated_model_id": resultant_aggregate.federated_model_id,
"parent_id": resultant_aggregate.parent_id,
"lft": resultant_aggregate.lft,
"rght": resultant_aggregate.rght,
"tree_id": resultant_aggregate.tree_id,
"level": resultant_aggregate.level,
"created_on": resultant_aggregate.created_on,
}
expected_aggregate = {
"id": 4,
"federated_model_id": model.id,
"parent_id": 3,
"lft": 2,
"rght": 3,
"tree_id": 2,
"level": 1,
"created_on": self.fake_datetime,
}
# Assert aggregate created correctly
self.assertDictEqual(expected_aggregate, actual_aggregate)
self.assertEqual(
"[3.0, 2.0, 3.5]", mock_save.call_args[0][1].file.read().decode()
)
|
0 | capitalone_repos/federated-model-aggregation/connectors/django/fma_django_connectors | capitalone_repos/federated-model-aggregation/connectors/django/fma_django_connectors/tests/test_api_handlers.py | import importlib
import re
import sys
from unittest import mock
from django.test import TestCase
from fma_core.workflows import api_handler_factory
from fma_django_connectors import api_handlers as fma_django_api_handlers
from fma_django_connectors.tests import fma_settings
class TestDjangoLambdaHandler(TestCase):
def test_no_apig_wsgi_module(self):
module_name = "apig_wsgi"
with mock.patch.dict("sys.modules"):
with mock.patch("importlib.reload"):
del sys.modules[module_name]
from fma_django_connectors import api_handlers
@mock.patch.dict(api_handler_factory._registry, {}, clear=True)
def test_registered(self):
self.assertNotIn("django_lambda_handler", api_handler_factory._registry)
importlib.reload(fma_django_api_handlers)
self.assertIn("django_lambda_handler", api_handler_factory._registry)
def test_django_lambda_handler(self):
self.assertIsNone(fma_django_api_handlers._real_handler)
with mock.patch(
"fma_django_connectors.api_handlers._real_handler"
) as mock_real_handler:
with mock.patch("fma_django_connectors.api_handlers.logger") as mock_logger:
with self.assertRaises(Exception):
mock_real_handler.side_effect = Exception("test")
api_handler_factory.call_api_handler(None, None)
mock_logger.error.assert_called()
event = {
"httpMethod": "GET",
"path": "/v1/",
"headers": {
"host": "localhost",
"Content-Type": "text/html",
"accept": "application/json",
},
}
context = {}
response = api_handler_factory.call_api_handler(event, context)
self.assertIsNotNone(fma_django_api_handlers._real_handler)
self.assertDictEqual(
response,
{
"statusCode": 200,
"headers": {
"Content-Type": "application/json",
"Vary": "Accept, Cookie",
"Allow": "GET, HEAD, OPTIONS",
"X-Frame-Options": "DENY",
"Content-Length": "225",
"X-Content-Type-Options": "nosniff",
"Referrer-Policy": "same-origin",
"Cross-Origin-Opener-Policy": "same-origin",
},
"isBase64Encoded": False,
"body": '{"models":"http://localhost/v1/models/",'
'"model_updates":"http://localhost/v1/model_updates/",'
'"model_aggregates":"http://localhost/v1/model_aggregates/",'
'"client_aggregate_scores":"http://localhost/v1/client_aggregate_scores/"}',
},
)
|
0 | capitalone_repos/federated-model-aggregation/connectors/django/fma_django_connectors | capitalone_repos/federated-model-aggregation/connectors/django/fma_django_connectors/tests/test_update_database.py | import pytest
from django.conf import settings
from django.db import connection
from django.test import TransactionTestCase
from pytest_django import fixtures
from fma_django_connectors.metadata_connector import DjangoMetadataConnector
from fma_django_connectors.tests import fma_settings
@pytest.fixture(scope="session")
def django_db_setup():
settings.DATABASES["default"]["TEST"]["MIGRATE"] = False
settings.DATABASES["default"]["NAME"] = ":memory:"
class TestUpdateDatabase(TransactionTestCase):
def test_update(self):
# resets connection clearing the db for sqlite...
connection.connect()
table_names = connection.introspection.table_names()
assert len(table_names) == 0
# calls function to apply migration
agg_settings = fma_settings.AGGREGATOR_SETTINGS
DjangoMetadataConnector(settings=agg_settings).update_database()
# check to see if migrations applied
table_names = connection.introspection.table_names()
assert len(table_names) > 0
|
0 | capitalone_repos/federated-model-aggregation/connectors/django/fma_django_connectors | capitalone_repos/federated-model-aggregation/connectors/django/fma_django_connectors/tests/fma_settings.py | """Abstract aggregator settings."""
INSTALLED_PACKAGES = ["fma_django_connectors"]
AGGREGATOR_SETTINGS = {
"aggregator_connector_type": "DjangoAggConnector",
"metadata_connector": {
"type": "DjangoMetadataConnector",
},
}
API_SERVICE_SETTINGS = {"handler": "django_lambda_handler"}
|
0 | capitalone_repos/federated-model-aggregation/connectors/django | capitalone_repos/federated-model-aggregation/connectors/django/fma_django/version.py | """File containers the version number for the package."""
MAJOR = 0
MINOR = 0
MICRO = 1
VERSION = "%d.%d.%d" % (MAJOR, MINOR, MICRO)
__version__ = VERSION
|
0 | capitalone_repos/federated-model-aggregation/connectors/django | capitalone_repos/federated-model-aggregation/connectors/django/fma_django/authenticators.py | """Contains authentication classes for the Django FMA connectors."""
import django
from rest_framework import authentication
from rest_framework.exceptions import AuthenticationFailed
from fma_django import models as fma_django_models
class ClientAuthentication(authentication.BaseAuthentication):
"""Handles client authentication for the Django FMA connectors."""
def authenticate(self, request):
"""Ensures that the client's request is coming from a valid UUID.
:param request: Message from the client containing the HTTP_CLIENT_UUID.
:type request: Any
:raises Authentication Failed: the UUID is either invalid or does not exist.
:return: A new ClientUser object with the authenticated UUID.
:rtype: Optional[fma_django.models.ClientUser]
"""
uuid = request.META.get("HTTP_CLIENT_UUID", None)
if not uuid:
return None
try:
client = fma_django_models.Client.objects.get(uuid=uuid)
except fma_django_models.Client.DoesNotExist:
raise AuthenticationFailed("Invalid UUID")
except django.core.exceptions.ValidationError:
raise AuthenticationFailed('"{}" is not a valid UUID.'.format(uuid))
request.client = client
return (fma_django_models.ClientUser(client), None)
|
0 | capitalone_repos/federated-model-aggregation/connectors/django | capitalone_repos/federated-model-aggregation/connectors/django/fma_django/apps.py | """Contains class for managing app configurations."""
from django.apps import AppConfig
class FMADjangoBaseConfig(AppConfig):
"""Sets relevant AppConfig fields for the FMA Django Connector."""
default_auto_field = "django.db.models.BigAutoField"
name = "fma_django"
|
0 | capitalone_repos/federated-model-aggregation/connectors/django | capitalone_repos/federated-model-aggregation/connectors/django/fma_django/admin.py | """Contains classes for managing what is displayed on the admin page."""
from django.contrib import admin
from fma_django import models as fma_django_models
class ClientAdmin(admin.ModelAdmin):
"""Sets the list of Client attributes visible to the Admin."""
pass
class FederatedModelAdmin(admin.ModelAdmin):
"""Sets the list of Federated Model attributes visible to the Admin."""
list_display = ["name", "last_modified"]
class ModelArtifactAdmin(admin.ModelAdmin):
"""Sets the list of Model Artifact attributes visible to the Admin."""
list_display = ["id", "federated_model", "version", "created_on"]
class ModelUpdateAdmin(admin.ModelAdmin):
"""Sets the list of Model Update attributes visible to the Admin."""
list_display = ["id", "status", "created_on"]
class ModelAggregateAdmin(admin.ModelAdmin):
"""Sets the list of Model Aggregate attributes visible to the Admin."""
list_display = ["id", "federated_model", "created_on"]
class ClientAggregateScoreAdmin(admin.ModelAdmin):
"""Sets the list of Client Aggregate score attributes visible to the Admin."""
list_display = ["id", "aggregate", "created_on"]
admin.site.register(fma_django_models.DisplayClient, ClientAdmin)
admin.site.register(fma_django_models.FederatedModel, FederatedModelAdmin)
admin.site.register(fma_django_models.ModelArtifact, ModelArtifactAdmin)
admin.site.register(fma_django_models.ModelUpdate, ModelUpdateAdmin)
admin.site.register(fma_django_models.ModelAggregate, ModelAggregateAdmin)
admin.site.register(
fma_django_models.ClientAggregateScore,
ClientAggregateScoreAdmin,
)
|
0 | capitalone_repos/federated-model-aggregation/connectors/django | capitalone_repos/federated-model-aggregation/connectors/django/fma_django/models.py | """Contains classes and methods for managing Django Models and their schedulers."""
import logging
import uuid
import boto3
from botocore.client import Config
from django.conf import settings
from django.contrib.auth.models import AnonymousUser, User
from django.core import validators
from django.db import models
from django_q.tasks import Schedule, schedule
from mptt.models import MPTTModel, TreeForeignKey
logger = logging.getLogger()
class Client(models.Model):
"""Class for managing a Client's UUID field."""
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
def __str__(self):
"""Returns the stringified UUID."""
return str(self.uuid)
class DisplayClient(Client):
"""Allows the admin panel to show clients under the auth tab."""
class Meta:
app_label = "auth"
proxy = True
verbose_name = "Client"
class ClientUser(AnonymousUser):
"""Class for authenticated Client Users."""
def __init__(self, client):
self.client = client
@property
def is_authenticated(self):
"""Property method for checking authentication.
:return: True
:rtype: bool
"""
return True
class FederatedModel(models.Model):
"""Class for managing the fields for a Federated Model."""
name = models.CharField(max_length=255, blank=False)
developer = models.ForeignKey(
User, null=False, on_delete=models.PROTECT, related_name="models"
)
clients = models.ManyToManyField(
Client, related_name="clients_of_model", blank=True
)
current_artifact = models.OneToOneField(
"ModelArtifact",
related_name="+",
null=True,
blank=True,
on_delete=models.SET_NULL,
)
aggregator = models.CharField(max_length=255, blank=True)
requirement = models.CharField(max_length=255, blank=True)
requirement_args = models.JSONField(null=True, blank=True)
update_schema = models.JSONField(null=True, blank=True)
client_agg_results_schema = models.JSONField(null=True, blank=True)
scheduler = models.OneToOneField(
Schedule, blank=True, null=True, on_delete=models.SET_NULL, editable=False
)
furthest_base_agg = models.PositiveIntegerField(
default=None,
blank=True,
null=True,
validators=[
validators.MinValueValidator(1),
validators.MaxValueValidator(2147483647),
],
)
created_on = models.DateTimeField(editable=False, auto_now_add=True)
last_modified = models.DateTimeField(auto_now=True)
def __init__(self, *args, **kwargs):
self._allow_aggregation = None
super().__init__(*args, **kwargs)
def __str__(self):
"""Returns the name of the FederatedModel."""
return self.name
@property
def allow_aggregation(self):
"""Validates whether the model's aggregation is paused or not.
:return: The status of allow_aggregation flag (True or False).
:rtype: bool
"""
if not self.scheduler:
if self._allow_aggregation is None:
allow_aggregation = get_aws_event_rule_state(self)
if allow_aggregation is None:
return allow_aggregation
return allow_aggregation == "enabled"
return self._allow_aggregation
return self.scheduler.repeats != 0
@allow_aggregation.setter
def allow_aggregation(self, value):
"""Sets the status of allow aggregation.
:param value: A flag passed to turn allow aggregation on or off.
:type value: Any
"""
if value:
self._allow_aggregation = True
return
self._allow_aggregation = False
def create_model_aggregation_schedule_local(sender, instance, created, **kwargs):
"""Create scheduler for every new Federated Model Aggregation.
:param sender: The id of the user requesting to create an aggregation task.
:type sender: Any
:param instance: An instance of a model object with aggregation tasks
:type instance: Any
:param created: A flag indicating if the task was already created.
:type created: Any
:param kwargs: keyword arguments
:type kwargs: Dict, optional
"""
if created and not instance.scheduler:
repeats = -1 if instance.allow_aggregation else 0
instance.scheduler = schedule(
"fma_core.workflows.tasks.agg_service",
instance.id,
schedule_type=Schedule.MINUTES,
minutes=1,
name=str(instance.id)
+ " - "
+ instance.name
+ " - Scheduled Aggregator", # noqa:E131
hook="fma_core.workflows.tasks.post_agg_service_hook",
repeats=repeats,
)
instance.save()
def create_model_aggregation_schedule_remote(sender, instance, created, **kwargs):
"""Create rule for lambda aggregation task for model.
:param sender: The id of the user requesting to create an aggregation task.
:type sender: Any
:param instance: An instance of a model object with an aggregation task.
:type instance: Any
:param created: A flag indicating if the task is already created
:type created: Any
:param kwargs: keyword arguments
:type kwargs: Dict, optional
"""
events_client = boto3.client("events", region_name="us-east-1")
name = f"fma-scheduled-model-{instance.id}-dev"
frequency = "rate(1 minute)"
enablement_state = "ENABLED" if instance.allow_aggregation else "DISABLED"
_ = events_client.put_rule(
Name=name,
ScheduleExpression=frequency,
State=enablement_state,
Tags=[dict(Key=k, Value=v) for k, v in settings.TAGS.items()],
)
input_template_str = (
'{"version": <version>, "id": <id>, '
'"detail-type": <detail-type>, "source": <source>,'
'"account": <account>, "time": <time>, "region": <region>,'
'"resources": [<resources>], "detail": {'
f'"model_id": {instance.id}' + "}}"
)
events_client.put_targets(
Rule=name,
Targets=[
{
"Id": f"model-{instance.id}",
"Arn": settings.AGGREGATOR_LAMBDA_ARN,
"InputTransformer": {
"InputPathsMap": {
"version": "$.version",
"id": "$.id",
"detail-type": "$.detail-type",
"source": "$.source",
"account": "$.account",
"time": "$.time",
"region": "$.region",
"resources": "$.resources[0]",
},
"InputTemplate": input_template_str,
},
}
],
)
def delete_model_aggregation_schedule_local(sender, instance, **kwargs):
"""When a model is deleted, deletes its scheduler.
:param sender: The id of the user requesting to delete an aggregation task.
:type sender: Any
:param instance: An instance of a model object with an aggregation task.
:type instance: Any
:param kwargs: keyword arguments
:type kwargs: Dict, optional
"""
if instance.scheduler:
instance.scheduler.delete()
def delete_model_aggregation_schedule_remote(sender, instance, **kwargs):
"""Create rule for lambda aggregation task for model.
:param sender: The id of the user requesting to delete an aggregation task.
:type sender: Any
:param instance: An instance of a model object with an aggregation task.
:type instance: Any
:param kwargs: keyword arguments
:type kwargs: Dict, optional
"""
events_client = boto3.client("events", region_name="us-east-1")
name = f"fma-scheduled-model-{instance.id}-dev"
_ = events_client.delete_rule(Name=name)
def get_aws_event_rule_state(federated_model):
"""Checks the AWS Event Rule state for a given Federated Model.
:param federated_model: federated model instance
:type federated_model: An instance of a model object with an aggregation task.
:return: state of the rule associated with the aggregation task (disabled|enabled)
:rtype: (None|string)
"""
state = None
try:
config = Config(connect_timeout=5, retries={"max_attempts": 0})
events_client = boto3.client("events", region_name="us-east-1", config=config)
response = events_client.describe_rule(
Name=f"fma-scheduled-model-{federated_model.id}-dev",
)
state = response.get("State", "DISABLED").lower()
except Exception as e:
logger.error(str(e))
return state
def create_model_agg_task(*args, **kwargs):
"""Creates tasks in the model aggregation scheduler.
:param args: arguments
:type args: Dict, optional
:param kwargs: keyword arguments
:type kwargs: Dict, optional
"""
if settings.IS_LOCAL_DEPLOYMENT:
create_model_aggregation_schedule_local(*args, **kwargs)
else:
create_model_aggregation_schedule_remote(*args, **kwargs)
def delete_model_agg_task(*args, **kwargs):
"""Deletes tasks in the model aggregation scheduler.
:param args: arguments
:type args: Dict, optional
:param kwargs: keyword arguments
:type kwargs: Dict, optional
"""
if settings.IS_LOCAL_DEPLOYMENT:
delete_model_aggregation_schedule_local(*args, **kwargs)
else:
delete_model_aggregation_schedule_remote(*args, **kwargs)
models.signals.post_save.connect(
create_model_agg_task,
sender=FederatedModel,
weak=False,
dispatch_uid="fma_django.models.create_model_agg_task",
)
models.signals.post_delete.connect(
delete_model_agg_task,
sender=FederatedModel,
weak=False,
dispatch_uid="fma_django.models.delete_model_agg_task",
)
class ModelArtifact(models.Model):
"""Class for managing the fields of a Model Artifact."""
values = models.FileField(blank=False, upload_to="model_artifacts")
federated_model = models.ForeignKey(
FederatedModel, null=False, on_delete=models.CASCADE, related_name="artifacts"
)
version = models.CharField(max_length=255, blank=False)
created_on = models.DateTimeField(editable=False, auto_now_add=True)
class Meta:
"""Model attributes enforcing database constraints."""
constraints = [
models.UniqueConstraint(
fields=["federated_model", "version"], name="unique version to model"
),
]
class ModelAggregate(MPTTModel):
"""Class for managing the fields of a Model Aggregate."""
federated_model = models.ForeignKey(
FederatedModel, null=False, on_delete=models.CASCADE, related_name="aggregates"
)
parent = TreeForeignKey(
"self", on_delete=models.CASCADE, null=True, blank=True, related_name="children"
)
result = models.FileField(blank=False, upload_to="model_aggregates")
validation_score = models.FloatField(null=True)
created_on = models.DateTimeField(editable=False, auto_now_add=True)
class ModelUpdate(models.Model):
"""Class for managing the fields of a Model Update."""
class TaskStatus(models.IntegerChoices):
PENDING = 0
RUNNING = 1
COMPLETE = 2
FAILED = 3
INVALID = 4
client = models.ForeignKey(
Client, null=False, on_delete=models.CASCADE, related_name="model_updates"
)
federated_model = models.ForeignKey(
FederatedModel,
null=False,
on_delete=models.CASCADE,
related_name="model_updates",
)
data = models.FileField(blank=False, upload_to="model_updates")
status = models.IntegerField(choices=TaskStatus.choices, default=0)
base_aggregate = models.ForeignKey(
ModelAggregate,
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name="updates_using_this",
)
applied_aggregate = models.ForeignKey(
ModelAggregate,
null=True,
blank=True,
on_delete=models.CASCADE,
related_name="updates_used_to_agg",
)
created_on = models.DateTimeField(editable=False, auto_now_add=True)
class ClientAggregateScore(models.Model):
"""Class for managing the fields of a Client Aggregate Score."""
aggregate = models.ForeignKey(
ModelAggregate,
null=True,
blank=True,
on_delete=models.CASCADE,
related_name="client_scores",
)
client = models.ForeignKey(
Client,
null=False,
on_delete=models.CASCADE,
related_name="aggregate_scores",
)
validation_results = models.JSONField()
created_on = models.DateTimeField(editable=False, auto_now_add=True)
class Meta:
"""Model attributes enforcing database constraints."""
unique_together = (
"aggregate",
"client",
)
|
0 | capitalone_repos/federated-model-aggregation/connectors/django/fma_django | capitalone_repos/federated-model-aggregation/connectors/django/fma_django/migrations/0001_initial.py | # Generated by Django 4.1.3 on 2023-01-25 19:42
from django.conf import settings
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
import mptt.fields
import uuid
class Migration(migrations.Migration):
initial = True
dependencies = [
('django_q', '0014_schedule_cluster'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Client',
fields=[
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
],
),
migrations.CreateModel(
name='FederatedModel',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255)),
('aggregator', models.CharField(blank=True, max_length=255)),
('requirement', models.CharField(blank=True, max_length=255)),
('requirement_args', models.JSONField(blank=True, null=True)),
('update_schema', models.JSONField(blank=True, null=True)),
('client_agg_results_schema', models.JSONField(blank=True, null=True)),
('furthest_base_agg', models.PositiveIntegerField(blank=True, default=None, null=True, validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(2147483647)])),
('created_on', models.DateTimeField(auto_now_add=True)),
('last_modified', models.DateTimeField(auto_now=True)),
('clients', models.ManyToManyField(blank=True, related_name='clients_of_model', to='fma_django.client')),
],
),
migrations.CreateModel(
name='ModelAggregate',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('result', models.FileField(upload_to='model_aggregates')),
('validation_score', models.FloatField(null=True)),
('created_on', models.DateTimeField(auto_now_add=True)),
('lft', models.PositiveIntegerField(editable=False)),
('rght', models.PositiveIntegerField(editable=False)),
('tree_id', models.PositiveIntegerField(db_index=True, editable=False)),
('level', models.PositiveIntegerField(editable=False)),
('federated_model', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='aggregates', to='fma_django.federatedmodel')),
('parent', mptt.fields.TreeForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='children', to='fma_django.modelaggregate')),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='ModelUpdate',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('data', models.FileField(upload_to='model_updates')),
('status', models.IntegerField(choices=[(0, 'Pending'), (1, 'Running'), (2, 'Complete'), (3, 'Failed'), (4, 'Invalid')], default=0)),
('created_on', models.DateTimeField(auto_now_add=True)),
('applied_aggregate', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='updates_used_to_agg', to='fma_django.modelaggregate')),
('base_aggregate', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='updates_using_this', to='fma_django.modelaggregate')),
('client', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='model_updates', to='fma_django.client')),
('federated_model', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='model_updates', to='fma_django.federatedmodel')),
],
),
migrations.CreateModel(
name='ModelArtifact',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('values', models.FileField(upload_to='model_artifacts')),
('version', models.CharField(max_length=255)),
('created_on', models.DateTimeField(auto_now_add=True)),
('federated_model', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='artifacts', to='fma_django.federatedmodel')),
],
),
migrations.AddField(
model_name='federatedmodel',
name='current_artifact',
field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='fma_django.modelartifact'),
),
migrations.AddField(
model_name='federatedmodel',
name='developer',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='models', to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='federatedmodel',
name='scheduler',
field=models.OneToOneField(blank=True, editable=False, null=True, on_delete=django.db.models.deletion.SET_NULL, to='django_q.schedule'),
),
migrations.CreateModel(
name='ClientAggregateScore',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('validation_results', models.JSONField()),
('created_on', models.DateTimeField(auto_now_add=True)),
('aggregate', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='client_scores', to='fma_django.modelaggregate')),
('client', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='aggregate_scores', to='fma_django.client')),
],
),
migrations.AddConstraint(
model_name='modelartifact',
constraint=models.UniqueConstraint(fields=('federated_model', 'version'), name='unique version to model'),
),
migrations.AlterUniqueTogether(
name='clientaggregatescore',
unique_together={('aggregate', 'client')},
),
]
|
0 | capitalone_repos/federated-model-aggregation/connectors/django | capitalone_repos/federated-model-aggregation/connectors/django/fma_django_api/apps.py | """Contains class for configuring the Task Queue API."""
from django.apps import AppConfig
class TaskQueueApiConfig(AppConfig):
"""Sets the default_auto_field and name of the api service."""
default_auto_field = "django.db.models.BigAutoField"
name = "fma_django_api"
|
0 | capitalone_repos/federated-model-aggregation/connectors/django | capitalone_repos/federated-model-aggregation/connectors/django/fma_django_api/utils.py | """Contains utility functions for handling data sent to the FMA Django API."""
import json
import uuid
from io import BytesIO
from django.core.files.uploadedfile import UploadedFile
def create_model_file(data):
"""Create a django json file object of the model weights data.
:param data: Model weights data
:type data: Any
:return: a json object of the model weights and metadata expected by the API service
:rtype: django.core.files.uploadedfile.UploadedFile
"""
data_io = BytesIO(json.dumps(data).encode("utf-8"))
data = UploadedFile(data_io)
data.name = str(uuid.uuid4())
data.size = data_io.getbuffer().nbytes
return data
|
0 | capitalone_repos/federated-model-aggregation/connectors/django | capitalone_repos/federated-model-aggregation/connectors/django/fma_django_api/urls.py | """Contains the set of url patterns for accessing the FMA Django API."""
from django.urls import include, re_path
urlpatterns = [
re_path(r"^v1/", include("fma_django_api.v1.urls")),
]
|
0 | capitalone_repos/federated-model-aggregation/connectors/django/fma_django_api | capitalone_repos/federated-model-aggregation/connectors/django/fma_django_api/v1/fields.py | """Contains helper classes for serializing data into JSON format for file storage."""
import json
from rest_framework import serializers
from fma_django_api import utils
class JsonToInternalFileField(serializers.FileField):
"""Serializes model weights data into JSON."""
def to_internal_value(self, data):
"""Converts data to a serialized set.
:param data: the model weights
:type data: Union[List, numpy.ndarray]
:return: a set containing the serialized data
:rtype: Set
"""
data = utils.create_model_file(data)
return super().to_internal_value(data)
class JsonFileField(serializers.FileField):
"""Reads a JSON file as a dictionary."""
def to_representation(self, value):
"""Reads a JSON file as a dictionary.
:param value: a file containing data about the model
:type value: Any
:return: a dictionary object containing the contents of the given file
:rtype: Optional[Dict]
"""
if value is None:
return None
with value.open("r") as f:
return json.load(f)
|
0 | capitalone_repos/federated-model-aggregation/connectors/django/fma_django_api | capitalone_repos/federated-model-aggregation/connectors/django/fma_django_api/v1/paginators.py | """Contains the Paginator classes for the FMA Django API."""
from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response
class BaseResultsSetPagination(PageNumberPagination):
"""The Base Paginator used by other Pagination classes."""
def get_paginated_response(self, data):
"""Override the pagination response."""
return Response(data)
class LargeResultsSetPagination(BaseResultsSetPagination):
"""The Paginator used for large result sets."""
page_size = 100
page_size_query_param = "page_size"
max_page_size = 200
class StandardResultsSetPagination(BaseResultsSetPagination):
"""The Paginator used for small result sets."""
page_size = 10
page_size_query_param = "page_size"
max_page_size = 20
|
0 | capitalone_repos/federated-model-aggregation/connectors/django/fma_django_api | capitalone_repos/federated-model-aggregation/connectors/django/fma_django_api/v1/filters.py | """Contains a Class for adding filters to the Django QuerySet."""
import django_filters
from fma_django import models as fma_django_models
class FederatedModelFilter(django_filters.FilterSet):
"""Django-filter specifically designed to make allow_aggregation searchable."""
allow_aggregation = django_filters.BooleanFilter(
label="allow_aggregation", method="filter_allow_aggregation"
)
def filter_allow_aggregation(self, queryset, name, value):
"""Construct the full lookup expression.
:param queryset: a Django QuerySet class object
:type queryset: Class
:param name: Additional flag, yet to be implemented
:type name: Any
:param value: A flag to determine whether or not to include the queryset
:type value: Any
:return: a Django QuerySet class object
:rtype: django.db.models.QuerySet
"""
if value:
return queryset.exclude(scheduler__repeats=0)
return queryset.filter(scheduler__repeats=0)
class Meta:
model = fma_django_models.FederatedModel
fields = ["allow_aggregation"]
|
0 | capitalone_repos/federated-model-aggregation/connectors/django/fma_django_api | capitalone_repos/federated-model-aggregation/connectors/django/fma_django_api/v1/serializers.py | """Contains the main Serializers for the FMA Django API."""
import json
from inspect import getmembers, isfunction
from operator import itemgetter
import jsonschema
from rest_framework import serializers
from fma_django import models
from fma_django_api import utils
try:
from fma_core.algorithms.aggregators import common as agg_common
from fma_core.algorithms.requirements import common as req_common
except ModuleNotFoundError:
req_common = None
agg_common = None
from . import fields
class ClientSerializer(serializers.ModelSerializer):
"""The serializer for clients associated with a model."""
class Meta:
model = models.Client
fields = "__all__"
class ModelArtifactSerializer(serializers.ModelSerializer):
"""The serializer for Model Artifacts."""
class Meta:
model = models.ModelArtifact
fields = "__all__"
read_only_fields = ["federated_model"]
class FederatedModelSerializer(serializers.ModelSerializer):
"""The serializer for federated models."""
allow_aggregation = serializers.BooleanField(default=False, allow_null=True)
aggregator = serializers.ChoiceField(
choices=list(map(itemgetter(0), getmembers(agg_common, isfunction)))
)
requirement = serializers.ChoiceField(
choices=list(map(itemgetter(0), getmembers(req_common, isfunction))),
allow_blank=True,
required=False,
)
class Meta:
model = models.FederatedModel
read_only_fields = ["current_artifact"]
exclude = ("scheduler",)
extra_fields = "allow_aggregation"
def update(self, instance, validated_data):
"""Overloads update to use the allow_aggregation field.
:param instance: the federated model which is being updated
:type instance: fma_django.models.FederatedModel
:param validated_data: metadata where allow_aggregation status is found
:type validated_data: dict
:return: updated federated model
:rtype: fma_django.models.FederatedModel
"""
allow_aggregation = validated_data.pop("allow_aggregation", None)
if allow_aggregation is not None and instance.scheduler:
instance.scheduler.repeats = -1 if allow_aggregation else 0
instance.scheduler.save()
elif not instance.scheduler:
instance.allow_aggregation = allow_aggregation
super().update(instance, validated_data)
return instance
class CreateFederatedModelSerializer(FederatedModelSerializer):
"""The serializer for creating a federated model."""
allow_aggregation = serializers.BooleanField(default=False)
initial_model = serializers.JSONField(
allow_null=True, write_only=True, required=False
)
class Meta(FederatedModelSerializer.Meta):
pass
def create(self, validated_data):
"""Creates a federated model object from validated model data.
:param validated_data: A validated federated model object
:type validated_data: Any
:return: A new or updated federated model
:rtype: serializers.FederatedModelSerializer
"""
initial_model = validated_data.pop("initial_model", None)
federated_model = super().create(validated_data)
# create model artifact
if initial_model is not None:
initial_model = utils.create_model_file(initial_model)
model_artifact = models.ModelArtifact.objects.create(
federated_model=federated_model, values=initial_model, version="1.0.0"
)
federated_model.current_artifact = model_artifact
federated_model.save(update_fields=["current_artifact"])
self.validated_data["current_artifact"] = model_artifact.id
return federated_model
class ModelUpdateSerializer(serializers.ModelSerializer):
"""The serializer for model updates."""
data = fields.JsonToInternalFileField()
class Meta:
model = models.ModelUpdate
exclude = []
read_only_fields = ["status"]
def validate(self, data):
"""Validates that the data matches the required schema.
:param data: The model update object that the client is pushing
:type data: Any
:raises ValidationError: Data does not match the required schema
:return: The validated data object
:rtype: Any
"""
data = super().validate(data)
update_schema = data["federated_model"].update_schema
if update_schema:
validator = jsonschema.validators._LATEST_VERSION(update_schema)
if not validator.is_valid(json.loads(data["data"].read())):
raise serializers.ValidationError(
{
"data": "data did not match the required schema: {}".format(
update_schema
)
}
)
return data
class ClientModelUpdateSerializer(ModelUpdateSerializer):
"""The serializer for model updates received from clients."""
class Meta(ModelUpdateSerializer.Meta):
exclude = ["applied_aggregate", "status"]
read_only_fields = ModelUpdateSerializer.Meta.read_only_fields + ["client"]
class ModelAggregateSerializer(serializers.ModelSerializer):
"""The serializer for model aggregates."""
class Meta:
model = models.ModelAggregate
fields = "__all__"
class ModelAggregateRetrieveJSONSerializer(serializers.ModelSerializer):
"""The serializer for model aggregates in JSON format."""
result = fields.JsonFileField()
class Meta:
model = models.ModelAggregate
fields = "__all__"
class PublishModelSerializer(serializers.Serializer):
"""The serializer for published model artifacts."""
version = serializers.CharField(max_length=255)
class PushValidationScore(serializers.Serializer):
"""The serializer for pushing validation scores."""
f1_score = serializers.FloatField(min_value=0, max_value=1)
class ClientAggregateScoreSerializer(serializers.ModelSerializer):
"""The serializer for client aggregate validation scores."""
class Meta:
model = models.ClientAggregateScore
fields = "__all__"
def validate(self, results):
"""Validates that the results matches the required schema.
:param results: The scores output from some evaluation metric
:type results: Any
:raises ValidationError: Data does not match the required schema
:return: The validated results object
:rtype: Any
"""
results = super().validate(results)
aggregate = results["aggregate"]
client_agg_results_schema = aggregate.federated_model.client_agg_results_schema
if client_agg_results_schema:
validator = jsonschema.validators._LATEST_VERSION(client_agg_results_schema)
if not validator.is_valid(results["validation_results"]):
raise serializers.ValidationError(
{
"results": "results did not "
"match the required schema: {}".format(
client_agg_results_schema
)
}
)
return results
|
0 | capitalone_repos/federated-model-aggregation/connectors/django/fma_django_api | capitalone_repos/federated-model-aggregation/connectors/django/fma_django_api/v1/urls.py | """Registers the FMA Django API endpoints with the Service url."""
from django.urls import include, path
from rest_framework import routers
from . import views
router = routers.DefaultRouter()
router.register(r"models", views.FederatedModelViewSet, basename="model")
router.register(r"model_updates", views.ModelUpdateViewSet, basename="model_update")
router.register(
r"model_aggregates", views.ModelAggregateViewSet, basename="model_aggregate"
)
router.register(
r"client_aggregate_scores",
views.ClientAggregateScoreViewSet,
basename="client_aggregate_scores",
)
urlpatterns = [
path("", include(router.urls)),
]
|
0 | capitalone_repos/federated-model-aggregation/connectors/django/fma_django_api | capitalone_repos/federated-model-aggregation/connectors/django/fma_django_api/v1/views.py | """Contains all the viewsets for the FMA Django API service."""
import json
from rest_framework import decorators, permissions, status, viewsets
from rest_framework.exceptions import NotFound
from rest_framework.response import Response
from fma_django import authenticators as fma_django_authenticators
from fma_django import models as fma_django_models
from fma_django_api.v1 import filters as api_filters
from fma_django_api.v1 import paginators
from fma_django_api.v1 import permissions as api_permissions
from fma_django_api.v1 import serializers
def error404(request):
"""Creates custom 404 error for django page not found.
:param request: Message requesting access to a page in FMA
:type request: Any
:raises: NotFound
"""
raise NotFound(detail="Error 404, page not found", code=404)
class FederatedModelViewSet(viewsets.ModelViewSet):
"""The viewset for federated models."""
serializer_class = serializers.FederatedModelSerializer
pagination_class = paginators.LargeResultsSetPagination
queryset = fma_django_models.FederatedModel.objects.all()
permission_classes = [api_permissions.IsActive]
ordering_fields = ("created_on",)
ordering = ("-created_on",)
filterset_class = api_filters.FederatedModelFilter
def get_serializer_class(self):
"""
Gets the FederatedModel serializer class based on the action requested.
:return: serializer class for a Federated Model
"""
if self.action == "create":
return serializers.CreateFederatedModelSerializer
return self.serializer_class
def get_queryset(self):
"""Gets FederatedModel query_set based on REST requested user parameters.
:return: FederatedModel queryset
:rtype: django.db.models.query.QuerySet
"""
if self.request.user.is_staff or self.action == "register_client":
return self.queryset
elif self.action in [
"get_latest_aggregate",
"get_current_artifact",
"get_latest_model",
] and hasattr(self.request, "client"):
return self.queryset
return self.queryset.filter(developer=self.request.user)
@decorators.action(
methods=["post"],
detail=True,
permission_classes=[permissions.AllowAny],
authentication_classes=[fma_django_authenticators.ClientAuthentication],
serializer_class=serializers.ClientSerializer,
)
def register_client(self, request, *args, **kwargs):
"""Allows client to register to a model to perform client specific actions.
:param request: Message from client to be added to the client list
:type request: Any
:param args: arguments
:type args: Dict, optional
:param kwargs: keyword arguments
:type kwargs: Dict, optional
:return: Serialized data about the registered client
:rtype: Response
"""
model = self.get_object()
client = None
if hasattr(request, "client"):
client = request.client
elif isinstance(request.user, fma_django_models.AnonymousUser):
client = fma_django_models.Client.objects.create()
if client:
model.clients.add(client)
model.save()
serializer = self.get_serializer(client)
return Response(serializer.data)
@decorators.action(
methods=["get"],
detail=True,
permission_classes=[
api_permissions.IsClientDeveloperAdmin, # noqa:E126
api_permissions.RegisteredClientOnlyPermission,
],
serializer_class=serializers.ClientSerializer,
)
def get_latest_aggregate(self, request, *args, **kwargs):
"""Sorts and returns the most recent aggregate to the requester.
:param request: Message from client asking for latest aggregate
:type request: Any
:param args: arguments
:type args: Dict, optional
:param kwargs: keyword arguments
:type kwargs: Dict, optional
:return: Serialized data about the latest aggregate
:rtype: Response
"""
model = self.get_object()
latest_agg = model.aggregates.order_by("-created_on").first()
if not latest_agg:
return Response({})
serializer_class = serializers.ModelAggregateSerializer
serializer = serializer_class(latest_agg)
return Response(serializer.data)
@decorators.action(
methods=["get"],
detail=True,
permission_classes=[
api_permissions.IsClientDeveloperAdmin, # noqa:E126
api_permissions.RegisteredClientOnlyPermission,
],
)
def get_current_artifact(self, request, *args, **kwargs):
"""Returns the current artifact of the model to the requester.
:param request: Message from client asking for the current artifact
:type request: Any
:param args: arguments
:type args: Dict, optional
:param kwargs: Keyword arguments
:type kwargs: Dict, optional
:return: Serialized data about the current artifact
:rtype: Response
"""
model = self.get_object()
if not model.current_artifact:
return Response({})
serializer_class = serializers.ModelArtifactSerializer
serializer = serializer_class(model.current_artifact)
return Response(serializer.data)
@decorators.action(
methods=["get"],
detail=True,
permission_classes=[
api_permissions.IsClientDeveloperAdmin, # noqa:E126
api_permissions.RegisteredClientOnlyPermission,
],
)
def get_latest_model(self, request, *args, **kwargs):
"""Returns the latest aggregate of model.
Returns the latest aggregate of the model else if no aggregate exists
the current artifact of the model to the requester.
:param request: Message from client asking for the lastest model
:type request: Any
:param args: Arguments
:type args: Dict, optional
:param kwargs: Keyword arguments
:type kwargs: Dict, optional
:return: Serialized data about the latest model
:rtype: Response
"""
model = self.get_object()
latest_agg = model.aggregates.order_by("-created_on").first()
if not latest_agg:
if not model.current_artifact:
return Response({})
with model.current_artifact.values.open("r") as f:
return Response({"values": json.load(f), "aggregate": None})
with latest_agg.result.open("r") as f:
return Response({"values": json.load(f), "aggregate": latest_agg.id})
class ModelUpdateViewSet(viewsets.ModelViewSet):
"""The viewset for model updates."""
pagination_class = paginators.StandardResultsSetPagination
queryset = fma_django_models.ModelUpdate.objects.all()
permission_classes = [
api_permissions.IsClientDeveloperAdmin,
api_permissions.ClientCreateGetViewPermission,
]
filterset_fields = (
"federated_model",
"status",
)
ordering_fields = ("created_on",)
ordering = ("-created_on",)
def get_serializer_class(self):
"""Returns the ModelUpdate serializer.
Returns the ModelUpdate serializer class depending on if the user is
a client or platform user.
:return: serializer class for a Federated Model
:rtype: fma_django_api.v1.serializer.ModelSerializer
"""
if hasattr(self.request, "client"):
return serializers.ClientModelUpdateSerializer
return serializers.ModelUpdateSerializer
def get_queryset(self):
"""Gets ModelUpdate query_set.
Gets the ModelUpdate query_set based on the REST requested user
parameters.
:return: ModelUpdate queryset
:rtype: django.db.models.query.QuerySet
"""
if self.request.user.is_staff:
return self.queryset
elif hasattr(self.request, "client"):
return self.queryset.filter(client=self.request.client)
return self.queryset.filter(federated_model__developer=self.request.user)
def perform_create(self, serializer):
"""Saves the current state of the given serializer."""
if hasattr(self.request, "client"):
serializer.save(client=self.request.client)
return
serializer.save()
class ModelAggregateViewSet(viewsets.ModelViewSet):
"""The viewset for model aggregates."""
serializer_class = serializers.ModelAggregateSerializer
pagination_class = paginators.StandardResultsSetPagination
queryset = fma_django_models.ModelAggregate.objects.all()
permission_classes = [
api_permissions.IsClientDeveloperAdmin,
api_permissions.ClientViewOnlyPermission,
]
filterset_fields = ("federated_model",)
ordering_fields = (
"created_on",
"validation_score",
)
ordering = ("-created_on",)
def get_queryset(self):
"""Get the ModelAggregate queryset.
Gets the ModelAggregate queryset based on the REST requested user
parameters.
:return: ModelAggregate queryset
"""
if self.request.user.is_staff:
return self.queryset
elif hasattr(self.request, "client"):
return self.queryset.filter(
federated_model__in=self.request.client.clients_of_model.all()
)
return self.queryset.filter(federated_model__developer=self.request.user)
def retrieve(self, request, *args, **kwargs):
"""Returns a Response containing serialized data about the given aggregate.
:param request: Message from client asking for the current instance of the
ModelAggregateViewSet
:type request: Any
:param args: Arguments
:type args: Dict, optional
:param kwargs: Keyword argumets
:type kwargs: Dict, optional
:return: Serialized data about the model aggregate
:rtype: Response
"""
instance = self.get_object()
serializer = serializers.ModelAggregateRetrieveJSONSerializer(instance)
return Response(serializer.data)
@decorators.action(
methods=["post"],
detail=True,
serializer_class=serializers.PublishModelSerializer,
permission_classes=[api_permissions.IsActive],
) # noqa:E126
def publish_aggregate(self, request, *args, **kwargs):
"""Publish aggregate from passed in ID.
:param request: A message containing data about a model aggregate
:type request: Any
:param args: Arguments
:type args: Dict, optional
:param kwargs: Keyword arguments
:type kwargs: Dict, optional
:return: Serialized data about the published aggregate (artifact)
:rtype: Response
"""
model = self.get_object()
serializer = self.get_serializer(data=request.data)
serializer.is_valid()
# TODO find a way to initialize artifact without loading data into memory
with model.result.open("r") as f:
model.federated_model.current_artifact = (
fma_django_models.ModelArtifact.objects.create(
federated_model=model.federated_model,
values=f,
version=serializer.validated_data["version"],
)
)
model.federated_model.save(update_fields=["current_artifact"])
serializer_class = serializers.ModelArtifactSerializer
serializer = serializer_class(model.federated_model.current_artifact)
return Response(serializer.data, status=status.HTTP_201_CREATED)
class ClientAggregateScoreViewSet(viewsets.ModelViewSet):
"""The viewset for client aggregate scores."""
queryset = fma_django_models.ClientAggregateScore.objects.all()
pagination_class = paginators.StandardResultsSetPagination
serializer_class = serializers.ClientAggregateScoreSerializer
permission_classes = [
api_permissions.IsClientDeveloperAdmin,
api_permissions.ClientCreateGetViewPermission,
]
filterset_fields = ("aggregate", "client")
ordering_fields = ("created_on",)
ordering = ("-created_on",)
def get_queryset(self):
"""Gets the ClientAggregateScore query_set.
Gets the ClientAggregateScore query_set based on the REST
requested user parameters.
:return: ClientAggregateScore queryset
"""
if self.request.user.is_staff:
return self.queryset
elif hasattr(self.request, "client"):
return self.queryset.filter(client=self.request.client)
return self.queryset.filter(
aggregate__federated_model__developer=self.request.user
)
def perform_create(self, serializer):
"""Saves the current state of the given serializer."""
if hasattr(self.request, "client"):
serializer.save(client=self.request.client)
return
serializer.save()
|
0 | capitalone_repos/federated-model-aggregation/connectors/django/fma_django_api | capitalone_repos/federated-model-aggregation/connectors/django/fma_django_api/v1/permissions.py | """Contains classes that manage user permissions."""
from rest_framework import permissions
from fma_django import models as fma_django_models
class IsActive(permissions.BasePermission):
"""Global permission for non client, active users for rest framework API."""
def has_permission(self, request, view):
"""Checks whether or not the user's request has permission.
:param request: The message recieved from the user
:type request: Any
:param view: The viewset that the user is attempting to access
:type view: viewsets.ModelViewSet
:return: A boolean to indicate if the user has permission
:rtype: bool
"""
if isinstance(request.user, fma_django_models.User):
return request.user.is_active
return False
class IsClientDeveloperAdmin(permissions.BasePermission):
"""Global permission for client, active users for rest framework API."""
def has_permission(self, request, view):
"""Checks whether or not the user has permission.
:param request: The message recieved from the user
:type request: Any
:param view: The viewset that the user is attempting to access
:type view: viewsets.ModelViewSet
:return: A boolean to indicate if the user has permission
:rtype: bool
"""
if (
hasattr(request, "client")
or request.user.is_active
or request.user.is_staff
):
return True
return False
class ClientCreateGetViewPermission(permissions.BasePermission):
"""Global permission for a client to interact with the experiments within FMA."""
def has_permission(self, request, view):
"""Checks whether or not the user has permission.
:param request: The message recieved from the user
:type request: Any
:param view: The viewset that the user is attempting to access
:type view: viewsets.ModelViewSet
:return: A boolean to indicate if the user has permission
:rtype: bool
"""
if hasattr(request, "client") and view.action not in [
"list",
"retrieve",
"create",
]:
return False
return True
class ClientViewOnlyPermission(permissions.BasePermission):
"""Global permission for a client to view experiment data within FMA."""
def has_permission(self, request, view):
"""Checks whether or not the user has permission.
:param request: The message recieved from the user
:type request: Any
:param view: The viewset that the user is attempting to access
:type view: viewsets.ModelViewSet
:return: A boolean to indicate if the user has permission
:rtype: bool
"""
if hasattr(request, "client") and view.action not in ["list", "retrieve"]:
return False
return True
class RegisteredClientOnlyPermission(permissions.BasePermission):
"""Global permission for a registered client to have access."""
def has_object_permission(self, request, view, obj):
"""Checks whether or not the user has permission.
:param request: The message recieved from the user
:type request: Any
:param view: The viewset that the user is attempting to access
:type view: viewsets.ModelViewSet
:param obj: The federated model object the user is registered with
:type obj: viewsets.ModelViewSet
:return: A boolean to indicate if the user has permission
:rtype: bool
"""
if hasattr(request, "client") and request.client not in obj.clients.all():
return False
return True
|
0 | capitalone_repos/federated-model-aggregation/connectors/django/fma_django_api/v1 | capitalone_repos/federated-model-aggregation/connectors/django/fma_django_api/v1/tests/test_model_update_viewset.py | from unittest import mock
from django.urls import reverse
from rest_framework.authtoken import models as auth_models
from rest_framework.response import Response
from rest_framework.test import APITestCase
from fma_django import models
from .utils import ClientMixin, LoginMixin
@mock.patch(
"django.core.files.storage.FileSystemStorage.save", return_value="save_create"
)
class TestModelUpdateViewSet(ClientMixin, LoginMixin, APITestCase):
reverse_url = "model_update-list"
fixtures = [
"TaskQueue_User.json",
"TaskQueue_client.json",
"DjangoQ_Schedule.json",
"TaskQueue_FederatedModel.json",
"TaskQueue_ModelAggregate.json",
"TaskQueue_ModelUpdate.json",
]
def setUp(self):
for user in models.User.objects.all():
auth_models.Token.objects.get_or_create(user=user)
def _validate_unauthorized(self, baseurl, client_action, request_json=None):
if request_json is None:
request_json = {}
# validate unauthorized, no one logged in
response = client_action(baseurl, format="json")
self.assertEqual(401, response.status_code)
self.assertDictEqual(
{"detail": "Authentication credentials were not provided."}, response.json()
)
# validate invalid uuid client can't access
response = client_action(
baseurl, format="json", HTTP_CLIENT_UUID="not-a-client"
)
self.assertEqual(401, response.status_code)
self.assertDictEqual(
{"detail": '"not-a-client" is not a valid UUID.'}, response.json()
)
# validate non-existent client can't access
response = client_action(
baseurl,
format="json",
HTTP_CLIENT_UUID="aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
)
self.assertEqual(401, response.status_code)
self.assertDictEqual({"detail": "Invalid UUID"}, response.json())
def test_list(self, *mocks):
baseurl = reverse(self.reverse_url)
self._validate_unauthorized(baseurl, client_action=self.client.get)
# validate authorized response given fixtures
self.login_user(user_json={"username": "admin"})
response = self.client.get(baseurl, format="json")
expected_response = [
{
"id": 1,
"client": "cbb6025f-c15c-4e90-b3fb-85626f7a79f1",
"federated_model": 1,
"data": "http://testserver/mediafiles/fake/path/model_updates/1",
"status": 2,
"created_on": "2022-12-15T23:08:28.720000Z",
"base_aggregate": None,
"applied_aggregate": None,
},
{
"id": 2,
"client": "cbb6025f-c15c-4e90-b3fb-85626f7a79f1",
"federated_model": 1,
"data": "http://testserver/mediafiles/fake/path/model_updates/2",
"status": 2,
"created_on": "2023-01-10T23:10:33.720000Z",
"base_aggregate": None,
"applied_aggregate": None,
},
{
"id": 3,
"client": "531580e6-ce6c-4f01-a5aa-9ed7af5ee768",
"federated_model": 1,
"data": "http://testserver/mediafiles/fake/path/model_updates/3",
"status": 2,
"created_on": "2023-01-16T23:17:35.480000Z",
"base_aggregate": None,
"applied_aggregate": None,
},
{
"id": 4,
"client": "531580e6-ce6c-4f01-a5aa-9ed7af5ee768",
"federated_model": 1,
"data": "http://testserver/mediafiles/fake/path/model_updates/4",
"status": 3,
"created_on": "2022-02-17T17:58:13.819000Z",
"base_aggregate": None,
"applied_aggregate": None,
},
{
"id": 5,
"client": "cbb6025f-c15c-4e90-b3fb-85626f7a79f1",
"federated_model": 2,
"data": "http://testserver/mediafiles/fake/path/model_updates/5",
"status": 0,
"created_on": "2022-02-17T17:58:44.441000Z",
"base_aggregate": None,
"applied_aggregate": None,
},
{
"id": 6,
"client": "ab359e5d-6991-4088-8815-a85d3e413c02",
"federated_model": 2,
"data": "http://testserver/mediafiles/fake/path/model_updates/6",
"status": 0,
"created_on": "2022-02-28T00:36:54.803000Z",
"base_aggregate": 2,
"applied_aggregate": None,
},
{
"id": 7,
"client": "cbb6025f-c15c-4e90-b3fb-85626f7a79f1",
"federated_model": 3,
"data": "http://testserver/mediafiles/fake/path/model_updates/7",
"status": 0,
"created_on": "2022-12-26T01:12:55.467000Z",
"base_aggregate": None,
"applied_aggregate": None,
},
{
"id": 8,
"client": "cbb6025f-c15c-4e90-b3fb-85626f7a79f1",
"federated_model": 3,
"data": "http://testserver/mediafiles/fake/path/model_updates/8",
"status": 0,
"created_on": "2022-12-08T13:22:24.557000Z",
"base_aggregate": None,
"applied_aggregate": None,
},
]
self.assertEqual(200, response.status_code)
self.assertCountEqual(expected_response, response.json())
self.logout_user()
# validate developer only sees their own
self.login_user(user_json={"username": "non_admin"})
response = self.client.get(baseurl, format="json")
expected_response = [
{
"id": 5,
"client": "cbb6025f-c15c-4e90-b3fb-85626f7a79f1",
"federated_model": 2,
"data": "http://testserver/mediafiles/fake/path/model_updates/5",
"status": 0,
"created_on": "2022-02-17T17:58:44.441000Z",
"base_aggregate": None,
"applied_aggregate": None,
},
{
"id": 6,
"client": "ab359e5d-6991-4088-8815-a85d3e413c02",
"federated_model": 2,
"data": "http://testserver/mediafiles/fake/path/model_updates/6",
"status": 0,
"created_on": "2022-02-28T00:36:54.803000Z",
"base_aggregate": 2,
"applied_aggregate": None,
},
{
"id": 7,
"client": "cbb6025f-c15c-4e90-b3fb-85626f7a79f1",
"federated_model": 3,
"data": "http://testserver/mediafiles/fake/path/model_updates/7",
"status": 0,
"created_on": "2022-12-26T01:12:55.467000Z",
"base_aggregate": None,
"applied_aggregate": None,
},
{
"id": 8,
"client": "cbb6025f-c15c-4e90-b3fb-85626f7a79f1",
"federated_model": 3,
"data": "http://testserver/mediafiles/fake/path/model_updates/8",
"status": 0,
"created_on": "2022-12-08T13:22:24.557000Z",
"base_aggregate": None,
"applied_aggregate": None,
},
]
self.assertEqual(200, response.status_code)
self.assertCountEqual(expected_response, response.json())
self.logout_user()
# validate client view
self.login_client(client_json={"uuid": "cbb6025f-c15c-4e90-b3fb-85626f7a79f1"})
response = self.client.get(baseurl, format="json")
expected_response = [
{
"id": 1,
"client": "cbb6025f-c15c-4e90-b3fb-85626f7a79f1",
"federated_model": 1,
"data": "http://testserver/mediafiles/fake/path/model_updates/1",
"created_on": "2022-12-15T23:08:28.720000Z",
"base_aggregate": None,
},
{
"id": 2,
"client": "cbb6025f-c15c-4e90-b3fb-85626f7a79f1",
"federated_model": 1,
"data": "http://testserver/mediafiles/fake/path/model_updates/2",
"created_on": "2023-01-10T23:10:33.720000Z",
"base_aggregate": None,
},
{
"id": 5,
"client": "cbb6025f-c15c-4e90-b3fb-85626f7a79f1",
"federated_model": 2,
"data": "http://testserver/mediafiles/fake/path/model_updates/5",
"created_on": "2022-02-17T17:58:44.441000Z",
"base_aggregate": None,
},
{
"id": 7,
"client": "cbb6025f-c15c-4e90-b3fb-85626f7a79f1",
"federated_model": 3,
"data": "http://testserver/mediafiles/fake/path/model_updates/7",
"created_on": "2022-12-26T01:12:55.467000Z",
"base_aggregate": None,
},
{
"id": 8,
"client": "cbb6025f-c15c-4e90-b3fb-85626f7a79f1",
"federated_model": 3,
"data": "http://testserver/mediafiles/fake/path/model_updates/8",
"created_on": "2022-12-08T13:22:24.557000Z",
"base_aggregate": None,
},
]
self.assertEqual(200, response.status_code)
self.assertCountEqual(expected_response, response.json())
self.logout_client()
def test_create(self, *mocks):
baseurl = reverse(self.reverse_url)
# validate unauthorized
self._validate_unauthorized(baseurl, client_action=self.client.post)
# validate client can't set client, status
self.login_client(client_json={"uuid": "cbb6025f-c15c-4e90-b3fb-85626f7a79f1"})
create_data = {
"client": "aab6025f-c15c-4e90-b3fb-85626f7a79f1",
"data": [[1, 5, 2], [2, 3, 4]],
"federated_model": 1,
"base_aggregate": None,
}
with mock.patch(
"django.core.files.storage.FileSystemStorage.save"
) as mock_save:
mock_save.return_value = "created data"
response = self.client.post(baseurl, format="json", data=create_data)
print(response)
cleaned_response = response.json()
# rather error show up on assert, hence `None`
cleaned_response.pop("created_on", None)
cleaned_response.pop("last_modified", None)
expected_response = create_data.copy()
expected_response["id"] = 9
expected_response["client"] = "cbb6025f-c15c-4e90-b3fb-85626f7a79f1"
expected_response["data"] = "http://testserver/mediafiles/created%20data"
expected_response["base_aggregate"] = None
self.assertEqual(201, response.status_code)
self.assertDictEqual(expected_response, cleaned_response)
# validate authorized client
self.login_client(client_json={"uuid": "cbb6025f-c15c-4e90-b3fb-85626f7a79f1"})
create_data = {
"data": [[1, 5, 2], [2, 3, 4]],
"federated_model": 1,
}
with mock.patch(
"django.core.files.storage.FileSystemStorage.save"
) as mock_save:
mock_save.return_value = "created data"
response = self.client.post(baseurl, format="json", data=create_data)
cleaned_response = response.json()
# rather error show up on assert, hence `None`
cleaned_response.pop("created_on", None)
cleaned_response.pop("last_modified", None)
expected_response = create_data.copy()
expected_response["id"] = 10
expected_response["client"] = "cbb6025f-c15c-4e90-b3fb-85626f7a79f1"
expected_response["base_aggregate"] = None
expected_response["data"] = "http://testserver/mediafiles/created%20data"
self.assertEqual(201, response.status_code)
self.assertDictEqual(expected_response, cleaned_response)
# test create w/ invalid schema
create_data = {
"data": [[1, 5], [2, 3]],
"federated_model": 1,
}
response = self.client.post(baseurl, format="json", data=create_data)
cleaned_response = response.json()
expected_response = {
"data": [
"data did not match the required schema: {}".format(
{
"type": "array",
"prefixItems": [
{"type": "array", "minItems": 3, "maxItems": 3},
{"type": "array", "minItems": 3, "maxItems": 3},
],
"items": False,
}
)
]
}
self.assertEqual(400, response.status_code)
self.assertDictEqual(expected_response, cleaned_response)
# TODO: create test to not allow non-registered clients
def test_get(self, *mocks):
baseurl = reverse(self.reverse_url)
# validate unauthorized
self._validate_unauthorized(baseurl + "1/", client_action=self.client.get)
# validate admin access to both
self.login_user(user_json={"username": "admin"})
response = self.client.get(baseurl + "1/", format="json")
expected_response = {
"id": 1,
"client": "cbb6025f-c15c-4e90-b3fb-85626f7a79f1",
"federated_model": 1,
"data": "http://testserver/mediafiles/fake/path/model_updates/1",
"status": 2,
"created_on": "2022-12-15T23:08:28.720000Z",
"base_aggregate": None,
"applied_aggregate": None,
}
response_json = response.json()
self.assertEqual(200, response.status_code)
self.assertDictEqual(expected_response, response_json)
response = self.client.get(baseurl + "2/", format="json")
expected_response = {
"id": 2,
"client": "cbb6025f-c15c-4e90-b3fb-85626f7a79f1",
"federated_model": 1,
"data": "http://testserver/mediafiles/fake/path/model_updates/2",
"status": 2,
"created_on": "2023-01-10T23:10:33.720000Z",
"base_aggregate": None,
"applied_aggregate": None,
}
self.assertEqual(200, response.status_code)
self.assertDictEqual(expected_response, response.json())
self.logout_user()
# validate developer no access to models that they don't own
self.login_user(user_json={"username": "non_admin"})
response = self.client.get(baseurl + "1/", format="json")
self.assertEqual(404, response.status_code)
self.assertEqual({"detail": "Not found."}, response.json())
# validate developer access to their own model
response = self.client.get(baseurl + "5/", format="json")
expected_response = {
"id": 5,
"client": "cbb6025f-c15c-4e90-b3fb-85626f7a79f1",
"federated_model": 2,
"data": "http://testserver/mediafiles/fake/path/model_updates/5",
"status": 0,
"created_on": "2022-02-17T17:58:44.441000Z",
"base_aggregate": None,
"applied_aggregate": None,
}
self.assertEqual(200, response.status_code)
self.assertDictEqual(expected_response, response.json())
@mock.patch("rest_framework.mixins.ListModelMixin.list")
def test_token_login(self, mock_list, *mocks):
# validate get using auth token
baseurl = reverse(self.reverse_url)
user_json = {"username": "non_admin"}
mock_list.return_value = Response({"detail": "successful API Call"})
self.user_token_login(user_json=user_json)
_ = self.client.get(baseurl)
params = mock_list.call_args
mock_list.assert_called_once()
self.assertEqual(self.user, params[0][0].user)
self.user_token_logout()
def test_filters(self, *mocks):
baseurl = reverse(self.reverse_url)
# validate federated_model filtering
queryurl = baseurl + "?federated_model=1"
self.login_user(user_json={"username": "admin"})
response = self.client.get(queryurl, format="json")
expected_response = [
{
"id": 3,
"client": "531580e6-ce6c-4f01-a5aa-9ed7af5ee768",
"federated_model": 1,
"data": "http://testserver/mediafiles/fake/path/model_updates/3",
"status": 2,
"created_on": "2023-01-16T23:17:35.480000Z",
"base_aggregate": None,
"applied_aggregate": None,
},
{
"id": 2,
"client": "cbb6025f-c15c-4e90-b3fb-85626f7a79f1",
"federated_model": 1,
"data": "http://testserver/mediafiles/fake/path/model_updates/2",
"status": 2,
"created_on": "2023-01-10T23:10:33.720000Z",
"base_aggregate": None,
"applied_aggregate": None,
},
{
"id": 1,
"client": "cbb6025f-c15c-4e90-b3fb-85626f7a79f1",
"federated_model": 1,
"data": "http://testserver/mediafiles/fake/path/model_updates/1",
"status": 2,
"created_on": "2022-12-15T23:08:28.720000Z",
"base_aggregate": None,
"applied_aggregate": None,
},
{
"id": 4,
"client": "531580e6-ce6c-4f01-a5aa-9ed7af5ee768",
"federated_model": 1,
"data": "http://testserver/mediafiles/fake/path/model_updates/4",
"status": 3,
"created_on": "2022-02-17T17:58:13.819000Z",
"base_aggregate": None,
"applied_aggregate": None,
},
]
self.assertEqual(200, response.status_code)
self.assertEqual(expected_response, response.json())
# validate federate_model=2
queryurl = baseurl + "?federated_model=2"
self.login_user(user_json={"username": "admin"})
response = self.client.get(queryurl, format="json")
expected_response = [
{
"id": 6,
"client": "ab359e5d-6991-4088-8815-a85d3e413c02",
"federated_model": 2,
"data": "http://testserver/mediafiles/fake/path/model_updates/6",
"status": 0,
"created_on": "2022-02-28T00:36:54.803000Z",
"base_aggregate": 2,
"applied_aggregate": None,
},
{
"id": 5,
"client": "cbb6025f-c15c-4e90-b3fb-85626f7a79f1",
"federated_model": 2,
"data": "http://testserver/mediafiles/fake/path/model_updates/5",
"status": 0,
"created_on": "2022-02-17T17:58:44.441000Z",
"base_aggregate": None,
"applied_aggregate": None,
},
]
self.assertEqual(200, response.status_code)
self.assertEqual(expected_response, response.json())
# validate federate_model=2
queryurl = baseurl + "?status=0"
self.login_user(user_json={"username": "admin"})
response = self.client.get(queryurl, format="json")
expected_response = [
{
"id": 7,
"client": "cbb6025f-c15c-4e90-b3fb-85626f7a79f1",
"federated_model": 3,
"data": "http://testserver/mediafiles/fake/path/model_updates/7",
"status": 0,
"created_on": "2022-12-26T01:12:55.467000Z",
"base_aggregate": None,
"applied_aggregate": None,
},
{
"id": 8,
"client": "cbb6025f-c15c-4e90-b3fb-85626f7a79f1",
"federated_model": 3,
"data": "http://testserver/mediafiles/fake/path/model_updates/8",
"status": 0,
"created_on": "2022-12-08T13:22:24.557000Z",
"base_aggregate": None,
"applied_aggregate": None,
},
{
"id": 6,
"data": "http://testserver/mediafiles/fake/path/model_updates/6",
"status": 0,
"created_on": "2022-02-28T00:36:54.803000Z",
"client": "ab359e5d-6991-4088-8815-a85d3e413c02",
"federated_model": 2,
"base_aggregate": 2,
"applied_aggregate": None,
},
{
"id": 5,
"client": "cbb6025f-c15c-4e90-b3fb-85626f7a79f1",
"federated_model": 2,
"data": "http://testserver/mediafiles/fake/path/model_updates/5",
"status": 0,
"created_on": "2022-02-17T17:58:44.441000Z",
"base_aggregate": None,
"applied_aggregate": None,
},
]
self.assertEqual(200, response.status_code)
self.assertEqual(expected_response, response.json())
def test_pagination(self, *mocks):
baseurl = reverse(self.reverse_url)
# setting the page size to 4 and querying for page 2
queryurl = baseurl + "?page_size=4&page=2"
self.login_user(user_json={"username": "admin"})
response = self.client.get(queryurl, format="json")
self.assertEqual(200, response.status_code)
self.assertEqual(4, len(response.json()))
# setting the page size to 2 and querying for page 2
queryurl = baseurl + "?page_size=2&page=2"
self.login_user(user_json={"username": "admin"})
response = self.client.get(queryurl, format="json")
self.assertEqual(200, response.status_code)
self.assertEqual(2, len(response.json()))
|