Skip to content

New Logger#464

Merged
pelillian merged 81 commits intomasterfrom
newer-logger
Mar 23, 2019
Merged

New Logger#464
pelillian merged 81 commits intomasterfrom
newer-logger

Conversation

@pelillian
Copy link
Copy Markdown
Contributor

@pelillian pelillian commented Jan 18, 2019

Created new logger API & updated all references to use the new system.

Many commits were required to be squashed into 96afc22 for rebasing

@pelillian pelillian requested a review from a team as a code owner January 18, 2019 01:19
@pelillian pelillian requested review from a user, naeioi and ryanjulian January 18, 2019 01:20
@pelillian pelillian mentioned this pull request Jan 18, 2019
@pelillian
Copy link
Copy Markdown
Contributor Author

#33

Comment thread garage/envs/mujoco/randomization/variation.py Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 18, 2019

Codecov Report

Merging #464 into master will decrease coverage by 0.45%.
The diff coverage is 57.43%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #464      +/-   ##
==========================================
- Coverage    62.9%   62.44%   -0.46%     
==========================================
  Files         182      185       +3     
  Lines       12169    11927     -242     
==========================================
- Hits         7655     7448     -207     
+ Misses       4514     4479      -35
Impacted Files Coverage Δ
garage/config.py 80.43% <ø> (-0.42%) ⬇️
garage/misc/autoargs.py 32% <0%> (ø) ⬆️
garage/logger/utils.py 0% <0%> (ø)
garage/logger/__init__.py 100% <100%> (ø)
garage/sampler/parallel_sampler.py 65.67% <100%> (-0.51%) ⬇️
garage/tf/algos/batch_polopt.py 93.54% <100%> (-0.07%) ⬇️
garage/algos/cem.py 94.44% <100%> (-0.11%) ⬇️
garage/envs/mujoco/hill/hill_env.py 84.93% <100%> (ø) ⬆️
garage/tf/regressors/gaussian_mlp_regressor.py 79.5% <100%> (-0.34%) ⬇️
garage/tf/algos/npo.py 99.01% <100%> (-0.04%) ⬇️
... and 49 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f33a03e...4975623. Read the comment docs.

@coveralls
Copy link
Copy Markdown

coveralls commented Jan 18, 2019

Coverage Status

Coverage decreased (-0.2%) to 63.144% when pulling 3625e64 on newer-logger into 369d5b1 on master.

@pelillian
Copy link
Copy Markdown
Contributor Author

pelillian commented Jan 18, 2019

@ryanjulian
For some reason Travis is giving me the following errors:
E0401: 8,0: Unable to import 'theano.tensor'
E0401: 16,0: Unable to import 'baselines.bench'

Any ideas what's going on?

@naeioi
Copy link
Copy Markdown
Member

naeioi commented Jan 18, 2019

Could you give a brief on the design of new logger and also an example script to illustrate the basic usage?

@pelillian pelillian requested a review from krzentner January 18, 2019 02:13
@CatherineSue
Copy link
Copy Markdown
Member

@ryanjulian
For some reason Travis is giving me the following errors:
E0401: 8,0: Unable to import 'theano.tensor'
E0401: 16,0: Unable to import 'baselines.bench'

Any ideas what's going on?

I have met the similar error here. But I met this error in local pre-commit. I updated the garage env then solved the problem.

@naeioi
Copy link
Copy Markdown
Member

naeioi commented Jan 18, 2019

@ryanjulian
For some reason Travis is giving me the following errors:
E0401: 8,0: Unable to import 'theano.tensor'
E0401: 16,0: Unable to import 'baselines.bench'
Any ideas what's going on?

I have met the similar error here. But I met this error in local pre-commit. I updated the garage env then solved the problem.

Can you elaborate on how to update garage env? Do you mean reinstall deps in environment.yml?

@CatherineSue
Copy link
Copy Markdown
Member

@ryanjulian
For some reason Travis is giving me the following errors:
E0401: 8,0: Unable to import 'theano.tensor'
E0401: 16,0: Unable to import 'baselines.bench'
Any ideas what's going on?

I have met the similar error here. But I met this error in local pre-commit. I updated the garage env then solved the problem.

Can you elaborate on how to update garage env? Do you mean reinstall deps in environment.yml?

conda env update -n garage

Copy link
Copy Markdown
Contributor

@krzentner krzentner left a comment

Choose a reason for hiding this comment

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

This is a pretty large change, but mostly not scary.
You added a bunch of noqa, which kinda defeats the point of using flake8. I was going to tell you to fix them, but then I found that they mostly don't appear to be necessary.

I have good tooling to fix this, so I just added a commit which fixes them. Please pull it before making more changes. I didn't fix the test/ directory, since that didn't really seem as important.

The rest of the comments are hopefully pretty minor? Let me know if you have questions, as always.

