Skip to content

Commit 7e649a9

Browse files
authored
Merge pull request #52 from OpenDataAlex/process_tracker_python-50
Process tracker python 50
2 parents b149270 + f7fc8fc commit 7e649a9

15 files changed

+776
-79
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,3 @@ pip-selfcheck.json
173173
.idea/misc.xml
174174
.idea/modules.xml
175175
.idea/process_tracker_python.iml
176-
/tests/test_process_tracker.py

dbscripts/mysql_process_tracker.sql

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,3 +272,31 @@ create index process_run_actor_id
272272
create index process_status_id
273273
on process_tracking (process_status_id);
274274

275+
create table process_tracker.cluster_tracking
276+
(
277+
cluster_id int auto_increment
278+
primary key,
279+
cluster_name varchar(250) not null,
280+
cluster_max_memory int null,
281+
cluster_max_memory_unit char(2) null,
282+
cluster_max_processing int null,
283+
cluster_max_processing_unit varchar(3) null,
284+
cluster_current_memory_usage int null,
285+
cluster_current_process_usage int null,
286+
constraint cluster_tracking_cluster_name_uindex
287+
unique (cluster_name)
288+
)
289+
comment 'Capacity cluster tracking';
290+
291+
create table process_tracker.cluster_process
292+
(
293+
cluster_id int not null,
294+
process_id int not null,
295+
primary key (cluster_id, process_id),
296+
constraint cluster_process_fk01
297+
foreign key (cluster_id) references process_tracker.cluster_tracking (cluster_id),
298+
constraint cluster_process_fk02
299+
foreign key (process_id) references process_tracker.process (process_id)
300+
)
301+
comment 'Relationship tracking between processes and performance clusters.';
302+

dbscripts/postgresql_process_tracker.sql

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ create table process
114114
primary key,
115115
process_name varchar(250) not null,
116116
total_record_count integer default 0 not null,
117-
process_type_id integer not null
117+
process_type_id integer null
118118
constraint process_fk02
119119
references process_type_lkup,
120-
process_tool_id integer not null
120+
process_tool_id integer null
121121
constraint process_fk03
122122
references tool_lkup,
123123
last_failed_run_date_time timestamp default '1900-01-01 00:00:00'::timestamp without time zone not null
@@ -417,3 +417,40 @@ comment on table extract_dependency is 'Table tracking interdependencies between
417417

418418
alter table extract_dependency owner to pt_admin;
419419

420+
create table cluster_tracking
421+
(
422+
cluster_id serial not null
423+
constraint cluster_tracking_pk
424+
primary key,
425+
cluster_name varchar(250) not null,
426+
cluster_max_memory integer null,
427+
cluster_max_memory_unit char(2) null,
428+
cluster_max_processing integer null,
429+
cluster_max_processing_unit varchar(3) null,
430+
cluster_current_memory_usage integer,
431+
cluster_current_process_usage integer
432+
);
433+
434+
comment on table cluster_tracking is 'Capacity cluster tracking';
435+
436+
alter table cluster_tracking owner to pt_admin;
437+
438+
create unique index cluster_tracking_cluster_name_uindex
439+
on cluster_tracking (cluster_name);
440+
441+
create table cluster_process
442+
(
443+
cluster_id integer not null
444+
constraint cluster_process_fk01
445+
references cluster_tracking,
446+
process_id integer not null
447+
constraint cluster_process_fk02
448+
references process,
449+
constraint cluster_process_pk
450+
primary key (cluster_id, process_id)
451+
);
452+
453+
comment on table cluster_process is 'Relationship tracking between processes and performance clusters.';
454+
455+
alter table cluster_process owner to pt_admin;
456+

process_tracker/cli.py

Lines changed: 115 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,39 @@ def upgrade():
5454
"-p", "--parent", help="The parent process' name, if creating a process dependency"
5555
)
5656
@click.option(
57-
"-c", "--child", help="The child process' name, if creating a process dependency"
57+
"-c",
58+
"--child",
59+
help="The child process' name, if creating a process dependency. For cluster/process relationships, the name of "
60+
"the process.",
5861
)
59-
def create(topic, name, parent=None, child=None):
62+
@click.option(
63+
"--max-processing",
64+
help="For clusters, the max processing ability allocated to the cluster",
65+
)
66+
@click.option(
67+
"--max-memory", help="For clusters, the max memory allocated to the cluster"
68+
)
69+
@click.option(
70+
"--processing-unit",
71+
help="For clusters, the unit of processing ability (Ghz, CPU, DPU, etc.",
72+
)
73+
@click.option(
74+
"--memory-unit", help="For clusters, the unit of allocated memory (MB, GB, etc."
75+
)
76+
@click.option(
77+
"--cluster", help="For cluster/process relationships, the name of the cluster"
78+
)
79+
def create(
80+
topic,
81+
name,
82+
parent=None,
83+
child=None,
84+
max_processing=None,
85+
processing_unit=None,
86+
max_memory=None,
87+
memory_unit=None,
88+
cluster=None,
89+
):
6090
"""
6191
Create an item that is within the valid topics list.
6292
:param topic: The name of the topic.
@@ -65,11 +95,32 @@ def create(topic, name, parent=None, child=None):
6595
:type name: string
6696
:param parent: The parent process' name, if creating a process dependency
6797
:type parent: string
68-
:param child: The child process' name, if creating a process dependency
98+
:param child: The child process' name, if creating a process dependency. For cluster/process relationships, the
99+
name of the process.
69100
:type child: string
101+
:param max_processing: For performance clusters, the maximum processing ability allocated to the cluster
102+
:type max_processing: integer
103+
:param max_memory: For performance clusters, the maximum memory allocated to the cluster
104+
:type max_memory: integer
105+
:param processing_unit: For performance clusters, the unit of processing ability allocated to the cluster
106+
:type processing_unit: string
107+
:param memory_unit: For performance clusters, the unit of allocated memory to the cluster
108+
:type memory_unit: string
109+
:param cluster: For cluster/process relationships, the name of the cluster.
110+
:type cluster: string
70111
"""
71112
click.echo("Attempting to create %s with name %s" % (topic, name))
72-
data_store.topic_creator(topic=topic, name=name, parent=parent, child=child)
113+
data_store.topic_creator(
114+
topic=topic,
115+
name=name,
116+
parent=parent,
117+
child=child,
118+
max_processing=max_processing,
119+
max_memory=max_memory,
120+
processing_unit=processing_unit,
121+
memory_unit=memory_unit,
122+
cluster=cluster,
123+
)
73124

