-
-
Notifications
You must be signed in to change notification settings - Fork 236
Fix duplicate data and API : Tickets [507] & [299] #508
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
Open
alencon
wants to merge
34
commits into
master
Choose a base branch
from
fix-database-mal
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
380255c
feat(cli): :sparkles: Rework CLI
LuisBlanche 9b3a88f
feat(core): :sparkles: add Organisation Team and Project to APi Client
LuisBlanche d913379
build: :arrow_up: add new dependencies for cli
LuisBlanche 951ed7c
fix(cli): :art: add a questionary prompt function
LuisBlanche 1dbc62b
test(cli): :white_check_mark: pass tests CLI
LuisBlanche 3677535
[507]:cleaning duplicate data
alencon 124d0ee
[299]:Prevent duplicate entry on API
alencon 17dbaf7
feat(cli): :sparkles: add more functionalities to python API client a…
LuisBlanche bb1be2d
feat(core): :sparkles: allows picking up API endpoint from conf file …
LuisBlanche 4b67fe9
[#516] : CodeCarbon Dashboard content :
alencon 0994802
feat(cli): :sparkles: allow to create a new custom configuration file…
LuisBlanche 8b2c39b
feat(cli): :sparkles: Rework CLI
LuisBlanche 1306879
feat(core): :sparkles: add Organisation Team and Project to APi Client
LuisBlanche cd7afe8
build: :arrow_up: add new dependencies for cli
LuisBlanche b52edab
fix(cli): :art: add a questionary prompt function
LuisBlanche 3be9005
test(cli): :white_check_mark: pass tests CLI
LuisBlanche 2e67fec
feat(cli): :sparkles: add more functionalities to python API client a…
LuisBlanche c09d39b
feat(core): :sparkles: allows picking up API endpoint from conf file …
LuisBlanche f86a666
feat(cli): :sparkles: allow to create a new custom configuration file…
LuisBlanche 235a283
Merge branch 'feat/rework_cli' of https://github.com/mlco2/codecarbon…
LuisBlanche fd906df
feat(CLI): :sparkles: allow to use or modify existing config file or …
LuisBlanche ae09ce3
test(CLI): :white_check_mark: fix tests
LuisBlanche 315542d
fix(CLI): :white_check_mark: use gihut action TEMP DIR
LuisBlanche bb1672c
ci(CLI): :green_heart: debu CI
LuisBlanche 7818242
ci(CLI): :green_heart: try modifying tox ini
LuisBlanche d813861
fix(CLI): :white_check_mark: remove useless test that created a .code…
LuisBlanche f3f28c3
ci(CLI): :rewind: remove debug step
LuisBlanche 3d8ab50
docs(CLI): :memo: test asciinema
LuisBlanche 903e3f3
docs(CLI): :memo: fix code block
LuisBlanche 8c3219e
[#299]:Fix API messages + add link for home page
alencon 24a1c17
[#507]: Fix stored procedure raise notice
alencon 56d4f96
empty line at end of file
3c9c740
[#516] : CodeCarbon Dashboard content :
alencon ff3ea09
Merge branch 'feat/rework_cli' into fix-database-mal
alencon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -125,3 +125,6 @@ code_carbon.db | |
| # Local file | ||
| emissions*.csv* | ||
| tests/test_data/rapl/* | ||
|
|
||
| #asciinema | ||
| *.cast | ||
This file contains hidden or 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 hidden or 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 hidden or 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
149 changes: 149 additions & 0 deletions
149
carbonserver/carbonserver/database/scripts/spcc_purgeduplicatedata.sql
This file contains hidden or 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,149 @@ | ||
| /* | ||
| spname : spcc_purgedata | ||
| goal : create a tempory table to display records where there are any information on runs and emissions | ||
| delete all records linked by their key referenced uuid from an organizations unused. | ||
| date : 20240222 | ||
| version : 01 | ||
| comment : 01 : initialize procedure spcc_purgeduplicatedata | ||
| created by : MARC ALENCON | ||
| modified by : MARC ALENCON | ||
| */ | ||
|
|
||
| /* Comments & Comments : | ||
| sample for camille organization to delete : | ||
| Delete from public.experiments | ||
| where project_id in ('6a121901-5fa6-4e37-9ad8-8ec86941feb5'); | ||
|
|
||
| delete from public.projects | ||
| where team_id='d8e80b93-50f8-42fc-9280-650954415dbb'; | ||
|
|
||
| delete from teams | ||
| where organization_id='92570ce9-1f90-4904-b9e6-80471963b740'; | ||
|
|
||
| delete from organizations | ||
| where id ='92570ce9-1f90-4904-b9e6-80471963b740'; | ||
| */ | ||
|
|
||
| CREATE OR REPLACE PROCEDURE public.spcc_purgeduplicatedata() | ||
| LANGUAGE 'plpgsql' | ||
| AS $BODY$ | ||
|
|
||
| BEGIN -- Start of transaction | ||
|
|
||
| -- Création de la table temporaire | ||
| CREATE TEMP TABLE temp_table ( | ||
| nb int , | ||
| orga_id uuid , | ||
| team_id uuid , | ||
| project_id uuid , | ||
| experiment_id uuid , | ||
| run_id uuid , | ||
| emission_id uuid | ||
| ); | ||
|
|
||
|
|
||
| -- get distinct id from tables experiments , projects , teams , organizations | ||
| -- Insertion des données de la table source vers la table temporaire | ||
| INSERT INTO temp_table (nb, orga_id,team_id,project_id,experiment_id,run_id,emission_id ) | ||
| SELECT count(*) as nb , o.id as orga_id,t.id as team_id, p.id as project_id, e.id as experiment_id , r.id as run_id , em.id as emission_id | ||
| from public.organizations o | ||
| left outer join public.teams t on o.id=t.organization_id | ||
| left outer join public.projects p on t.id = p.team_id | ||
| left outer join public.experiments e on p.id = e.project_id | ||
| left outer join public.runs r on e.id = r.experiment_id | ||
| left outer join public.emissions em on r.id = em.run_id | ||
| where r.id is null and em.id is null | ||
| group by o.id,t.id, p.id,e.id,r.id ,em.id; | ||
|
|
||
|
|
||
| /* | ||
| select count(*) from temp_table -- 752 | ||
| select count(*) from experiments -- 1376 / 653 | ||
| select count(*) from projects -- 41 /21 | ||
| select count(*) from teams -- 26 /15 | ||
| select count(*) from organizations --25 /12 | ||
| */ | ||
|
|
||
| DO $$ | ||
| DECLARE | ||
| row_data RECORD; | ||
| -- variables techniques . | ||
| a_count integer; | ||
| v_state TEXT; | ||
| v_msg TEXT; | ||
| v_detail TEXT; | ||
| v_hint TEXT; | ||
| v_context TEXT; | ||
|
|
||
|
|
||
| BEGIN | ||
| GET DIAGNOSTICS a_count = ROW_COUNT; | ||
| RAISE NOTICE '------- START -------'; | ||
| FOR row_data IN SELECT orga_id, team_id,project_id,experiment_id,run_id,emission_id FROM temp_table LOOP | ||
|
|
||
| a_count = a_count +1; | ||
|
|
||
| --RAISE NOTICE '------- START -------'; | ||
| RAISE NOTICE 'The rows affected by A=%',a_count; | ||
| RAISE NOTICE 'Delete experiments which contains any runs affected'; | ||
| delete FROM public.experiments e | ||
| where e.id not in ( select r.experiment_id | ||
| from runs r | ||
| ) | ||
| and e.project_id =row_data.project_id; | ||
|
|
||
|
|
||
| RAISE NOTICE '--------------'; | ||
| RAISE NOTICE 'Delete projects which contains any experiments affected'; | ||
|
|
||
| delete FROM public.projects p | ||
| where p.id not in ( select e.project_id | ||
| from experiments e | ||
| ) | ||
| and p.team_id =row_data.team_id; | ||
|
|
||
|
|
||
| RAISE NOTICE '--------------'; | ||
| RAISE NOTICE 'Delete teams which contains any project affected '; | ||
| DELETE from teams t | ||
| where t.id not in (select p.team_id from projects p) | ||
| and t.organization_id =row_data.orga_id; | ||
|
|
||
|
|
||
|
|
||
| RAISE NOTICE '--------------'; | ||
| RAISE NOTICE 'Delete organizations which contains any teams affected'; | ||
| DELETE from organizations o | ||
| where o.id not in (select t.organization_id from teams t ) | ||
| and o.id = row_data.orga_id; | ||
|
|
||
| END LOOP; | ||
| RAISE NOTICE '-------- END ------'; | ||
| EXCEPTION | ||
| WHEN others THEN | ||
|
|
||
| -- Handling error:Cancelled transaction when error produced | ||
| ROLLBACK; | ||
| get stacked diagnostics | ||
| v_state = returned_sqlstate, | ||
| v_msg = message_text, | ||
| v_detail = pg_exception_detail, | ||
| v_hint = pg_exception_hint, | ||
| v_context = pg_exception_context; | ||
| RAISE NOTICE E'Got exception : | ||
| state : % | ||
| message : % | ||
| detail : % | ||
| hint : % | ||
| context : % ', v_state, v_msg, v_detail, v_hint, v_context ; | ||
| END $$; | ||
|
|
||
| DROP TABLE temp_table; | ||
|
|
||
| COMMIT; -- end of transaction | ||
| END; | ||
| $BODY$; | ||
|
|
||
|
|
||
|
|
||
|
|
||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -10,3 +10,4 @@ | |
| ) | ||
|
|
||
| __all__ = ["EmissionsTracker", "OfflineEmissionsTracker", "track_emissions"] | ||
| __app_name__ = "codecarbon" | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.