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

Draft:Add provenance functionality #1993

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open

Draft:Add provenance functionality #1993

wants to merge 34 commits into from

Conversation

kinow
Copy link
Member

@kinow kinow commented Dec 13, 2024

In GitLab by @apuiggro on Oct 28, 2024, 12:18

apuiggro and others added 20 commits October 2, 2024 10:24
* add CI and dependabot gh actions

* disable linting temporarily
* Autosubmit config version compatibility fix ( rebasing )

Reverting a conflict in the rebase to the other option II ( tests are only failing in the CI/CD )

Reverting a conflict in the rebase to the other option

updated typing

added a missing return

Changed err_code function to return the err_code

Rebase fix

Squashed zombies/orphan and database fixes.

PIPELINE

Fix doc test

Fix pipeline

Added comments and typing (II )

Added comments and typing

Test pipeline ( now with output)

Test pipeline

Update as version

Fix tests, added pytest-xdist

!475 vertical regression test

[Single job] Test working, retrials working

Changes to stat, db and retrials (WIP)

Added database test, fixed some issues

reduced time.sleeps

Mock exists() so it works in the pipeline

Fix events queue being reset in a platform failure

clean import

added more tests

Changed the timeout

removed debug message

Added tests for signals

cleanup code

Added cleanup signal

changes to signals and waitpid

A new orphan/zombies code approach

WIP: Looking good, some more fixes neccesaries and ready to be pushed

WIP: Zombies/orphan processors logs fix

* Pipeline failing, debug (I)

* Fix Stat_0 file being deleted when it shouldn't

* Fixed issues with the db and logs not being recovered in different run scenearios 

* Update VERSION

* added process_jobs_to_submit fixes runtime issue

* Added few todos that requires to change critical stuff

* Fix runtime issue, recovery now shows a better output

* Improved package test

* Improved package test

* Closing file descriptors on reconnect.

* Fixes an issue with logs with this sequence of commands: `create + run + create + recovery + run`

* Intregation test added, fixed few bugs

* Fixed DB test

* Now the db test also checks the stat and job_names in the filesystem

* feedback

* Changed test name,
Added generic functions in the test to expand it with other run options

* Added few todos

* disabled the check exit code as it is not working on the pipeline and not important right now

* Adding more chunks to the wrapper success

* More detailed test

