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

add log_tuples function #1896

Merged
merged 5 commits into from
Jun 6, 2022
Merged

Conversation

kk1050
Copy link
Contributor

@kk1050 kk1050 commented May 27, 2022

ARTIQ Pull Request

Description of Changes

add log_tuples function which can write the runid, start_time and path to a file in the data directory

Related Issue

Log runid/start_time/path tuples to a file in the data directory #810

Type of Changes

Type
✨ New feature

Steps (Choose relevant, delete irrelevant before submitting)

All Pull Requests

  • Use correct spelling and grammar.
  • Close/update issues.
  • Check the copyright situation of your changes and sign off your patches (git commit --signoff, see copyright).

Code Changes

  • Test your changes or have someone test them. Mention what was tested and how.

Git Logistics

  • Split your contribution into logically separate changes (git rebase --interactive). Merge/squash/fixup commits that just fix or amend previous commits. Remove unintended changes & cleanup. See tutorial.
  • Write short & meaningful commit messages. Review each commit for messages (git show). Format:
    topic: description. < 50 characters total.
    add log_tuples function
    
    Longer description. < 70 characters per line
    

Licensing

See copyright & licensing for more info.
ARTIQ files that do not contain a license header are copyrighted by M-Labs Limited and are licensed under LGPLv3+.

@@ -342,7 +347,7 @@ def write_results():
try:
exp_inst.analyze()
put_completed()
finally:
finally:
Copy link
Member

Choose a reason for hiding this comment

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

clean up

@@ -286,6 +286,10 @@ def write_results():
f["run_time"] = run_time
f["expid"] = pyon.encode(expid)

def log_tuples():
with open("tuples.txt", "a") as f:
f.write("%s %s %s\n" %(rid, start_time, expid["file"]))
Copy link
Member

@sbourdeauducq sbourdeauducq May 27, 2022

Choose a reason for hiding this comment

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

use new style format "".format()"

@sbourdeauducq
Copy link
Member

"tuples" is too generic of a name. https://en.wikipedia.org/wiki/Tuple

@sbourdeauducq
Copy link
Member

What happens if multiple experiments are executed at the same time? This can happen if they are scheduled in different pipelines. Can't that corrupt the file?
Might be safer/simpler to write to the file from the scheduler where operations are done sequentially.

@@ -286,6 +286,10 @@ def write_results():
f["run_time"] = run_time
f["expid"] = pyon.encode(expid)

def log_tuples():
with open("tuples.txt", "a") as f:
Copy link
Member

Choose a reason for hiding this comment

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

The current directory of the experiment may be subject to change (see discussions in #1747, #1543).
Would be more future-proof to put it where the master writes other files such as last_rid.pyon.

*Chang the file name
* Write to the file from the scheduler
@@ -122,6 +122,13 @@ def __init__(self, ridc, worker_handlers, notifier, experiment_db):
self.notifier = notifier
self.experiment_db = experiment_db

def log_tuples(self, rid, expid):
Copy link
Member

Choose a reason for hiding this comment

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

"Tuples" is not a good name in functions either. What about log_submissions?

self.rid = rid
self.expid = expid
start_time = time()
with open("rid_time_path.txt", "a") as f:
Copy link
Member

Choose a reason for hiding this comment

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

experiment_submissions.log as a default file name would be better. And make that logging optional and the file name configurable via the command line arguments.

Copy link
Member

Choose a reason for hiding this comment

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

Or even .csv with , as separator?

* make the file name configurable
@@ -53,7 +53,10 @@ def get_argparser():
"--experiment-subdir", default="",
help=("path to the experiment folder from the repository root "
"(default: '%(default)s')"))

group.add_argument(
"--log-filename", default="experiment_submissions.csv",
Copy link
Member

Choose a reason for hiding this comment

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

Please keep disabled by default

@@ -53,7 +53,10 @@ def get_argparser():
"--experiment-subdir", default="",
help=("path to the experiment folder from the repository root "
"(default: '%(default)s')"))

group.add_argument(
"--log-filename", default="experiment_submissions.csv",
Copy link
Member

Choose a reason for hiding this comment

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

Please keep disabled by default

help=("set the filename of the experiment subimission "
"(default: '%(default)s')"))
"--log-filename", default=None,
help=("(optional) set the filename to create the experiment subimission "))
Copy link
Member

Choose a reason for hiding this comment

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

grammar, typo, space at the end

Copy link
Member

@sbourdeauducq sbourdeauducq Jun 2, 2022

Choose a reason for hiding this comment

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

And I don't think we want this in the "repository" options group. Suggest putting it at the top level like --name

Comment on lines 128 to 129
self.rid = rid
self.expid = expid
Copy link
Member

@sbourdeauducq sbourdeauducq Jun 2, 2022

Choose a reason for hiding this comment

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

Why write to self?

self.rid = rid
self.expid = expid
start_time = time()
if self.log_filename != None:
Copy link
Member

Choose a reason for hiding this comment

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

is not None

@@ -135,6 +146,7 @@ def submit(self, expid, priority, due_date, flush, pipeline_name):
wd, repo_msg = None, None
run = Run(rid, pipeline_name, wd, expid, priority, due_date, flush,
self, repo_msg=repo_msg)
self.log_submissions(rid, expid)
Copy link
Member

Choose a reason for hiding this comment

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

log_submission, singular

@@ -90,7 +90,7 @@ def setUp(self):

def test_steps(self):
loop = self.loop
scheduler = Scheduler(_RIDCounter(0), dict(), None)
scheduler = Scheduler(_RIDCounter(0), dict(), None, "experiment_submissions.csv")
Copy link
Member

Choose a reason for hiding this comment

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

If you're not reading the file in the test, then don't write it and set it to None. You could just use None as default value in the Scheduler's parameter, then it's backward-compatible and you don't need to edit the test and potentially other code.

@@ -53,7 +53,9 @@ def get_argparser():
"--experiment-subdir", default="",
help=("path to the experiment folder from the repository root "
"(default: '%(default)s')"))

group.add_argument(
"--log-filename", default=None,
Copy link
Member

Choose a reason for hiding this comment

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

There are already other "logging" options in the master and this is confusing. --log-submissions?

*Remove the typos and 'self'
*Rename the function and argument
*Set the variable to None in test file
@sbourdeauducq sbourdeauducq merged commit 4ddd273 into m-labs:master Jun 6, 2022
@sbourdeauducq
Copy link
Member

Oops, should have renamed the commit

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.

3 participants