Skip to content

Commit

Permalink
Merge branch 'master' of github.com:data-workspaces/data-workspaces-core
Browse files Browse the repository at this point in the history
  • Loading branch information
jfischer committed Apr 9, 2019
2 parents be05060 + 70070b2 commit e9ba5b7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
21 changes: 19 additions & 2 deletions dataworkspaces/commands/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ def process_dir(dirpath):
elif f.endswith('_md.json'):
with open(p, 'r') as fobj:
data = json.load(fobj)
data['metric'] = None
data['value'] = None
# print("Data in get_snapshot_metadata = ", data)
rel_dest_path = data['relative_destination_path']
results_file = join(join(join(workspace, 'results'), rel_dest_path), 'results.json')
# print("results_file at ", results_file)
if os.path.exists(results_file):
with open(results_file, 'r') as rfile:
results_json = json.load(rfile)
metrics = results_json.get('metrics', None)
if metrics:
data['metric'] = next(iter(metrics.keys())) # get the first attribute from metrics
# we'll print this in the status summary
data['value'] = metrics[data['metric']]
yield data
md_path = get_snapshot_metadata_dir_path(workspace)
metadata = [data for data in process_dir(md_path)]
Expand All @@ -39,14 +53,17 @@ def run(self):
# num_snapshots = len(history)
history = get_snapshot_metadata(self.workspace_dir)
click.echo("\nHistory of snapshots")
click.echo("%s %s %s %s" %
click.echo("%s %s %s %s %s %s" %
('Hash'.ljust(8), 'Tags'.ljust(20), 'Created'.ljust(19),
'Metric'.ljust(32), 'Value'.ljust(32),
'Message'))
for v in history[0:self.limit] if self.limit is not None else history:
click.echo('%s %s %s %s' %
click.echo('%s %s %s %s %s %s' %
(v['hash'][0:7]+' ',
(', '.join(v['tags']) if v['tags'] is not None else 'N/A').ljust(20),
v['timestamp'][0:-7],
(v['metric'] if v['metric'] is not None else 'N/A').ljust(32),
(str(v['value']) if v['metric'] is not None else 'N/A').ljust(32),
v['message'] if v['message'] is not None and
v['message']!='' else 'N/A'))
num_shown = len(history) if self.limit is None \
Expand Down
8 changes: 0 additions & 8 deletions dataworkspaces/resources/rclone_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,6 @@ def results_move_current_files(self, rel_dest_root, exclude_files,
move_current_files_local_fs(self.name, self.local_path, rel_dest_root, exclude_files, exclude_dirs_re)

def snapshot(self):
# rsrcdir = os.path.abspath(self.workspace_dir + 'resources/' + self.role + '/' + self.name)
# h = hashtree.generate_hashes(self.rsrcdir, self.local_path, ignore=self.ignore)
# assert os.path.exists(os.path.join(self.rsrcdir, h))
# if is_git_staging_dirty(self.workspace_dir, subdir=self.rsrcdir_relative):
# call_subprocess([GIT_EXE_PATH, 'commit', '-m',
# "Add snapshot hash files for resource %s" % self.name],
# cwd=self.workspace_dir, verbose=False)
# return h
print("In snapshot: ", self.remote_name, self.remote_path, self.local_path)
if self.compute_hash:
(ret, out) = self.rclone.check(self.remote_origin, self.local_path, flags=['--one-way'])
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
click
mypy

0 comments on commit e9ba5b7

Please sign in to comment.