Skip to content

Commit

Permalink
Pull request update/240920
Browse files Browse the repository at this point in the history
f928f68 OS-7847. Fixed motor+pymongo version in arcee and bulldozer
bc64d6a OS-7841. Additional live_demo runs fixes
c45c292 OS-7846. Fixed discount fields for aws raw expenses
c049b0d OS-7799. Use accessorFn to resolve null tag to a string
  • Loading branch information
stanfra authored Sep 20, 2024
2 parents b343b1e + f928f68 commit bf29199
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 39 deletions.
3 changes: 2 additions & 1 deletion arcee/arcee_receiver/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
aiohttp==3.10.2
sanic==23.12.1
sanic-ext==23.12.0
motor==3.4.0
motor==3.6.0
pymongo==4.9.1
python-etcd==0.4.5
mongodb-migrations==1.2.1
pydantic==2.4.2
Expand Down
3 changes: 2 additions & 1 deletion bulldozer/bulldozer_api/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
aiohttp==3.10.2
sanic==23.12.1
motor==3.4.0
motor==3.6.0
pymongo==4.9.1
websockets==12.0
kombu==5.3.4
mongodb-migrations==1.2.1
Expand Down
1 change: 1 addition & 0 deletions diworker/diworker/importers/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
AWS_CUR_PREFIX_MAP = {
'identity': (False, []),
'bill': (False, []),
'discount': (False, []),
'line_item': (False, []),
'product': (True, ['product_name', 'purchase_option', 'size_flex']),
'pricing': (True, ['rate_code', 'rate_id', 'purchase_option',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import logging
from optscale_client.rest_api_client.client_v2 import Client as RestClient
from diworker.diworker.migrations.base import BaseMigration
"""
Fixed names for discount fields in AWS expenses
"""
LOG = logging.getLogger(__name__)


class Migration(BaseMigration):
@property
def rest_cl(self):
if self._rest_cl is None:
self._rest_cl = RestClient(
url=self.config_cl.restapi_url(),
secret=self.config_cl.cluster_secret())
return self._rest_cl

@property
def mongo_raw(self):
return self.db.raw_expenses

def get_cloud_accs(self):
cloud_accounts_ids = set()
_, organizations = self.rest_cl.organization_list({
'with_connected_accounts': True, 'is_demo': False})
for org in organizations['organizations']:
_, accounts = self.rest_cl.cloud_account_list(
org['id'], type='aws_cnr')
for cloud_account in accounts['cloud_accounts']:
if cloud_account['auto_import']:
cloud_accounts_ids.add(cloud_account['id'])
return cloud_accounts_ids

def upgrade(self):
cloud_accs = self.get_cloud_accs()
for i, cloud_acc_id in enumerate(cloud_accs):
LOG.info('Starting processing for cloud account %s (%s/%s)' % (
cloud_acc_id, i+1, len(cloud_accs)))
self.db.raw_expenses.update_many(
{'bill/BillingPeriodStartDate': {'$exists': True},
'cloud_account_id': cloud_acc_id},
{'$rename': {
'discount_total_discount': 'discount/TotalDiscount',
'discount_bundled_discount': 'discount/BundledDiscount'}})

def downgrade(self):
pass
14 changes: 0 additions & 14 deletions ngui/ui/src/components/TagKey/TagKey.test.tsx

This file was deleted.

5 changes: 0 additions & 5 deletions ngui/ui/src/components/TagKey/TagKey.tsx

This file was deleted.

3 changes: 0 additions & 3 deletions ngui/ui/src/components/TagKey/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
import { useMemo } from "react";
import BarChartOutlinedIcon from "@mui/icons-material/BarChartOutlined";
import { FormattedMessage } from "react-intl";
import { FormattedMessage, useIntl } from "react-intl";
import FormattedMoney from "components/FormattedMoney";
import Table from "components/Table";
import TableCellActions from "components/TableCellActions";
import TableLoader from "components/TableLoader";
import TagKey from "components/TagKey";
import TextWithDataTestId from "components/TextWithDataTestId";
import TextWithDate from "components/TextWithDate";
import { FORMATTED_MONEY_TYPES } from "utils/constants";

const getTotalBreakdownTableData = (counts) =>
Object.entries(counts).map(([id, { name = "", ...details }]) => ({
id: id ?? name,
name,
...details
}));

const TagsBreakdownTable = ({ data, appliedRange, isLoading, selectedTag, onShowOnChartClick }) => {
const tableData = useMemo(() => getTotalBreakdownTableData(data), [data]);
const tableData = useMemo(() => data, [data]);

const intl = useIntl();

const columns = useMemo(
() => [
Expand All @@ -28,8 +22,12 @@ const TagsBreakdownTable = ({ data, appliedRange, isLoading, selectedTag, onShow
<FormattedMessage id="tagKey" />
</TextWithDataTestId>
),
accessorKey: "tag",
cell: ({ cell }) => <TagKey tagKey={cell.getValue()} />
id: "tagKey",
accessorFn: ({ tag }) =>
tag ??
intl.formatMessage({
id: "(untagged)"
})
},
{
header: (
Expand Down Expand Up @@ -81,7 +79,7 @@ const TagsBreakdownTable = ({ data, appliedRange, isLoading, selectedTag, onShow
)
}
],
[appliedRange.startSecondsTimestamp, appliedRange.endSecondsTimestamp, onShowOnChartClick, selectedTag]
[appliedRange.startSecondsTimestamp, appliedRange.endSecondsTimestamp, intl, selectedTag, onShowOnChartClick]
);

return isLoading ? (
Expand Down
Binary file modified rest_api/live_demo.tar.xz
Binary file not shown.
4 changes: 2 additions & 2 deletions rest_api/rest_api_server/controllers/live_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
TOP_NO_DUPLICATE_RESOURCES = 10
DUPLICATION_FORMAT = '-x{ending}'
WITH_SUBPOOLS_SIGN = '+'
MIN_RUN_DURATION = 7 * 60 * 60
MAX_RUN_DURATION = 24 * 60 * 60
MIN_RUN_DURATION = 14 * 60 * 60
MAX_RUN_DURATION = 48 * 60 * 60
RECOMMENDATION_MULTIPLIED_FIELDS = ['saving', 'annually_monthly_saving',
'monthly_saving']
PREPARED_DEMO_LIFETIME_DAYS = 3
Expand Down

0 comments on commit bf29199

Please sign in to comment.