Skip to content

Commit

Permalink
HW2 Pull Request (xlab-uiuc#67)
Browse files Browse the repository at this point in the history
* system state hw1

* hw1 state

* uploading crd

* hw2
  • Loading branch information
amankhinvasara authored Feb 16, 2024
1 parent 004e53b commit 34024d4
Show file tree
Hide file tree
Showing 2 changed files with 178 additions and 2 deletions.
2 changes: 0 additions & 2 deletions operators/DataDog_datadog-operator/jenkins.io_jenkins.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
Expand Down
178 changes: 178 additions & 0 deletions operators/DataDog_datadog-operator/required_measure.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import yaml"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"def load_yaml_file(file_path):\n",
" with open(file_path, 'r') as file:\n",
" data = yaml.safe_load(file)\n",
" return data"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"# Example usage:\n",
"yaml_file_path = 'jenkins.io_jenkins.yaml'\n",
"data = load_yaml_file(yaml_file_path)\n"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"schema_properties = data['spec']['versions'][0]['schema']['openAPIV3Schema']['properties']"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"schema_spec = schema_properties['spec']"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [],
"source": [
"def requiredTreeHelper(d):\n",
" if 'required' not in d.keys():\n",
" return None\n",
" else:\n",
" return {k : requiredTreeHelper(d['properties'][k]) for k in d['required']}\n",
"\n",
"def requiredTree(d):\n",
" return {'spec': requiredTreeHelper(d)}"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [],
"source": [
"t = requiredTree(schema_spec)"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'spec': {'jenkinsAPISettings': {'authorizationStrategy': None},\n",
" 'master': {'disableCSRFProtection': None}}}"
]
},
"execution_count": 37,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"t"
]
},
{
"cell_type": "code",
"execution_count": 43,
"metadata": {},
"outputs": [],
"source": [
"def size(T):\n",
" if T is None:\n",
" return 0\n",
" return 1 + sum([size(t) for t in T.values()])\n",
"\n",
"def height(T):\n",
" if T is None:\n",
" return -1\n",
" return 1 + max([depth(t) for t in T.values()])"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"4"
]
},
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"size(t)"
]
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2"
]
},
"execution_count": 44,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"height(t)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.8"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit 34024d4

Please sign in to comment.