* Add CI and dependabot GitHub actions (#2021)

* add CI and dependabot gh actions

* disable linting temporarily

(cherry picked from commit 8a1b2df)

* Improved test output in case of failure

* more info

* more info

* Test adding +x

* added chmod after sending

* chmod added

---------

Co-authored-by: dbeltran <daniel.beltran@bsc.es>
Co-authored-by: Luiggi Tenorio <luiggibit@gmail.com>

---------

Co-authored-by: dbeltran <daniel.beltran@bsc.es>
Co-authored-by: Luiggi Tenorio <luiggibit@gmail.com>

---------

Co-authored-by: dbeltran <daniel.beltran@bsc.es>
Co-authored-by: Luiggi Tenorio <luiggibit@gmail.com>
* Added notify_on

* added update_stat_file() (wrong rebase)

---------

Co-authored-by: dbeltran <daniel.beltran@bsc.es>
* Fix issue with the wrapper attribute

* Fix issue with the wrapper attribute
* Fixes wrapper warning message at the end

* Added typing suggestion
Copy link
Member Author

@kinow kinow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry the delay in reviewing this, @apuiggro . Left some comments & suggestions. Can you rebase again, please.

.gitignore Outdated
@@ -26,3 +26,6 @@ dockerfiles/id_rsa*
dockerfiles/authorized_keys

venv/

#metadata
metadata/
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this ignore necessary to build the project? Or was it used for some local test? if it's not part of the AS build then it's better to not include it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just saw you have a metadata/data/job_data_a000.sql file in this change. I think you need to configure AS to write metadata in another directory. Can you remove that file if that's not needed for this PR?

@@ -555,8 +556,13 @@ def create_rocrate_archive(
patch = json.loads(rocrate_json['PATCH'])
for jsonld_node in patch['@graph']:
crate.add_or_update_jsonld(jsonld_node)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary extra spaces ☝️

#zip is defined in this function so all the (modified) code should be moved here. Still, I'm exploring other posibilites
#to query the las modified time within this function (Not very used to the code still...)
date = time.strftime("%Y%m%d%H%M%S", time.localtime(os.path.getmtime(path)))
crate.write_zip(Path(path, f"{expid}-{date}.zip"))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be safer to go with the local time. The time the command was run.

Similar to how it's done in other commands like profiler, report, etc.:

datetime.datetime.today().strftime('%Y%m%d-%H%M%S')

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okey! Should I leave it this way then?

date = datetime.datetime.today().strftime('%Y%m%d-%H%M%S')

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup!

@@ -649,7 +655,7 @@ def parse_args():
subparser.add_argument('-v', '--update_version', action='store_true',
default=False, help='Update experiment version')
subparser.add_argument('--rocrate', action='store_true', default=False,
help='Unarchive an RO-Crate file')
help='Unarchive an RO-Crate file')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙆‍♂️ thanks!

@@ -2266,7 +2274,7 @@ def run_experiment(expid, notransitive=False, start_time=None, start_after=None,
job_list.update_list(as_conf, submitter=submitter)
job_list.save()
# Submit jobs that are ready to run
#Log.debug(f"FD submit: {fd_show.fd_table_status_str()}")
#Log.debug(f"FD submit: {fd_show.fd_table_status_str()}")run_experiment
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was it a test? Maybe remove the run_experiment (I think this might be used by dani for tesing -- although this can probably be refactored/removed in the future).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmm... I believe I haven't added that (at least intentionally). I'll remove it :).

:type expid: str
:param rocrate: flag to enable RO-Crate
:type rocrate: bool
"""""
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too many quotes here. It's just three or one 🙂

f"Error creating RO-Crate ZIP file: {str(e)}", 7012)
else:
raise AutosubmitCritical(
"Can not create RO-Crate ZIP file. Argument '--rocrate' required", 7012)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can invert the logic here, so that we don't create the Path unnecessarily, and leave the validation/constraint logic first, followed by the main logic. Something like,

    @staticmethod
    def provenance(expid, rocrate=False): 
        """
        :param expid: experiment identifier
        :type expid: str
        :param rocrate: flag to enable RO-Crate
        :type rocrate: bool
        """
        if not rocrate:
            msg = "Can not create RO-Crate ZIP file. Argument '--rocrate' required"
            raise AutosubmitCritical(msg, 7012)

        aslogs_folder = Path(
            BasicConfig.LOCAL_ROOT_DIR,
            expid,
            BasicConfig.LOCAL_TMP_DIR,
            BasicConfig.LOCAL_ASLOG_DIR
        )

        try:
            Autosubmit.rocrate(expid, Path(aslogs_folder))
            Log.info('RO-Crate ZIP file created!')
        except Exception as e:
            raise AutosubmitCritical(f"Error creating RO-Crate ZIP file: {str(e)}", 7012)

Autosubmit.provenance("expid123", rocrate=False)

assert "Can not create RO-Crate ZIP file. Argument '--rocrate' required" in str(excinfo)
mock_rocrate.assert_not_called()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to have 2 spaces between each top-level function. My IDE warns when this happens, but linters like pep8/ruff/etc.

image

from autosubmit.autosubmit import Autosubmit
from log.log import AutosubmitCritical
import os
from unittest.mock import patch
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are using VS Code or PyCharm they should have the option to automatically sort the imports (we will enable this in CICD later). In PyCharm there is the option when you right-click a file, "Optimize Imports".

image

@@ -0,0 +1,59 @@
import pytest
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests look great! The rocrate function is already covered, so good strategy to only cover the parts missing 👍

@kinow kinow mentioned this pull request Dec 27, 2024
@codecov-commenter
Copy link

codecov-commenter commented Jan 3, 2025

Codecov Report

Attention: Patch coverage is 62.06897% with 132 lines in your changes missing coverage. Please review.

Please upload report for BASE (master@0e6032c). Learn more about missing BASE report.

Files with missing lines Patch % Lines
autosubmit/platforms/platform.py 38.18% 34 Missing ⚠️
autosubmit/autosubmit.py 64.15% 14 Missing and 5 partials ⚠️
autosubmit/platforms/wrappers/wrapper_factory.py 45.45% 18 Missing ⚠️
autosubmit/platforms/slurmplatform.py 25.00% 15 Missing ⚠️
autosubmit/job/job_list.py 54.83% 7 Missing and 7 partials ⚠️
autosubmit/job/job.py 85.50% 8 Missing and 2 partials ⚠️
autosubmit/job/job_packager.py 64.28% 7 Missing and 3 partials ⚠️
autosubmit/platforms/paramiko_platform.py 58.33% 2 Missing and 3 partials ⚠️
autosubmit/platforms/ecplatform.py 50.00% 2 Missing ⚠️
autosubmit/platforms/sgeplatform.py 0.00% 2 Missing ⚠️
... and 3 more
Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1993   +/-   ##
=========================================
  Coverage          ?   48.92%           
=========================================
  Files             ?       72           
  Lines             ?    17564           
  Branches          ?     3418           
=========================================
  Hits              ?     8594           
  Misses            ?     8161           
  Partials          ?      809           
Flag Coverage Δ
fast-tests 48.92% <62.06%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@apuiggro
Copy link
Contributor

apuiggro commented Jan 3, 2025

Hi @kinow,

Rebase finished! I believe all the issues are solved. Let me know if there is any other problem.

Thankss

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants