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

Issue1036 #70

Merged
merged 56 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
d810744
Introduce past and future terminology.
ClemensBuechner May 10, 2023
55bd7ea
Fix basic progression of past landmarks.
ClemensBuechner May 10, 2023
5514517
Add use_obedient_reasonable option to reasonable orders factory.
ClemensBuechner May 10, 2023
9605cc4
Remove goal check which is no longer necessary.
ClemensBuechner May 11, 2023
20320bb
Introduce future landmarks and implement ordering progressions.
ClemensBuechner May 11, 2023
840dff1
Update landmark status correctly.
ClemensBuechner May 11, 2023
4b0f934
Add experiments.
ClemensBuechner May 11, 2023
a505fdf
Fix style.
ClemensBuechner May 11, 2023
e1214fe
Remove landmark status as detour to get to past and future information.
ClemensBuechner May 11, 2023
f5eb820
Add experiments v4.
ClemensBuechner May 11, 2023
6cdad46
Add comma.
ClemensBuechner May 12, 2023
ca0c8c3
Implement suggestions from code review.
ClemensBuechner May 12, 2023
b8802f9
Fix conditions for computing cost partitionings.
ClemensBuechner May 12, 2023
8970d66
Prettify and implement more review comments.
ClemensBuechner May 12, 2023
af13cd7
Clarify heuristic computation.
ClemensBuechner May 15, 2023
fc115f6
Consider only relevant landmarks and orderings when progressing.
ClemensBuechner May 15, 2023
ea174db
Change default for obedient-reasonable orderings.
ClemensBuechner May 15, 2023
e91c1c1
Fix greedy-necessary ordering progression.
ClemensBuechner May 15, 2023
bad208e
Add experiments v5.
ClemensBuechner May 15, 2023
0166af9
Fix style.
ClemensBuechner May 15, 2023
85e9687
Remove some tests.
ClemensBuechner May 16, 2023
07f55c1
Change IDs to pointers.
ClemensBuechner May 16, 2023
645297b
Append goal progression to basic progression.
ClemensBuechner May 17, 2023
3a9f03c
Expand comments and speed-up ordering progressions.
ClemensBuechner May 22, 2023
a3a2865
Add experiments.
ClemensBuechner May 22, 2023
83f7c23
Remove lm_is_p/f(id,state), instead add ConstBitsetView get_p/f_lms(s…
salome-eriksson Jun 13, 2023
c95b593
Add experiments v7.
salome-eriksson Jun 13, 2023
4151913
Update terminology.
ClemensBuechner Jun 13, 2023
b7fea6c
Fix style.
ClemensBuechner Jun 13, 2023
fcba1e2
Split basic and goal progression and make explicitly adding a require…
ClemensBuechner Jun 14, 2023
7e791a7
Add experiments.
ClemensBuechner Jun 14, 2023
d2c8587
Fix style.
ClemensBuechner Jun 14, 2023
8b3fae0
Allow reasonable orders for optimal planning.
ClemensBuechner Jun 14, 2023
fdae6cc
Add experiment for optimal configs.
ClemensBuechner Jun 14, 2023
4d426fa
Relax progression criterion again.
ClemensBuechner Jun 14, 2023
5e98f08
Add experiments.
ClemensBuechner Jun 14, 2023
9c96fb9
Fix goal progression condition.
ClemensBuechner Jun 16, 2023
2d44934
Add experiments.
ClemensBuechner Jun 16, 2023
d97fb70
Add base-optimal experiment.
ClemensBuechner Jun 20, 2023
5976a65
Clean up comments.
ClemensBuechner Jun 22, 2023
8ce827b
Write out future instead of fut.
ClemensBuechner Jul 9, 2023
a539730
Avoid redundant loop.
ClemensBuechner Jul 9, 2023
b01a757
Move comment.
ClemensBuechner Jul 9, 2023
49099be
Remove option for obedient-reasonable orderings.
ClemensBuechner Jul 9, 2023
0b1c9d0
Swap parameter ordering.
ClemensBuechner Jul 9, 2023
d09e915
Add page numbers to reference.
ClemensBuechner Jul 15, 2023
ffed417
Remove experiments.
ClemensBuechner Jul 17, 2023
daeb1b0
Fix style.
ClemensBuechner Jul 17, 2023
a368089
Implement more ideomatic way to deal with const bitset views.
ClemensBuechner Jul 21, 2023
7e2f02b
Clean up initial state progression.
ClemensBuechner Jul 21, 2023
d70f0ee
Rename progress_basic to progress_landmarks.
ClemensBuechner Jul 21, 2023
d408e28
Remove document note about obedient-reasonable orderings.
ClemensBuechner Jul 21, 2023
364c96d
Clarify initial state progression further.
ClemensBuechner Jul 21, 2023
8fe44d2
Clarify comment.
ClemensBuechner Jul 21, 2023
9a11e00
Merge branch 'main' into issue1036.
ClemensBuechner Jul 21, 2023
d3a1e1e
Merge branch 'main' into issue1036.
ClemensBuechner Aug 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 124 additions & 0 deletions experiments/issue1036/archive.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
from pathlib import Path
ClemensBuechner marked this conversation as resolved.
Show resolved Hide resolved
import subprocess
import tarfile
from tempfile import TemporaryDirectory

ARCHIVE_HOST = "aifiles"
ARCHIVE_LOCATION = Path("experiments")

def add_archive_step(exp, path):
"""
Adds a step to the given experiment that will archive it to the
archive location specified in ARCHIVE_LOCATION und the given path.
We archive the following files:
- everything in the same directory as the main experiment script
(except for 'data', '.venv', and '__pycache__')
- all generated reports
- the combined properties file
- all run and error logs
- the source code stored in the experiment data directory
- any files added as resources to the experiment

The first two items in the above list will be stored unpacked for easier
access while all otherdata will be packed.
"""
def archive():
archive_path = ARCHIVE_LOCATION / path
_archive_script_dir(exp, ARCHIVE_HOST, archive_path)
_archive_eval_dir(exp, ARCHIVE_HOST, archive_path)
_archive_data_dir(exp, ARCHIVE_HOST, archive_path)

exp.add_step("archive", archive)


def add_archive_eval_dir_step(exp, path):
"""
Adds a step to the given experiment that will archive its eval dir to the
archive location specified in ARCHIVE_LOCATION und the given path.
This includes:
- all generated reports
- the combined properties file

To also archive logs, scripts, and source code, use add_archive_step.
"""
def archive():
archive_path = ARCHIVE_LOCATION / path
_archive_eval_dir(exp, ARCHIVE_HOST, archive_path)

exp.add_step("archive-eval-dir", archive)


def _archive_script_dir(exp, host, archive_path):
"""
Archives everything except 'data', '.venv', and '__pycache__' from the
same directory as the experiment script at host:archive_path/scripts.
"""
script_dir = Path(exp._script).parent
target_path = archive_path / "scripts"

script_files = [f for f in script_dir.glob("*")
if f.name not in ["data", ".venv", "venv", "__pycache__"]]
_rsync(script_files, host, target_path)


def _archive_data_dir(exp, host, archive_path):
"""
Packs all files we want to archive from the experiment's data directory and
then archives the packed data at host:archive_path/data. Specifically, the
archived files are:
- all files directly in the data dir (added resources such as parsers)
- all directories starting with "code_" (source code of all revisions and
the compilied binaries)
- All *.log and *.err files from the run directories
"""
data_dir = Path(exp.path)
target_path = archive_path / "data"

data_files = [f for f in data_dir.glob("*") if f.is_file()]
data_files.extend([d for d in data_dir.glob("code-*") if d.is_dir()])
data_files.extend(data_dir.glob("runs*/*/*.log"))
data_files.extend(data_dir.glob("runs*/*/*.err"))
with TemporaryDirectory() as tmpdirname:
packed_filename = Path(tmpdirname) / (exp.name + ".tar.xz")
_pack(data_files, packed_filename, Path(exp.path).parent)
_rsync([packed_filename], host, target_path)


def _archive_eval_dir(exp, host, archive_path):
"""
Archives all files in the experiment's eval dir.
If there is a properties file, it will be packed and only the
packed version will be included in the resulting list.
"""
eval_dir = Path(exp.eval_dir)
target_path = archive_path / "data" / eval_dir.name

filenames = list(eval_dir.glob("*"))
properties = eval_dir / "properties"
if properties.exists():
filenames.remove(properties)
with TemporaryDirectory() as tmpdirname:
packed_properties = Path(tmpdirname) / "properties.tar.xz"
_pack([properties], packed_properties, eval_dir)
_rsync([packed_properties], host, target_path)
_rsync(filenames, host, target_path)


def _pack(filenames, archive_filename, path_prefix):
"""
Packs all files given in filenames into an archive (.tar.xz) located at
archive_filename. The path_prefix is removed in the archive, i.e.,
if the filename is '/path/to/file' and the prefix is '/path', the location
inside the archive will be 'to/file'.
"""
with tarfile.open(archive_filename, "w|xz") as f:
for name in filenames:
f.add(name, name.relative_to(path_prefix))

def _rsync(filenames, host, target_path):
# Before copying files we have to create the target path on host.
# We could use the rsync option --mkpath but it is only available in newer
# rsync versions (and not in the one running on the grid)
# https://stackoverflow.com/questions/1636889
subprocess.run(["ssh", host, "mkdir", "-p", target_path])
subprocess.run(["rsync", "-avz"] + [str(f) for f in filenames] + [f"{host}:{target_path}"])
Loading