Comment thread garage/envs/mujoco/ant_env.py Outdated
Comment thread garage/algos/batch_polopt.py Outdated
Comment thread garage/baselines/linear_feature_baseline.py Outdated
Comment thread garage/misc/autoargs.py Outdated
Comment thread garage/misc/tabulate.py Outdated
Comment thread garage/misc/logger/singleton_tabular.py Outdated
Comment thread garage/misc/logger/singleton_logger.py Outdated
Comment thread garage/misc/logger/logger_utils.py Outdated
Comment thread garage/misc/logger/logger_utils.py Outdated
Comment thread garage/misc/logger/logger_utils.py Outdated
Copy link
Copy Markdown
Member

@jonashen jonashen left a comment

Choose a reason for hiding this comment

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

Just a general question, is there a reason why we have logger under misc instead of it being standalone? i.e. garage.misc.logger instead of garage.logger?

Comment thread examples/tf/example_tensorboard_logger.py Outdated
Comment thread garage/envs/mujoco/maze/maze_env.py Outdated
Comment thread tests/benchmarks/test_benchmark_her.py Outdated
Comment thread tests/fixtures/tf/instrumented_npo.py Outdated
Comment thread tests/garage/tf/policies/test_gaussian_policies.py Outdated
@pelillian
Copy link
Copy Markdown
Contributor Author

Just a general question, is there a reason why we have logger under misc instead of it being standalone? i.e. garage.misc.logger instead of garage.logger?

@krzentner @ryanjulian What do you think about this?

@pelillian
Copy link
Copy Markdown
Contributor Author

This is a pretty large change, but mostly not scary.
You added a bunch of noqa, which kinda defeats the point of using flake8. I was going to tell you to fix them, but then I found that they mostly don't appear to be necessary.

I have good tooling to fix this, so I just added a commit which fixes them. Please pull it before making more changes. I didn't fix the test/ directory, since that didn't really seem as important.

The rest of the comments are hopefully pretty minor? Let me know if you have questions, as always.

@krzentner
Thanks a million! What tooling do you use, if you don't mind my asking? I had tried autopep8 and a couple other tools, yet they seem to differ somewhat from what garage wants.

@ryanjulian
Copy link
Copy Markdown
Member

Just a general question, is there a reason why we have logger under misc instead of it being standalone? i.e. garage.misc.logger instead of garage.logger?

@krzentner @ryanjulian What do you think about this?

Put it in garage.logger

@ryanjulian
Copy link
Copy Markdown
Member

This is a pretty large change, but mostly not scary.
You added a bunch of noqa, which kinda defeats the point of using flake8. I was going to tell you to fix them, but then I found that they mostly don't appear to be necessary.
I have good tooling to fix this, so I just added a commit which fixes them. Please pull it before making more changes. I didn't fix the test/ directory, since that didn't really seem as important.
The rest of the comments are hopefully pretty minor? Let me know if you have questions, as always.

@krzentner
Thanks a million! What tooling do you use, if you don't mind my asking? I had tried autopep8 and a couple other tools, yet they seem to differ somewhat from what garage wants.

You have to make sure to use our configurations with automated tools. They live in setup.cfg

Comment thread garage/misc/logger/__init__.py Outdated
Comment thread garage/misc/logger/logger_outputs.py Outdated
Comment thread garage/misc/logger/logger_outputs.py Outdated
Comment thread garage/misc/logger/logger_outputs.py Outdated
Comment thread garage/misc/logger/logger_outputs.py Outdated
Comment thread garage/misc/logger/logger_utils.py Outdated
Comment thread garage/misc/logger/singleton_logger.py Outdated
Comment thread garage/misc/tabulate.py Outdated
Comment thread garage/misc/logger/singleton_tabular.py Outdated
Comment thread garage/misc/logger/tensorboard_output.py Outdated
Comment thread scripts/run_experiment.py Outdated
Comment thread scripts/travisci/check_flake8.sh Outdated
@krzentner
Copy link
Copy Markdown
Contributor

@krzentner
Thanks a million! What tooling do you use, if you don't mind my asking? I had tried autopep8 and a couple other tools, yet they seem to differ somewhat from what garage wants.

