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

An easier way to configure test cases #71

Closed
wants to merge 34 commits into from

Conversation

undefined-moe
Copy link
Member

config.json like this:

{
  "time":1,
  "memory":128000,
  "cases":10
}

And your file should be like this:

  • 1.in
  • 1.out
  • 2.in
  • 2.out
  • ...
  • 10.in
  • 10.out

@twd2
Copy link
Member

twd2 commented Apr 12, 2019

Why is this format necessary? Which OJ is currently using this format?
This format does not have any more feature compared with config.ini format.

@undefined-moe
Copy link
Member Author

Some users just want to add config files easily.
And by adding this format,they don't need to copy&paste lines like
foo1.in|foo1.out|1|10|128000 or

- <<: *default
  input: bar1.in
  output: bar1.out

It allow users to config it easily.
Maybe I will add some extra features later.
e.g.

  • search for input&output files automatically (without cases field required)
  • support file prefix like foo.in foo.out

@twd2
Copy link
Member

twd2 commented Apr 12, 2019

A better way may be enhancing the existing yaml format.

@undefined-moe
Copy link
Member Author

Got it.
I'll make some changes later.

@undefined-moe
Copy link
Member Author

Write config.yaml like this:

time: 1
memory: 128000
count: 10

Copy link
Member

@twd2 twd2 left a comment

Choose a reason for hiding this comment

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

Please add some necessary spaces.
And, please ensure your code can run before commit.

For example, i+'.in' should be str(i) + '.in'

@undefined-moe undefined-moe changed the title Json config file support A easier way to write config.yaml Apr 13, 2019
Copy link
Member

@twd2 twd2 left a comment

Choose a reason for hiding this comment

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

These suggestions are about the code style, and, @iceb0y PTAL
BTW, we appreciated if you can give an example for each new format.

jd4/case.py Outdated Show resolved Hide resolved
jd4/case.py Outdated Show resolved Hide resolved
jd4/case.py Outdated Show resolved Hide resolved
jd4/case.py Outdated Show resolved Hide resolved
jd4/case.py Outdated Show resolved Hide resolved
jd4/case.py Outdated Show resolved Hide resolved
jd4/case.py Outdated Show resolved Hide resolved
jd4/case.py Outdated Show resolved Hide resolved
jd4/case.py Outdated Show resolved Hide resolved
jd4/case.py Outdated Show resolved Hide resolved
@moesoha
Copy link
Member

moesoha commented Apr 14, 2019

Please mark conversation resolved immediately after you made some changes.

Copy link
Member

@moesoha moesoha left a comment

Choose a reason for hiding this comment

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

Thanks for contribution!

.gitignore Outdated Show resolved Hide resolved
jd4/case.py Outdated Show resolved Hide resolved
jd4/case.py Outdated Show resolved Hide resolved
jd4/case.py Outdated Show resolved Hide resolved
@undefined-moe
Copy link
Member Author

It seems that the problem is fixed now.

@undefined-moe undefined-moe changed the title A easier way to write config.yaml A easier way to configure test cases Apr 14, 2019
jd4/case.py Outdated Show resolved Hide resolved
jd4/case.py Outdated Show resolved Hide resolved
jd4/case.py Outdated Show resolved Hide resolved
jd4/case.py Outdated Show resolved Hide resolved
jd4/case.py Outdated Show resolved Hide resolved
jd4/case.py Outdated Show resolved Hide resolved
jd4/case.py Show resolved Hide resolved
@twd2
Copy link
Member

twd2 commented Apr 14, 2019

@iceb0y PTAL

jd4/case.py Outdated Show resolved Hide resolved
@undefined-moe undefined-moe dismissed stale reviews from twd2 and moesoha via 30d4186 April 15, 2019 05:51
moesoha
moesoha previously approved these changes Apr 15, 2019
Copy link
Member

@moesoha moesoha left a comment

Choose a reason for hiding this comment

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

LGTM, @iceb0y review plz😭

@undefined-moe
Copy link
Member Author

@iceb0y 😢 are you there?

@twd2
Copy link
Member

twd2 commented Apr 18, 2019

PTAL @iceb0y , please

@iceboy233
Copy link
Member

Instead of doing this, can you create a SDK to generate config file?

@twd2
Copy link
Member

twd2 commented Apr 19, 2019

Creating an SDK to generate config files seems to be a new issue.
so, can I merge this PR?

@undefined-moe
Copy link
Member Author

I've written an SDK.
But it seems that it will be more convenient as user can use the same .zip file for all oj.(like luogu,hustoj,qingdaou/onlinejudge)

@iceboy233
Copy link
Member

Actually we have a luogu dev @moesoha here. What about create a common library for parsing and creating case packages? The library can be multi-language if needed. Note that we also had intention to move case storage to git repositories.

If we wanted to merge this alone, we need to refine both logic and implementation (as discussed in vijos-dev privately). For logic, we need to make "config file missing" = "empty config" = "scanning files in zip". For implementation, we should use names from canonical_dict instead of zip_file.

@undefined-moe
Copy link
Member Author

You mean create a new repo for parsing packages?

@twd2 twd2 changed the title A easier way to configure test cases An easier way to configure test cases Apr 21, 2019
@twd2
Copy link
Member

twd2 commented Apr 21, 2019

Please refine both logic and implementation as @iceb0y said so that this PR can be merged.

@undefined-moe
Copy link
Member Author

I don't understand what to do.

def read_auto_cases(open, zip_file, time_limit='1s', memory_limit='128m', judge=''):
prefix = ''
cases = []
for filename in zip_file.namelist():
Copy link
Member

Choose a reason for hiding this comment

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

for filename in canonical_dict.keys():

cdef int b

cdef int a, b
cdef str cache_a = "", cache_b = ""
Copy link
Member

Choose a reason for hiding this comment

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

This looks very slow. Consider using a expanding buffer (like c++'s std::vector).

Also str is unicode in python 3, but the byte to char conversion is not needed here.

Copy link
Member Author

Choose a reason for hiding this comment

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

a,b is a int, so convert is needed.
These changes are not going to be merged now.
It's only a self-test as we also need to modify vj4/handler/judge.py & vj4/ui/templates/record_detail.html .

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.

5 participants