74125

75126
@main.command()
@@ -81,7 +132,10 @@ def create(topic, name, parent=None, child=None):
81132
@click.option(
82133
"-c", "--child", help="The child process' name, if deleting a process dependency"
83134
)
84-
def delete(topic, name, parent=None, child=None):
135+
@click.option(
136+
"--cluster", help="For cluster/process relationships, the name of the cluster"
137+
)
138+
def delete(topic, name, parent=None, child=None, cluster=None):
85139
"""
86140
Delete an item that is within the valid topics list and not a pre-loaded item.
87141
:param topic: The name of the topic.
@@ -90,20 +144,71 @@ def delete(topic, name, parent=None, child=None):
90144
:type name: string
91145
:param parent: The parent process' name, if deleting a process dependency
92146
:type parent: string
93-
:param child: The child process' name, if deleting a process dependency
147+
:param child: The child process' name, if deleting a process dependency. For cluster/process relationships, the
148+
name of the process.
94149
:type child: string
150+
:param cluster: For cluster/process relationships, the name of the cluster.
151+
:type cluster: string
95152
"""
96153
click.echo("Attempting to delete %s with name %s" % (topic, name))
97-
data_store.topic_deleter(topic=topic, name=name, parent=parent, child=child)
154+
data_store.topic_deleter(
155+
topic=topic, name=name, parent=parent, child=child, cluster=cluster
156+
)
98157

99158

100159
@main.command()
101160
@click.option("-t", "--topic", help="The topic being created")
102161
@click.option("-i", "--initial-name", help="The name that needs to be changed.")
103162
@click.option("-n", "--name", help="The new name for the topic.")
104-
def update(topic, initial_name, name):
105-
163+
@click.option(
164+
"--max-processing",
165+
help="For clusters, the max processing ability allocated to the cluster",
166+
)
167+
@click.option(
168+
"--max-memory", help="For clusters, the max memory allocated to the cluster"
169+
)
170+
@click.option(
171+
"--processing-unit",
172+
help="For clusters, the unit of processing ability (Ghz, CPU, DPU, etc.",
173+
)
174+
@click.option(
175+
"--memory-unit", help="For clusters, the unit of allocated memory (MB, GB, etc."
176+
)
177+
def update(
178+
topic,
179+
initial_name,
180+
name,
181+
max_processing=None,
182+
max_memory=None,
183+
processing_unit=None,
184+
memory_unit=None,
185+
):
186+
"""
187+
Update an item that is within the valid topics list and not a pre-loaded item.
188+
:param topic: The name of the topic.
189+
:type topic: string
190+
:param initial_name: The revised name of the topic item to be updated.
191+
:type initial_name: string
192+
:param name: The original name of the topic item to be updated.
193+
:type name: string
194+
:param max_processing: For performance clusters, the maximum processing ability allocated to the cluster
195+
:type max_processing: string
196+
:param max_memory: For performance clusters, the maximum memory allocated to the cluster
197+
:type max_memory: string
198+
:param processing_unit: For performance clusters, the unit of processing ability allocated to the cluster
199+
:type processing_unit: string
200+
:param memory_unit: For performance clusters, the unit of allocated memory to the cluster
201+
:type memory_unit: string
202+
"""
106203
click.echo(
107204
"Attempting to update %s with name %s to %s" % (topic, initial_name, name)
108205
)
109-
data_store.topic_updater(topic=topic, initial_name=initial_name, name=name)
206+
data_store.topic_updater(
207+
topic=topic,
208+
initial_name=initial_name,
209+
name=name,
210+
max_processing=max_processing,
211+
max_memory=max_memory,
212+
processing_unit=processing_unit,
213+
memory_unit=memory_unit,
214+
)

0 commit comments

Comments
 (0)