I'm not sure if there's any fully automated tooling which works with our current linters. My workflow (which I've used across lots of environments / teams / companies) is basically:

  • Run the linter to find failures (e.g. flake8).
  • Filter them down to a single failure type (e.g. flake8 --select=F401).
  • Pipe them all into (n)vim (e.g. flake8 --format="+%(row)s %(path)s" --select=F401 | xargs -L 1 nvim).
  • Write a vim macro which fixes the error.
  • Spam the macro and :x or :bNext until all the files are fixed.

Obviously, a fully automated tooling solution is preferred, but this workflow has served me well for making formatting fixes and refactorings.

@pelillian pelillian self-assigned this Jan 22, 2019
Comment thread garage/__init__.py Outdated
Comment thread garage/logger/__init__.py Outdated
Comment thread garage/logger/outputs.py Outdated
Comment thread garage/logger/snapshotter.py Outdated
Comment thread garage/logger/snapshotter.py Outdated
Comment thread garage/logger/singleton_logger.py Outdated
Comment thread garage/logger/singleton_logger.py Outdated
Comment thread garage/logger/outputs.py Outdated
Comment thread garage/logger/outputs.py Outdated
Comment thread garage/logger/singleton_logger.py Outdated
pelillian and others added 14 commits March 21, 2019 19:50
* Renames TensorBoard logging files and tests to follow convention
* Changes Histogram* types in garage.logger.tensorboard_inputs to
  simpler names in garage.logger.distributions
* Move LogOutput base class to `garage.logger.logger`, so that the
  entire API is in one place
* Rename `garage.logger.outputs` to `simple_outputs` to better reflect
  its purpose
* Moves tests for simple_outputs to test_simple_outputs
* Makes proper use of temporary files
* Replace TensorBoardOutput with tensorboardX.
* Add unittest for TensorBoardOutput.
* Delete tensor log as it is too complex and not used anywhere right
  now.
* Rebase with origin/HEAD.
* garage.experiment.run_experiment didn't add `StdOutput`. Fixed.
* `TextOutput` doesn't support `TabularInput`. This would make
  `TextOutput` useless as it doesn't log algorithm information any more.
  Therefore I prefer we added `TabularInput` in `TextOutput`.
* Sort tabular in alphabetical order.
* Fix that `TabularInput.as_primitive_dict` doesn't log `np.float32`.
* snapshotter fails because `Snapshotter._snapshot_dir=None` and
 `snapshot_dir.setter` calls `mkdir_p` which doesn't support NoneType.
 Fixed this.
* Rewrites parts of TensorBoardLogger
* Tests TensorBoardLogger with mocks
* Makes proper use of the dump() API
* Modifies LocalRunner to use dump()
* Updates tests which no longer need the logger
* Updates test fixtures to use NullOutput
* Add TabularInput support to TextOutput
* Detects and warns when TabularInput values are not logged
* Move NullOutput to tests.fixtures
* Refactor Snapshotter unittests
* Delete duplicate log line in tf/DDPG
* Fix flake8 complaints
* Fix CsvOutput bug. For some off policy algorithms that use replay
  buffer, there is usually a min buffer size. It means the algorithms
  won't start training until it has sampled min-buffer-size samples.
  But CsvOutput set `CsvOutput._fieldnames` from the beginning, which is
  empty in this case. Later when data is not empty, it will raise
  Inconsistent TabularInput keys warning. Fix this by only start to set
  `CsvOutput._writer` when `to_csv.keys()` is not None.
@CatherineSue CatherineSue force-pushed the newer-logger branch 3 times, most recently from 6531e46 to 1006a68 Compare March 22, 2019 08:39
* Add more CsvOutput and Logger tests. The logger module now reaches 98%
  coverage.
* Delete `with tf.Session()` in TensorboardOutput test as a session is
  created in setUp.
* There is a bug in TfTestCase and TfGraphTestVase that leaves dangling
  tf.Session. tf.Session.close() releases all the resources associated
  within the session. However, the default session context manage still
  refers to the session. Thus, when setUp is called next time, it
  creates another session. As a result, the graph is nested. And when
  tests.garage.experiment.test_snapshit.reset_tf() is called, it only
  exits the most nestted session. Then it calls tf.reset_default_graph()
  and raises error because the graph is still nested.
  An easy fix would be adding `self.sess.__exit__()` to
  TfTestCase.tearDown().
  However, it gets mixed up with LocalRunner. When we pass a `self.sess`
  to LocalTfRunner, LocalTfRunner will set the sess as the default
  session. And delete it when LocalTfRunner exits. Then we can't call
  `self.sess.__exit__()` anymore as it has already been deleted.
  To fix this, I assume that we always use LocalTfRunner along with the
  with statement, and I used an if check to decide whether call
  `self.sess.__exit__()` or not.
def __init__(self, file_name, with_timestamp=True):
super().__init__(file_name, 'a')
self._with_timestamp = with_timestamp
self._delimiter = " | "
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

single quote


def __init__(self, file_name, mode='w'):
mkdir_p(os.path.dirname(file_name))
self._log_file = open(file_name,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

probably less awkward for the comment to go above this line

Copy link
Copy Markdown
Member

@ryanjulian ryanjulian left a comment

Choose a reason for hiding this comment

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

Great work, everyone

@pelillian pelillian merged commit 5254d33 into master Mar 23, 2019
@CatherineSue CatherineSue deleted the newer-logger branch March 26, 2019 00:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants