Skip to content

Commit

Permalink
Fix single quotes and add extra test case
Browse files Browse the repository at this point in the history
  • Loading branch information
jesszzzz committed Nov 15, 2024
1 parent ea30b2b commit 09c9967
Show file tree
Hide file tree
Showing 6 changed files with 373 additions and 185 deletions.
2 changes: 1 addition & 1 deletion hydra/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,6 @@ def to_hydra_override_value_str(obj: Any) -> str:
"[" + ", ".join([to_hydra_override_value_str(value) for value in obj]) + "]"
)
elif isinstance(obj, str):
new_str = obj.replace('\\"', '\\\\"').replace('"', '\\"')
new_str = obj.replace('\\"', '\\\\"').replace('"', '\\"').replace("\\'", "\\\'")
return f'"{new_str}"'
return json.dumps(obj)
20 changes: 20 additions & 0 deletions tests/jupyter/$tmpdir/.hydra/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
db:
driver: mysql
user: omry
pass: secret
ui:
windows:
create_db: true
view: true
schema:
database: school
tables:
- name: students
fields:
- name: string
- class: int
- name: exams
fields:
- profession: string
- time: data
- class: int
159 changes: 159 additions & 0 deletions tests/jupyter/$tmpdir/.hydra/hydra.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
hydra:
run:
dir: $tmpdir
sweep:
dir: multirun/${now:%Y-%m-%d}/${now:%H-%M-%S}
subdir: ${hydra.job.num}
launcher:
_target_: hydra._internal.core_plugins.basic_launcher.BasicLauncher
sweeper:
_target_: hydra._internal.core_plugins.basic_sweeper.BasicSweeper
max_batch_size: null
params: null
help:
app_name: ${hydra.job.name}
header: '${hydra.help.app_name} is powered by Hydra.
'
footer: 'Powered by Hydra (https://hydra.cc)
Use --hydra-help to view Hydra specific help
'
template: '${hydra.help.header}
== Configuration groups ==
Compose your configuration from those groups (group=option)
$APP_CONFIG_GROUPS
== Config ==
Override anything in the config (foo.bar=value)
$CONFIG
${hydra.help.footer}
'
hydra_help:
template: 'Hydra (${hydra.runtime.version})
See https://hydra.cc for more info.
== Flags ==
$FLAGS_HELP
== Configuration groups ==
Compose your configuration from those groups (For example, append hydra/job_logging=disabled
to command line)
$HYDRA_CONFIG_GROUPS
Use ''--cfg hydra'' to Show the Hydra config.
'
hydra_help: ???
hydra_logging:
version: 1
formatters:
simple:
format: '[%(asctime)s][HYDRA] %(message)s'
handlers:
console:
class: logging.StreamHandler
formatter: simple
stream: ext://sys.stdout
root:
level: INFO
handlers:
- console
loggers:
logging_example:
level: DEBUG
disable_existing_loggers: false
job_logging:
version: 1
formatters:
simple:
format: '[%(asctime)s][%(name)s][%(levelname)s] - %(message)s'
handlers:
console:
class: logging.StreamHandler
formatter: simple
stream: ext://sys.stdout
file:
class: logging.FileHandler
formatter: simple
filename: ${hydra.runtime.output_dir}/${hydra.job.name}.log
root:
level: INFO
handlers:
- console
- file
disable_existing_loggers: false
env: {}
mode: RUN
searchpath: []
callbacks: {}
output_subdir: .hydra
overrides:
hydra:
- hydra.run.dir="$tmpdir"
- hydra.job.chdir=True
- hydra.mode=RUN
task: []
job:
name: my_app
chdir: true
override_dirname: ''
id: ???
num: ???
config_name: config
env_set: {}
env_copy: []
config:
override_dirname:
kv_sep: '='
item_sep: ','
exclude_keys: []
runtime:
version: 1.4.0.dev1
version_base: '1.4'
cwd: /Users/jszhang/hydra/tests/jupyter
config_sources:
- path: hydra.conf
schema: pkg
provider: hydra
- path: /Users/jszhang/hydra/examples/tutorials/basic/your_first_hydra_app/6_composition/conf
schema: file
provider: main
- path: ''
schema: structured
provider: schema
output_dir: /Users/jszhang/hydra/tests/jupyter/$tmpdir
choices:
schema: school
ui: full
db: mysql
hydra/env: default
hydra/callbacks: null
hydra/job_logging: default
hydra/hydra_logging: default
hydra/hydra_help: default
hydra/help: default
hydra/sweeper: basic
hydra/launcher: basic
hydra/output: default
verbose: false
1 change: 1 addition & 0 deletions tests/jupyter/$tmpdir/.hydra/overrides.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Empty file.
Loading

0 comments on commit 09c9967

Please sign in to comment.