Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple paths per bucket in replay selector #160

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions tools/ReplayAnalysis/api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,15 @@ def search_s3():
boto3_session = boto3.Session()

if request.method == "GET":
bucket = request.args.get("uri")
bucket, data = list_replays(bucket, session=boto3_session)
if bucket is None:
uri = request.args.get("uri")
workload, data = list_replays(uri, session=boto3_session)
if workload is None:
if data is ClientError:
return jsonify({"success": False, "message": data.__str__()}), 403
else:
return jsonify({"success": False, "message": data.__str__()}), 404

return jsonify({"success": True, "bucket": bucket, "replays": data}), 201
return jsonify({"success": True, "workload": workload, "replays": data}), 201


@app.route("/submit_replays", methods=["GET", "POST"])
Expand Down
2 changes: 1 addition & 1 deletion tools/ReplayAnalysis/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def list_replays(bucket_url, session):
print(f"Unable to access replay. {e}")

# use tabulate lib to format output
return bucket.get("bucket_name"), table
return table[0]["workload"], table


def remove_comments(string):
Expand Down
30 changes: 15 additions & 15 deletions tools/ReplayAnalysis/gui/src/pages/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export const HomePage = () => {

const [resource, setResource] = useState('');
const [replays, setReplays] = useState([])
const [buckets, setBuckets] = useState([])
const [bucketLabels, setBucketLabels] = useState([])
const [workloads, setWorkloads] = useState([])
const [workloadLabels, setWorkloadLabels] = useState([])
const [searching, setSearching] = useState(false)
const [profiles, setProfiles] = useState([])
const [valid, setValid] = useState(true)
Expand All @@ -36,10 +36,10 @@ export const HomePage = () => {
if (!response.success) {
setValid(false)
} else {
if (!buckets.includes(response.bucket)) {
if (!workloads.includes(response.workload)) {
setReplays(replays => [...replays, ...response.replays]);
setBuckets(buckets => [...buckets, response.bucket]);
setBucketLabels(buckets => [...buckets, {label: response.bucket}]);
setWorkloads(workloads => [...workloads, response.workload]);
setWorkloadLabels(workloads => [...workloads, {label: response.workload}]);
}
}

Expand All @@ -59,17 +59,17 @@ export const HomePage = () => {
}

/**
* Removes entries from list of replays when bucket is removed
* Removes entries from list of replays when workload is removed
* @param {number} itemIndex Total data set of query frequency values.
*/
function removeBucket(itemIndex) {
let bucket = bucketLabels[itemIndex].label
setBucketLabels([...bucketLabels.slice(0, itemIndex),
...bucketLabels.slice(itemIndex + 1)]);
setBuckets([...buckets.slice(0, itemIndex),
...buckets.slice(itemIndex + 1)]);
function removeWorkload(itemIndex) {
let workload = workloadLabels[itemIndex].label
setWorkloadLabels([...workloadLabels.slice(0, itemIndex),
...workloadLabels.slice(itemIndex + 1)]);
setWorkloads([...workloads.slice(0, itemIndex),
...workloads.slice(itemIndex + 1)]);
let result = replays.filter((data) => {
return data.bucket.search(bucket) === -1;
return data.workload !== workload;
});
setReplays(result);
}
Expand Down Expand Up @@ -113,9 +113,9 @@ export const HomePage = () => {

<TokenGroup
onDismiss={({detail: {itemIndex}}) => {
removeBucket(itemIndex)
removeWorkload(itemIndex)
}}
items={bucketLabels}>
items={workloadLabels}>

</TokenGroup>

Expand Down