-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
145 additions
and
216,124 deletions.
There are no files selected for viewing
1,487 changes: 0 additions & 1,487 deletions
1,487
5c00412b19131c0025defa91__general_6b388e39-4b8d-494f-9a9a-867a27def5d6
This file was deleted.
Oops, something went wrong.
1,487 changes: 0 additions & 1,487 deletions
1,487
5c00412b19131c0025defa91__general_6b388e39-4b8d-494f-9a9a-867a27def5d6.1
This file was deleted.
Oops, something went wrong.
41,140 changes: 0 additions & 41,140 deletions
41,140
5c00412b19131c0025defa91__general_6b388e39-4b8d-494f-9a9a-867a27def5d6.10
This file was deleted.
Oops, something went wrong.
41,140 changes: 0 additions & 41,140 deletions
41,140
5c00412b19131c0025defa91__general_6b388e39-4b8d-494f-9a9a-867a27def5d6.11
This file was deleted.
Oops, something went wrong.
1,487 changes: 0 additions & 1,487 deletions
1,487
5c00412b19131c0025defa91__general_6b388e39-4b8d-494f-9a9a-867a27def5d6.2
This file was deleted.
Oops, something went wrong.
1,487 changes: 0 additions & 1,487 deletions
1,487
5c00412b19131c0025defa91__general_6b388e39-4b8d-494f-9a9a-867a27def5d6.3
This file was deleted.
Oops, something went wrong.
1,487 changes: 0 additions & 1,487 deletions
1,487
5c00412b19131c0025defa91__general_6b388e39-4b8d-494f-9a9a-867a27def5d6.4
This file was deleted.
Oops, something went wrong.
1,487 changes: 0 additions & 1,487 deletions
1,487
5c00412b19131c0025defa91__general_6b388e39-4b8d-494f-9a9a-867a27def5d6.5
This file was deleted.
Oops, something went wrong.
1,487 changes: 0 additions & 1,487 deletions
1,487
5c00412b19131c0025defa91__general_6b388e39-4b8d-494f-9a9a-867a27def5d6.6
This file was deleted.
Oops, something went wrong.
41,140 changes: 0 additions & 41,140 deletions
41,140
5c00412b19131c0025defa91__general_6b388e39-4b8d-494f-9a9a-867a27def5d6.7
This file was deleted.
Oops, something went wrong.
41,140 changes: 0 additions & 41,140 deletions
41,140
5c00412b19131c0025defa91__general_6b388e39-4b8d-494f-9a9a-867a27def5d6.8
This file was deleted.
Oops, something went wrong.
41,140 changes: 0 additions & 41,140 deletions
41,140
5c00412b19131c0025defa91__general_6b388e39-4b8d-494f-9a9a-867a27def5d6.9
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
import pandas as pd | ||
from app.services.aggregator.factoryAggr import FactoryAggr | ||
from app.services.mappers.aggregator import mapperA | ||
|
||
|
||
def make_aggregation(data): | ||
aggr = {} | ||
|
||
df = pd.DataFrame(data) | ||
factory = FactoryAggr(df) | ||
|
||
for mapp in mapperA(): | ||
result = factory.run(mapp) | ||
|
||
if result is not None: | ||
entity = mapp.uniqueField() | ||
aggr[entity] = { | ||
'label': result.index.tolist(), | ||
'data': result.tolist() | ||
} | ||
|
||
return aggr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
class Aggr(object): | ||
|
||
def __init__(self, field, sub=''): | ||
self._field = field | ||
self._sub = sub | ||
self._result = [] | ||
|
||
def getField(self): | ||
return self._field | ||
|
||
def uniqueField(self): | ||
return "%s_%s" % (self._field, self._sub) | ||
|
||
def getResult(self): | ||
return self._result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import pandas as pd | ||
from.aggr import Aggr | ||
|
||
class AggrDict(Aggr): | ||
|
||
def __init__(self, field, sub="name", aggrk="_id", aggr="count"): | ||
self._aggr = aggr | ||
self._aggrk = aggrk | ||
super().__init__(field, sub) | ||
|
||
def aggregate(self, df): | ||
dic = df.dropna().apply(pd.Series) | ||
|
||
if self._sub in dic: | ||
aggr = dic.groupby(self._sub).agg({self._aggrk: self._aggr}) | ||
self._result = aggr.get(self._aggrk) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
from.aggr import Aggr | ||
|
||
class AggrImmutable(Aggr): | ||
|
||
def aggregate(self, df): | ||
self._result = df.groupby(df).count() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
import pandas as pd | ||
from.aggr import Aggr | ||
|
||
class AggrListObj(Aggr): | ||
|
||
def aggregate(self, df): | ||
|
||
dic = df\ | ||
.dropna()\ | ||
.apply(self.merged)\ | ||
.stack()\ | ||
.reset_index(level=1, drop=True) | ||
|
||
self._result = dic.groupby(dic).count() | ||
|
||
def merged(self, services): | ||
|
||
if services and isinstance(services, list): | ||
services = map(self.reducev, services) | ||
|
||
return pd.Series(services) | ||
|
||
def reducev(self, data): | ||
if isinstance(data, dict): | ||
return data.get(self._sub) | ||
|
||
if isinstance(data, (str, int, float)): | ||
return data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
|
||
class FactoryAggr(object): | ||
|
||
def __init__(self, dataframe): | ||
self._dataframe = dataframe | ||
|
||
def run(self, cls): | ||
field = cls.getField() | ||
|
||
if field in self._dataframe: | ||
df = self._dataframe[field] | ||
cls.aggregate(df) | ||
|
||
return cls.getResult() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
from app.services.aggregator.aggrDict import AggrDict | ||
from app.services.aggregator.aggrListObj import AggrListObj | ||
from app.services.aggregator.aggrImmutable import AggrImmutable | ||
|
||
def mapperA(): | ||
return [ | ||
AggrImmutable("family"), | ||
AggrImmutable("size"), | ||
AggrImmutable("provider"), | ||
AggrDict("datacenters", sub="name"), | ||
AggrDict("datacenters", sub="provider"), | ||
AggrDict("datacenters", sub="instance"), | ||
AggrDict("datacenters", sub="region"), | ||
AggrDict("os", sub="base", aggrk="base"), | ||
AggrListObj("regions"), | ||
AggrListObj("zones"), | ||
AggrListObj("deps", sub="name"), | ||
AggrListObj("services", sub="name"), | ||
AggrListObj("deploy", sub="type"), | ||
AggrListObj("contacts", sub="channel"), | ||
AggrListObj("applications", sub="name"), | ||
AggrListObj("system", sub="name"), | ||
AggrListObj("clients", sub="name"), | ||
AggrListObj("entry", sub="name"), | ||
AggrListObj("auth", sub="type"), | ||
AggrListObj("tags", sub="key"), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters